Skip to content

Instantly share code, notes, and snippets.

@adambarthelson
Created April 23, 2015 19:44
Show Gist options
  • Save adambarthelson/cb4bc4002f582560e19a to your computer and use it in GitHub Desktop.
Save adambarthelson/cb4bc4002f582560e19a to your computer and use it in GitHub Desktop.
Convert NMEA GPS data from decimal-decimal format to decimal-degree
function NMEA2GPS(num, pole){
var poles = {'N':1,'S':-1,'W':-1,'E':1};
var s = parseFloat(num).toString();
var deg = s.substring(0,2);
var min = s.substring(2);
return (parseInt(deg) + parseFloat(min)/60) * poles[pole];
}
// NMEA2GPS(07721.2060, 'W') => -77.35347
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment