Changeset 31549 in osm for applications/editors/josm
- Timestamp:
- 2015-09-13T17:59:23+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31515 r31549 18 18 19 19 /** The time the image was captured, in Epoch format. */ 20 pr ivatelong capturedAt;20 protected long capturedAt; 21 21 /** Sequence of pictures containing this object. */ 22 22 private MapillarySequence sequence; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
r31513 r31549 21 21 protected File file; 22 22 /** The date when the picture was taken. */ 23 public long datetimeOriginal;24 23 25 24 /** … … 59 58 this.file = file; 60 59 try { 61 this.datetimeOriginal = MapillaryUtils.getEpoch(datetimeOriginal, "yyyy:MM:dd hh:mm:ss"); 60 this.capturedAt = MapillaryUtils.getEpoch(datetimeOriginal, 61 "yyyy:MM:dd hh:mm:ss"); 62 62 } catch (ParseException e) { 63 63 try { 64 this. datetimeOriginal= MapillaryUtils.getEpoch(datetimeOriginal,64 this.capturedAt = MapillaryUtils.getEpoch(datetimeOriginal, 65 65 "yyyy/MM/dd hh:mm:ss"); 66 66 } catch (ParseException e1) { 67 this. datetimeOriginal= MapillaryUtils.currentTime();67 this.capturedAt = MapillaryUtils.currentTime(); 68 68 } 69 69 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java
r31515 r31549 37 37 .getString("username"); 38 38 } catch (IOException e) { 39 Main. error(e);40 isTokenValid = false;39 Main.info("Invalid Mapillary token, reseting field"); 40 reset(); 41 41 } 42 42 return username; … … 66 66 .getString("images_policy"); 67 67 } catch (IOException e) { 68 Main. error(e);69 isTokenValid = false;68 Main.info("Invalid Mapillary token, reseting field"); 69 reset(); 70 70 } 71 71 hash.put("images_policy", images_policy); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r31515 r31549 211 211 String key = MapillaryUser.getUsername() + "/" + uuid.toString() + "/" 212 212 + image.getLatLon().lat() + "_" + image.getLatLon().lon() + "_" 213 + image.getCa() + "_" + image. datetimeOriginal+ ".jpg";213 + image.getCa() + "_" + image.getCapturedAt() + ".jpg"; 214 214 215 215 String policy = null; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31513 r31549 118 118 * not one of the values mentioned above 119 119 */ 120 public static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) { 120 public static double degMinSecToDouble(RationalNumber[] degMinSec, 121 String ref) { 121 122 if (degMinSec == null || degMinSec.length != 3) { 122 123 throw new IllegalArgumentException("Array's length must be 3."); … … 145 146 } 146 147 147 result = 360 * ((result + 180) / 360 - Math.floor((result + 180) / 360)) - 180; 148 result = 360 * ((result + 180) / 360 - Math.floor((result + 180) / 360)) 149 - 180; 148 150 return result; 149 151 } … … 159 161 * @throws ParseException 160 162 */ 161 public static long getEpoch(String date, String format) throws ParseException { 163 public static long getEpoch(String date, String format) 164 throws ParseException { 162 165 SimpleDateFormat formatter = new SimpleDateFormat(format); 163 166 Date dateTime = formatter.parse(date); … … 229 232 * If the file doesn't have the valid metadata. 230 233 */ 231 public static MapillaryImportedImage readJPG(File file) throws IOException,232 ImageReadException {234 public static MapillaryImportedImage readJPG(File file) 235 throws IOException, ImageReadException { 233 236 return readJPG(file, false); 234 237 } … … 259 262 if (metadata instanceof JpegImageMetadata) { 260 263 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; 261 final TiffField lat_ref = jpegMetadata 262 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);264 final TiffField lat_ref = jpegMetadata.findEXIFValueWithExactMatch( 265 GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); 263 266 final TiffField lat = jpegMetadata 264 267 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE); 265 final TiffField lon_ref = jpegMetadata 266 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);268 final TiffField lon_ref = jpegMetadata.findEXIFValueWithExactMatch( 269 GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); 267 270 final TiffField lon = jpegMetadata 268 271 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); 269 final TiffField ca = jpegMetadata 270 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);272 final TiffField ca = jpegMetadata.findEXIFValueWithExactMatch( 273 GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); 271 274 final TiffField datetimeOriginal = jpegMetadata 272 .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); 275 .findEXIFValueWithExactMatch( 276 ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); 273 277 if (lat_ref == null || lat == null || lon == null || lon_ref == null) { 274 278 if (exceptionNoTags) … … 307 311 */ 308 312 public static MapillaryImportedImage readNoTags(File file) { 309 return readNoTags( 310 file, 311 Main.map.mapView.getProjection().eastNorth2latlon( 312 Main.map.mapView.getCenter())); 313 return readNoTags(file, Main.map.mapView.getProjection() 314 .eastNorth2latlon(Main.map.mapView.getCenter())); 313 315 } 314 316 … … 327 329 double HORIZONTAL_DISTANCE = 0.0001; 328 330 double horDev; 331 329 332 if (noTagsPics % 2 == 0) 330 333 horDev = HORIZONTAL_DISTANCE * noTagsPics / 2; … … 332 335 horDev = -HORIZONTAL_DISTANCE * ((noTagsPics + 1) / 2); 333 336 noTagsPics++; 337 338 ImageMetadata metadata = null; 339 try { 340 metadata = Imaging.getMetadata(file); 341 } catch (IOException e) { 342 Main.error(e); 343 } catch (ImageReadException e) { 344 Main.error(e); 345 } 346 if (metadata instanceof JpegImageMetadata) { 347 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; 348 final TiffField datetimeOriginal = jpegMetadata 349 .findEXIFValueWithExactMatch( 350 ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); 351 if (datetimeOriginal == null) 352 return new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, 353 file); 354 else { 355 try { 356 return new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, 357 file, datetimeOriginal.getStringValue()); 358 } catch (ImageReadException e) { 359 Main.error(e); 360 } 361 } 362 } 334 363 return new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file); 335 364 } … … 386 415 maxLon = img.getLatLon().lon(); 387 416 } 388 Bounds zoomBounds = new Bounds(new LatLon(minLat, minLon), new LatLon(389 maxLat, maxLon));417 Bounds zoomBounds = new Bounds(new LatLon(minLat, minLon), 418 new LatLon(maxLat, maxLon)); 390 419 // The zoom rectangle must have a minimum size. 391 double latExtent = zoomBounds.getMaxLat() - zoomBounds.getMinLat() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds 392 .getMaxLat() - zoomBounds.getMinLat() 393 : MIN_ZOOM_SQUARE_SIDE; 394 double lonExtent = zoomBounds.getMaxLon() - zoomBounds.getMinLon() >= MIN_ZOOM_SQUARE_SIDE ? zoomBounds 395 .getMaxLon() - zoomBounds.getMinLon() 396 : MIN_ZOOM_SQUARE_SIDE; 420 double latExtent = zoomBounds.getMaxLat() 421 - zoomBounds.getMinLat() >= MIN_ZOOM_SQUARE_SIDE 422 ? zoomBounds.getMaxLat() - zoomBounds.getMinLat() 423 : MIN_ZOOM_SQUARE_SIDE; 424 double lonExtent = zoomBounds.getMaxLon() 425 - zoomBounds.getMinLon() >= MIN_ZOOM_SQUARE_SIDE 426 ? zoomBounds.getMaxLon() - zoomBounds.getMinLon() 427 : MIN_ZOOM_SQUARE_SIDE; 397 428 zoomBounds = new Bounds(zoomBounds.getCenter(), latExtent, lonExtent); 398 429 … … 423 454 } 424 455 425 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(firstImage 426 .getSequence().getImages() 427 .subList(0, firstImage.getSequence().getImages().indexOf(secondImage))); 428 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(firstImage 429 .getSequence() 430 .getImages() 431 .subList(firstImage.getSequence().getImages().indexOf(secondImage), 456 ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>( 457 firstImage.getSequence().getImages().subList(0, 458 firstImage.getSequence().getImages().indexOf(secondImage))); 459 ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>( 460 firstImage.getSequence().getImages().subList( 461 firstImage.getSequence().getImages().indexOf(secondImage), 432 462 firstImage.getSequence().getImages().size())); 433 463 … … 455 485 ret += tr("Downloading Mapillary images"); 456 486 else if (MapillaryLayer.getInstance().getData().size() > 0) 457 ret += tr("Total Mapillary images: {0}", MapillaryLayer.getInstance()458 .getData().size());487 ret += tr("Total Mapillary images: {0}", 488 MapillaryLayer.getInstance().getData().size()); 459 489 else 460 490 ret += tr("No images found");
Note:
See TracChangeset
for help on using the changeset viewer.