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