MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / parseLongitude

Function parseLongitude

app/rcc/scripts/parser/js/nmea_0183.js:118–130  ·  view source on GitHub ↗

* Parses NMEA longitude format to decimal degrees. * Format: DDDMM.MMMM (degrees and minutes) * Example: "01131.000" with "E" -> 11.5167 degrees

(lonStr, hemisphere)

Source from the content-addressed store, hash-verified

116 * Example: "01131.000" with "E" -> 11.5167 degrees
117 */
118function parseLongitude(lonStr, hemisphere) {
119 if (!lonStr || lonStr.length < 5)
120 return 0;
121
122 var degrees = parseFloat(lonStr.substring(0, 3));
123 var minutes = parseFloat(lonStr.substring(3));
124 var decimal = degrees + (minutes / 60);
125
126 if (hemisphere === 'W')
127 decimal = -decimal;
128
129 return decimal;
130}
131
132/**
133 * Validates NMEA checksum.

Callers 1

nmea_0183.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected