summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wu-cheng Li <wuchengli@google.com> 2011-01-24 18:48:34 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2011-01-24 18:48:34 -0800
commitc8de291ee58665010f80cdedc1bccc57c1d675fb (patch)
treeba4633427b69281b574d00580e64eb110746e5aa
parent2ff6d70521fe1f537f8ebd631f0b9b3aa8becf94 (diff)
parenta113a075ca9afa14361806ea592c8f078b1636c5 (diff)
Merge "Improved conversion accuracy of exif geotag data" into honeycomb
-rw-r--r--media/java/android/media/ExifInterface.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index 11e27a90cc3e..925f965d6236 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -299,12 +299,16 @@ public class ExifInterface {
String lngRef = mAttributes.get(ExifInterface.TAG_GPS_LONGITUDE_REF);
if (latValue != null && latRef != null && lngValue != null && lngRef != null) {
- output[0] = convertRationalLatLonToFloat(latValue, latRef);
- output[1] = convertRationalLatLonToFloat(lngValue, lngRef);
- return true;
- } else {
- return false;
+ try {
+ output[0] = convertRationalLatLonToFloat(latValue, latRef);
+ output[1] = convertRationalLatLonToFloat(lngValue, lngRef);
+ return true;
+ } catch (IllegalArgumentException e) {
+ // if values are not parseable
+ }
}
+
+ return false;
}
/**
@@ -373,12 +377,12 @@ public class ExifInterface {
String [] pair;
pair = parts[0].split("/");
- int degrees = (int) (Float.parseFloat(pair[0].trim())
- / Float.parseFloat(pair[1].trim()));
+ double degrees = Double.parseDouble(pair[0].trim())
+ / Double.parseDouble(pair[1].trim());
pair = parts[1].split("/");
- int minutes = (int) ((Float.parseFloat(pair[0].trim())
- / Float.parseFloat(pair[1].trim())));
+ double minutes = Double.parseDouble(pair[0].trim())
+ / Double.parseDouble(pair[1].trim());
pair = parts[2].split("/");
double seconds = Double.parseDouble(pair[0].trim())
@@ -389,10 +393,12 @@ public class ExifInterface {
return (float) -result;
}
return (float) result;
- } catch (RuntimeException ex) {
- // if for whatever reason we can't parse the lat long then return
- // null
- return 0f;
+ } catch (NumberFormatException e) {
+ // Some of the nubmers are not valid
+ throw new IllegalArgumentException();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Some of the rational does not follow the correct format
+ throw new IllegalArgumentException();
}
}