Changeset 4241 in josm for trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
- Timestamp:
- 2011-07-14T17:00:22+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r4010 r4241 63 63 import com.drew.metadata.Directory; 64 64 import com.drew.metadata.Metadata; 65 import com.drew.metadata.MetadataException; 66 import com.drew.metadata.exif.ExifDirectory; 65 67 import com.drew.metadata.exif.GpsDirectory; 66 68 … … 509 511 double lon, lat; 510 512 Metadata metadata = null; 511 Directory dir = null;513 Directory dirExif = null, dirGps = null; 512 514 513 515 try { 514 516 metadata = JpegMetadataReader.readMetadata(e.getFile()); 515 dir = metadata.getDirectory(GpsDirectory.class); 517 dirExif = metadata.getDirectory(ExifDirectory.class); 518 dirGps = metadata.getDirectory(GpsDirectory.class); 516 519 } catch (CompoundException p) { 517 520 e.setExifCoor(null); … … 521 524 522 525 try { 526 int orientation = dirExif.getInt(ExifDirectory.TAG_ORIENTATION); 527 e.setExifOrientation(orientation); 528 } catch (MetadataException ex) { 529 } 530 531 try { 523 532 // longitude 524 533 525 Rational[] components = dir .getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE);534 Rational[] components = dirGps.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE); 526 535 527 536 deg = components[0].doubleValue(); … … 534 543 lon = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600))); 535 544 536 if (dir .getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') {545 if (dirGps.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF).charAt(0) == 'W') { 537 546 lon = -lon; 538 547 } … … 540 549 // latitude 541 550 542 components = dir .getRationalArray(GpsDirectory.TAG_GPS_LATITUDE);551 components = dirGps.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE); 543 552 544 553 deg = components[0].doubleValue(); … … 554 563 throw new IllegalArgumentException(); 555 564 556 if (dir .getString(GpsDirectory.TAG_GPS_LATITUDE_REF).charAt(0) == 'S') {565 if (dirGps.getString(GpsDirectory.TAG_GPS_LATITUDE_REF).charAt(0) == 'S') { 557 566 lat = -lat; 558 567 } … … 566 575 // Try to read lon/lat as double value (Nonstandard, created by some cameras -> #5220) 567 576 try { 568 Double longitude = dir .getDouble(GpsDirectory.TAG_GPS_LONGITUDE);569 Double latitude = dir .getDouble(GpsDirectory.TAG_GPS_LATITUDE);577 Double longitude = dirGps.getDouble(GpsDirectory.TAG_GPS_LONGITUDE); 578 Double latitude = dirGps.getDouble(GpsDirectory.TAG_GPS_LATITUDE); 570 579 if (longitude == null || latitude == null) 571 580 throw new CompoundException(""); … … 590 599 591 600 try { 592 direction = dir .getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);601 direction = dirGps.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION); 593 602 if (direction != null) { 594 603 e.setExifImgDir(direction.doubleValue());
Note:
See TracChangeset
for help on using the changeset viewer.