    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 nexted Rn attribute
    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   * Set of traffic signs in the image.
    056   *//*
    057  private final List<ImageDetection> detections = Collections.synchronizedList(new ArrayList<>());
    058*/
    059  /**
    060   * Main constructor of the class StreetsideImage
    061   *
    062   * @param id     The unique identifier of the image.
    063   * @param latLon The latitude and longitude where it is positioned.
    064   * @param he     The direction of the images in degrees, meaning 0 north.
    065   */
    066  public StreetsideImage(String id, LatLon latLon, double he) {
    067    super(id, latLon, he);
    068  }
    069
    070  public StreetsideImage(String id, LatLon latLon) {
    071    super(id, latLon, 0.0);
    072  }
    073
    074  public StreetsideImage(String id, double la, double lo) {
    075    super(id, new LatLon(la,lo), 0.0);
    076  }
    077
    078  public StreetsideImage(String id) {
    079            super(id);
    080  }
    081
    082  // Default constructor for Jackson/JSON Deserializattion
    083  public StreetsideImage() {
    084    super(CubemapUtils.IMPORTED_ID, null, 0.0);
    085  }
    086
    087  /**
    088   * Returns the unique identifier of the object.
    089   *
    090   * @return A {@code String} containing the unique identifier of the object.
    091   */
    092  @Override
    093public String getId() {
    094    return String.valueOf(id);
    095  }
    096
    097  /*public List<ImageDetection> getDetections() {
    098    return detections;
    099  }*/
    100
    101  /*public void setAllDetections(Collection<ImageDetection> newDetections) {
    102    Logging.debug("Add {0} detections to image {1}", newDetections.size(), getId());
    103    synchronized (detections) {
    104      detections.clear();
    105      detections.addAll(newDetections);
    106    }
    107  }*/
    108
    109  public UserProfile getUser() {
    110            return getSequence().getUser();
    111  }
    112
    113  @Override
    114  public String toString() {
    115    return String.format(
    116      // TODO: format date cd (Gradle build error command line)
    117      "Image[id=%s,lat=%f,lon=%f,he=%f,user=%s]",
    118      id, latLon.lat(), latLon.lon(), he, "null"//, cd
    119    );
    120  }
    121
    122  // TODO: implement equals @rrh
    123  @Override
    124  public boolean equals(Object object) {
    125    return object instanceof StreetsideImage && id.equals(((StreetsideImage) object).getId());
    126  }
    127
    128  // TODO: implement compareTo @rrh
    129  @Override
    130  public int compareTo(StreetsideAbstractImage image) {
    131    if (image instanceof StreetsideImage) {
    132      return id.compareTo(((StreetsideImage) image).getId());
    133    }
    134    return hashCode() - image.hashCode();
    135  }
    136
    137  // TODO: implement hashcode @rrh
    138  @Override
    139  public int hashCode() {
    140    return id.hashCode();
    141  }
    142
    143  @Override
    144  public void stopMoving() {
    145    super.stopMoving();
    146    checkModified();
    147  }
    148
    149  private void checkModified() {
    150    if (StreetsideLayer.hasInstance()) {
    151      if (isModified()) {
    152        StreetsideLayer.getInstance().getLocationChangeset().add(this);
    153      } else {
    154        StreetsideLayer.getInstance().getLocationChangeset().remove(this);
    155      }
    156    }
    157  }
    158
    159  @Override
    160  public void turn(double ca) {
    161    super.turn(ca);
    162    checkModified();
    163  }
    164
    165  /**
    166   * @return the altitude
    167   */
    168  public double getAl() {
    169    return al;
    170  }
    171
    172  /**
    173   * @param altitude the altitude to set
    174   */
    175  public void setAl(double altitude) {
    176    al = altitude;
    177  }
    178
    179  /**
    180   * @return the roll
    181   */
    182  public double getRo() {
    183    return ro;
    184  }
    185
    186  /**
    187   * @param roll the roll to set
    188   */
    189  public void setRo(double roll) {
    190    ro = roll;
    191  }
    192
    193  /**
    194   * @return the pi
    195   */
    196  public double getPi() {
    197    return pi;
    198  }
    199
    200  /**
    201   * @param pitch the pi to set
    202   */
    203  public void setPi(double pitch) {
    204    pi = pitch;
    205  }
    206
    207  /**
    208   * @return the burringl
    209   */
    210  public String getBl() {
    211    return bl;
    212  }
    213
    214  /**
    215   * @param blurring the blurring to set
    216   */
    217  public void setBl(String blurring) {
    218    bl = blurring;
    219  }
    220
    221  /**
    222   * @return the ml
    223   */
    224  public int getMl() {
    225    return ml;
    226  }
    227
    228  /**
    229   * @param ml the ml to set
    230   */
    231  public void setMl(int ml) {
    232    this.ml = ml;
    233  }
    234
    235  /**
    236   * @return the nbn
    237   */
    238  public List<String> getNbn() {
    239    return nbn;
    240  }
    241
    242  /**
    243   * @param nbn the nbn to set
    244   */
    245  public void setNbn(List<String> nbn) {
    246    this.nbn = nbn;
    247  }
    248
    249  /**
    250   * @return the pbn
    251   */
    252  public List<String> getPbn() {
    253    return pbn;
    254  }
    255
    256  /**
    257   * @param pbn the pbn to set
    258   */
    259  public void setPbn(List<String> pbn) {
    260    this.pbn = pbn;
    261  }
    262
    263  /**
    264   * @return the ad
    265   */
    266  public int getAd() {
    267    return ad;
    268  }
    269
    270  /**
    271   * @param ad the ad to set
    272   */
    273  public void setAd(int ad) {
    274    this.ad = ad;
    275  }
    276
    277  /**
    278   * @return the la
    279   */
    280  public double getLa() {
    281    return la;
    282  }
    283
    284  /**
    285   * @param la the la to set
    286   */
    287  public void setLa(double la) {
    288    this.la = la;
    289  }
    290
    291  /**
    292   * @return the lo
    293   */
    294  public double getLo() {
    295    return lo;
    296  }
    297
    298  /**
    299   * @param lo the lo to set
    300   */
    301  public void setLo(double lo) {
    302    this.lo = lo;
    303  }
    304
    305  /**
    306   * @param id the id to set
    307   */
    308  @Override
    309public void setId(String id) {
    310    this.id = id;
    311  }
    312
    313  /**
    314   * @return the rn
    315   */
    316  public Rn getRn() {
    317    return rn;
    318  }
    319
    320  /**
    321   * @param rn the rn to set
    322   */
    323  public void setRn(Rn rn) {
    324    this.rn = rn;
    325  }
    326}