001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.plugins.streetside;
003
004import java.util.List;
005
006import org.openstreetmap.josm.data.coor.LatLon;
007import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils;
008import org.openstreetmap.josm.plugins.streetside.model.UserProfile;
009
010/**
011 * A StreetsideImage object represents each of the images stored in Streetside.
012 *
013 * @author nokutu
014 * @author renerr18
015 *
016 * @see StreetsideSequence
017 * @see StreetsideData
018 */
019public class StreetsideImage extends StreetsideAbstractImage {
020  /**
021   * Rn is a Bing Streetside image attribute - currently not
022   * used, mapped or supported in the Streetside plugin -
023   * left out initially because it's an unrequired complex object.
024   */
025  public static class Rn {
026          // placeholder for Rn attribute (undocumented streetside complex inner type)
027  }
028
029  // latitude of the Streetside image
030  private double la;
031
032  //longitude of the Streetside image
033  private double lo;
034
035  // The bubble altitude, in meters above the WGS84 ellipsoid
036  private double al;
037
038  // Roll
039  private double ro;
040
041  // Pitch
042  private double pi;
043
044  // Blurring instructions - not currently used by the plugin
045  private String bl;
046
047  // Undocumented Attributes
048  private int ml;
049  private List<String> nbn;
050  private List<String> pbn;
051  private int ad;
052  private Rn rn;
053
054  /**
055   * Main constructor of the class StreetsideImage
056   *
057   * @param id     The unique identifier of the image.
058   * @param latLon The latitude and longitude where it is positioned.
059   * @param he     The direction of the images in degrees, meaning 0 north.
060   */
061  public StreetsideImage(String id, LatLon latLon, double he) {
062    super(id, latLon, he);
063  }
064
065  public StreetsideImage(String id, double la, double lo) {
066    super(id, new LatLon(la,lo), 0.0);
067  }
068
069  public StreetsideImage(String id) {
070            super(id);
071  }
072
073  // Default constructor for Jackson/JSON Deserializattion
074  public StreetsideImage() {
075    super(CubemapUtils.TEST_IMAGE_ID, null, 0.0);
076  }
077
078  /**
079   * Returns the unique identifier of the object.
080   *
081   * @return A {@code String} containing the unique identifier of the object.
082   */
083  @Override
084public String getId() {
085    return String.valueOf(id);
086  }
087
088  public UserProfile getUser() {
089            return getSequence().getUser();
090  }
091
092  @Override
093  public String toString() {
094    return String.format(
095      "Image[id=%s,lat=%f,lon=%f,he=%f,user=%s]",
096      id, latLon.lat(), latLon.lon(), he, "null"//, cd
097    );
098  }
099
100  @Override
101  public boolean equals(Object object) {
102    return object instanceof StreetsideImage && id.equals(((StreetsideImage) object).getId());
103  }
104
105  @Override
106  public int compareTo(StreetsideAbstractImage image) {
107    if (image instanceof StreetsideImage) {
108      return id.compareTo(((StreetsideImage) image).getId());
109    }
110    return hashCode() - image.hashCode();
111  }
112
113  @Override
114  public int hashCode() {
115    return id.hashCode();
116  }
117
118  @Override
119  public void stopMoving() {
120    super.stopMoving();
121    checkModified();
122  }
123
124  private void checkModified() {
125    // modifications not currently supported in Streetside
126  }
127
128  @Override
129  public void turn(double ca) {
130    super.turn(ca);
131    checkModified();
132  }
133
134  /**
135   * @return the altitude
136   */
137  public double getAl() {
138    return al;
139  }
140
141  /**
142   * @param altitude the altitude to set
143   */
144  public void setAl(double altitude) {
145    al = altitude;
146  }
147
148  /**
149   * @return the roll
150   */
151  public double getRo() {
152    return ro;
153  }
154
155  /**
156   * @param roll the roll to set
157   */
158  public void setRo(double roll) {
159    ro = roll;
160  }
161
162  /**
163   * @return the pi
164   */
165  public double getPi() {
166    return pi;
167  }
168
169  /**
170   * @param pitch the pi to set
171   */
172  public void setPi(double pitch) {
173    pi = pitch;
174  }
175
176  /**
177   * @return the burringl
178   */
179  public String getBl() {
180    return bl;
181  }
182
183  /**
184   * @param blurring the blurring to set
185   */
186  public void setBl(String blurring) {
187    bl = blurring;
188  }
189
190  /**
191   * @return the ml
192   */
193  public int getMl() {
194    return ml;
195  }
196
197  /**
198   * @param ml the ml to set
199   */
200  public void setMl(int ml) {
201    this.ml = ml;
202  }
203
204  /**
205   * @return the nbn
206   */
207  public List<String> getNbn() {
208    return nbn;
209  }
210
211  /**
212   * @param nbn the nbn to set
213   */
214  public void setNbn(List<String> nbn) {
215    this.nbn = nbn;
216  }
217
218  /**
219   * @return the pbn
220   */
221  public List<String> getPbn() {
222    return pbn;
223  }
224
225  /**
226   * @param pbn the pbn to set
227   */
228  public void setPbn(List<String> pbn) {
229    this.pbn = pbn;
230  }
231
232  /**
233   * @return the ad
234   */
235  public int getAd() {
236    return ad;
237  }
238
239  /**
240   * @param ad the ad to set
241   */
242  public void setAd(int ad) {
243    this.ad = ad;
244  }
245
246  /**
247   * @return the la
248   */
249  public double getLa() {
250    return la;
251  }
252
253  /**
254   * @param la the la to set
255   */
256  public void setLa(double la) {
257    this.la = la;
258  }
259
260  /**
261   * @return the lo
262   */
263  public double getLo() {
264    return lo;
265  }
266
267  /**
268   * @param lo the lo to set
269   */
270  public void setLo(double lo) {
271    this.lo = lo;
272  }
273
274  /**
275   * @param id the id to set
276   */
277  @Override
278public void setId(String id) {
279    this.id = id;
280  }
281
282  /**
283   * @return the rn
284   */
285  public Rn getRn() {
286    return rn;
287  }
288
289  /**
290   * @param rn the rn to set
291   */
292  public void setRn(Rn rn) {
293    this.rn = rn;
294  }
295}