]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/jpeg/ExternalExifLibrary.java
Version 12, December 2010
[GpsPrune.git] / tim / prune / jpeg / ExternalExifLibrary.java
index b9cd1fdadf33bb739868d98c716c8d8b4d44fc16..cff2346e531dff458d4b91a1a49822a270087d51 100644 (file)
@@ -42,12 +42,14 @@ public class ExternalExifLibrary implements ExifLibrary
                                {
                                        data.setLatitudeRef(gpsdir.getString(GpsDirectory.TAG_GPS_LATITUDE_REF));
                                        Rational[] latRats = gpsdir.getRationalArray(GpsDirectory.TAG_GPS_LATITUDE);
+                                       double seconds = ExifGateway.convertToPositiveValue(latRats[2].getNumerator(), latRats[2].getDenominator());
                                        data.setLatitude(new double[] {latRats[0].doubleValue(),
-                                               latRats[1].doubleValue(), latRats[2].doubleValue()});
+                                               latRats[1].doubleValue(), seconds});
                                        data.setLongitudeRef(gpsdir.getString(GpsDirectory.TAG_GPS_LONGITUDE_REF));
                                        Rational[] lonRats = gpsdir.getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE);
+                                       seconds = ExifGateway.convertToPositiveValue(lonRats[2].getNumerator(), lonRats[2].getDenominator());
                                        data.setLongitude(new double[] {lonRats[0].doubleValue(),
-                                               lonRats[1].doubleValue(), lonRats[2].doubleValue()});
+                                               lonRats[1].doubleValue(), seconds});
                                }
 
                                // Altitude (if present)
@@ -66,7 +68,9 @@ public class ExternalExifLibrary implements ExifLibrary
                                        data.setGpsTimestamp(new int[] {times[0].intValue(), times[1].intValue(),
                                                times[2].intValue()});
                                        Rational[] dates = gpsdir.getRationalArray(TAG_GPS_DATESTAMP);
-                                       data.setGpsDatestamp(new int[] {dates[0].intValue(), dates[1].intValue(), dates[2].intValue()});
+                                       if (dates != null) {
+                                               data.setGpsDatestamp(new int[] {dates[0].intValue(), dates[1].intValue(), dates[2].intValue()});
+                                       }
                                }
                        }
 
@@ -75,10 +79,14 @@ public class ExternalExifLibrary implements ExifLibrary
                        {
                                Directory exifdir = metadata.getDirectory(ExifDirectory.class);
 
-                               // Take time and date from exif tags if haven't got it already from GPS
-                               if (data.getGpsDatestamp() == null && exifdir.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)) {
+                               // Take time and date from exif tags
+                               if (exifdir.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)) {
                                        data.setOriginalTimestamp(exifdir.getString(ExifDirectory.TAG_DATETIME_ORIGINAL));
                                }
+                               // Also take "digitized" timestamp
+                               if (exifdir.containsTag(ExifDirectory.TAG_DATETIME_DIGITIZED)) {
+                                       data.setDigitizedTimestamp(exifdir.getString(ExifDirectory.TAG_DATETIME_DIGITIZED));
+                               }
 
                                // Photo rotation code
                                if (exifdir.containsTag(ExifDirectory.TAG_ORIENTATION)) {
@@ -104,6 +112,7 @@ public class ExternalExifLibrary implements ExifLibrary
                return data;
        }
 
+
        /**
         * Check whether the exifreader class can be correctly resolved
         * @return true if it looks ok