Closed maximilianloy closed 6 years ago
(I'm just another random dev) I had the same issue - they're in degrees/minutes/seconds with optional multipliers. From a bit of research it's this that seems to be in the actual EXIF spec, though.
Here's some code I wrote to make sense of them...
function EXIFtoLocation(stringDMS){
function EXIFdivide(dStr) {
num = dStr.split('/');
return num[0] / num[1];
}
var DMS = stringDMS.split(",");
return EXIFdivide(DMS[0]) + (EXIFdivide(DMS[1])/60) + (EXIFdivide(DMS[2])/3600);
};
if (metadata.GPS != null) { // iOS
// iPhone uses different fields
var lat = metadata.GPS.Latitude;
var lon = metadata.GPS.Longitude;
var latref = metadata.GPS.LatitudeRef;
var lonref = metadata.GPS.LongitudeRef;
} else { // Android
var lat = EXIFtoLocation(metadata.gpsLatitude);
var lon = EXIFtoLocation(metadata.gpsLongitude);
var latref = metadata.gpsLatitudeRef;
var lonref = metadata.gpsLongitudeRef;
}
if (latref == "S")
lat = -lat;
if (lonref == "W")
lon = -lon;
Agree though, it would be handy if some of this were in the plugin.
I created PR #11 which fixes this on Android. There is actually already a function provided by the Android EXIF API to convert lat/lng and altitude. But good to know that I need to switch the sign on iOS too. I am testing in N/E so didn't notice this :-)
I've submitted a PR to your fork (hopefully that was the right way to do it!).
thanks man you're another dev who saved my life
@pugwonk MVP
Hi, the GPS data returned on Android is pretty weird. Is this normal?
{ aperture: "1.29" datetime: "2016:11:08 20:36:49" exposureTime: "0.083333335" flash: "65" focalLength: "3097/1000" gpsAltitude: "84000/100" gpsAltitudeRef: "0" gpsDateStamp: "2016:11:08" gpsLatitude: "45/1,30/1,4608/100" gpsLatitudeRef: "N" gpsLongitude: "10/1,18/1,1928/100" gpsLongitudeRef: "E" gpsProcessingMethod: null gpsTimestamp: "19:36:46" iso: "2773" make: "htc" model: "Nexus 9" orientation: "1" whiteBalance: "0" }
Tested it on Nexus 5 (Android 6.0.1) and Nexus 9 (Android 7.0)