summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2011-04-29 10:20:34 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-04-29 10:20:34 -0700
commit7bcb2f39154e7d4271486674c5a6db5756de6c29 (patch)
tree79bcf9f84c09583f0be6d533f9d0b7a8586e497f
parenta50913aaf7da085e6f6438a14fc9d12c86fab9f5 (diff)
parentc5505f6a150db8232cc275bedd400f7f5a593530 (diff)
downloadframeworks_base-7bcb2f39154e7d4271486674c5a6db5756de6c29.zip
frameworks_base-7bcb2f39154e7d4271486674c5a6db5756de6c29.tar.gz
frameworks_base-7bcb2f39154e7d4271486674c5a6db5756de6c29.tar.bz2
am c5505f6a: Merge "Improved conversion accuracy of exif geotag data"
* commit 'c5505f6a150db8232cc275bedd400f7f5a593530': Improved conversion accuracy of exif geotag data
-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 74488c5..a08f388 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -293,12 +293,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;
}
/**
@@ -367,12 +371,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())
@@ -383,10 +387,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();
}
}