Check if img coords existsd

This commit is contained in:
misaochan 2016-02-03 15:54:30 +13:00
parent f8b6575ef4
commit ab41cd67a8

View file

@ -15,6 +15,7 @@ public class GPSExtractor {
private double decLatitude, decLongitude; private double decLatitude, decLongitude;
Context context; Context context;
private static final String TAG = GPSExtractor.class.getName(); private static final String TAG = GPSExtractor.class.getName();
public boolean imageCoordsExists;
public GPSExtractor(String filePath, Context context){ public GPSExtractor(String filePath, Context context){
this.filePath = filePath; this.filePath = filePath;
@ -39,6 +40,7 @@ public class GPSExtractor {
} }
if (exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) == null) { if (exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) == null) {
imageCoordsExists = false;
Log.d(TAG, "Picture has no GPS info"); Log.d(TAG, "Picture has no GPS info");
LocationManager locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); LocationManager locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
@ -51,6 +53,7 @@ public class GPSExtractor {
return currentCoords; return currentCoords;
} }
else { else {
imageCoordsExists = true;
latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE); latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
latitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF); latitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);
longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE); longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);