ttlappalainen / NMEA0183

Library for handling NMEA0183 messages
69 stars 44 forks source link

Leading zeros in RMC (Longitude, Lattitude) missing #11

Closed AK-Homberger closed 4 years ago

AK-Homberger commented 4 years ago

Hi Timo,

While using this Library ,I identified a compatibility problem with a loogbook app. It looks like the Longitude, Latttude information is not formatted according to the NMEA specification, which requires leading zeros. Most apps will ignore the missing leading zeros, but not all.

Changing the formatting in NMEA0183Msg.h worked for me (%08.3f and %09.3f).

Regards, Andreas

// Add Latitude field. Also E/W will be added. Latitude is in degrees. Negative value is W. E.g. // AddLatitudeField(-5.2345); -> ,5.235,W bool AddLatitudeField(double Latitude, const char *Format="%08.3f");

// Add Longitude field. Also N/S will be added. Longitude is in degrees. Negative value is S. E.g.
// AddLongitudeField(-5.2345); -> ,514.070,S
bool AddLongitudeField(double Longitude, const char *Format="%09.3f");
ttlappalainen commented 4 years ago

Sorry for delay. I have nod had time to check this.

Do you know how many decimals are allowed on the lat/lon? With current GPS accuracy we should have at least 4 and up to 6. But are some apps limited to 3? I think I set it to 3, since some app could not read more. So there should be possibility to set format.

AK-Homberger commented 4 years ago

Hi Timo,

My problem was just the missing leading zeros. The formatting with "%08.3f" for Latitude and "%09.3f" for Longitude is fixing the leading zeros problem. Not sure about the maximum decimals. According to the NMEA standard the decimal fraction is optinal. Version 301 defines maximum 2 decimals. Not sure if this has changed in later versions. But all apps I tsted so far, are working with three decimals.

Regards, Andreas