Skip to content

Instantly share code, notes, and snippets.

@tonyc
Created September 6, 2013 19:57
Show Gist options
  • Save tonyc/6469102 to your computer and use it in GitHub Desktop.
Save tonyc/6469102 to your computer and use it in GitHub Desktop.
var EXIFGPSParser = function(exifData) {
this.exif = exifData;
this.getDecimalLatitude = function() {
return this._DMStoDecimal(this.exif.GPSLatitude, this.exif.GPSLatitudeRef, 'S');
};
this.getDecimalLongitude = function() {
return this._DMStoDecimal(this.exif.GPSLongitude, this.exif.GPSLongitudeRef, 'W');
};
this._DMStoDecimal = function(coords, coordRef, negativeCoordRef) {
if (!coords) {
return null;
}
var deg = coords[0];
var mins = coords[1];
var sec = coords[2];
var decimalSeconds = sec / 60.0
var decimalMins = (mins / 60.0) + decimalSeconds;
var decimalDegrees = deg + decimalMins;
if (coordRef === negativeCoordRef) {
decimalDegrees = -decimalDegrees;
}
return decimalDegrees;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment