Created
September 6, 2013 19:57
-
-
Save tonyc/6469102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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