Skip to content

Instantly share code, notes, and snippets.

@djom202
Last active April 20, 2018 03:08
Show Gist options
  • Save djom202/e1b19f1cb7eed561ae5c67f66cc70825 to your computer and use it in GitHub Desktop.
Save djom202/e1b19f1cb7eed561ae5c67f66cc70825 to your computer and use it in GitHub Desktop.
Converter from NMEA to Decimals (GPS)
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