Changeset 6209 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2013-08-30T11:36:28+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r6128 r6209 65 65 import com.drew.imaging.jpeg.JpegMetadataReader; 66 66 import com.drew.lang.CompoundException; 67 import com.drew.lang.Rational;68 67 import com.drew.metadata.Directory; 69 68 import com.drew.metadata.Metadata; … … 72 71 import com.drew.metadata.exif.GpsDirectory; 73 72 73 /** 74 * Layer displaying geottaged pictures. 75 */ 74 76 public class GeoImageLayer extends Layer implements PropertyChangeListener, JumpToMarkerLayer { 75 77 … … 263 265 } 264 266 267 /** 268 * Constructs a new {@code GeoImageLayer}. 269 * @param data The list of images to display 270 * @param gpxLayer The associated GPX layer 271 */ 265 272 public GeoImageLayer(final List<ImageEntry> data, GpxLayer gpxLayer) { 266 267 273 super(tr("Geotagged Images")); 268 274 … … 499 505 } 500 506 501 /* 502 * Extract gps from image exif507 /** 508 * Extract GPS metadata from image EXIF 503 509 * 504 * If successful, fills in the LatLon and EastNorth attributes of passed in 505 * image; 510 * If successful, fills in the LatLon and EastNorth attributes of passed in image 506 511 */ 507 508 512 private static void extractExif(ImageEntry e) { 509 513 510 double deg;511 double min, sec;512 double lon, lat;513 514 Metadata metadata; 514 515 Directory dirExif; … … 542 543 543 544 try { 544 double ele =dirGps.getDouble(GpsDirectory.TAG_GPS_ALTITUDE);545 double ele = dirGps.getDouble(GpsDirectory.TAG_GPS_ALTITUDE); 545 546 int d = dirGps.getInt(GpsDirectory.TAG_GPS_ALTITUDE_REF); 546 547 if (d == 1) { … … 552 553 553 554 try { 554 // longitude 555 556 Rational[] components = dirGps.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE); 557 if (components != null) { 558 deg = components[0].doubleValue(); 559 min = components[1].doubleValue(); 560 sec = components[2].doubleValue(); 561 562 if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec)) 563 throw new IllegalArgumentException(); 564 565 lon = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600))); 566 567 if (dirGps.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') { 568 lon = -lon; 569 } 570 } else { 571 // Try to read lon/lat as double value (Nonstandard, created by some cameras -> #5220) 572 lon = dirGps.getDouble(GpsDirectory.TAG_GPS_LONGITUDE); 573 } 574 575 // latitude 576 577 components = dirGps.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE); 578 if (components != null) { 579 deg = components[0].doubleValue(); 580 min = components[1].doubleValue(); 581 sec = components[2].doubleValue(); 582 583 if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec)) 584 throw new IllegalArgumentException(); 585 586 lat = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600))); 587 588 if (Double.isNaN(lat)) 589 throw new IllegalArgumentException(); 590 591 if (dirGps.getString(GpsDirectory.TAG_GPS_LATITUDE_REF).charAt(0) == 'S') { 592 lat = -lat; 593 } 594 } else { 595 lat = dirGps.getDouble(GpsDirectory.TAG_GPS_LATITUDE); 596 } 597 598 // Store values 599 600 e.setExifCoor(new LatLon(lat, lon)); 555 LatLon latlon = ExifReader.readLatLon(dirGps); 556 e.setExifCoor(latlon); 601 557 e.setPos(e.getExifCoor()); 602 558 … … 607 563 } 608 564 609 // compass direction value610 611 Rational direction = null;612 613 565 try { 614 direction = dirGps.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);566 Double direction = ExifReader.readDirection(dirGps); 615 567 if (direction != null) { 616 568 e.setExifImgDir(direction.doubleValue()); … … 846 798 } 847 799 800 /** 801 * Returns the associated GPX layer. 802 * @return The associated GPX layer 803 */ 848 804 public GpxLayer getGpxLayer() { 849 805 return gpxLayer;
Note:
See TracChangeset
for help on using the changeset viewer.