mikalhart / TinyGPSPlus

A new, customizable Arduino NMEA parsing library
http://arduiniana.org
1.11k stars 494 forks source link

Longitude values within 1 degree E of meridian are returned as negative (W) #3

Closed dbrooke closed 10 years ago

dbrooke commented 11 years ago

A position just E of the meridian, having iLngDegrees of 0, causes the test in TinyGPSLocation::lng() to subtract the billionths which results in the reported position being shown as negative (W).

The indication of W or E in TinyGPSPlus::endOfTermHandler() , which negates the degree value in the case of W, has no effect when the value is 0 since -0 is the same.

This issue will presumably also affect latitude values within 1 degree of the equator.

mikalhart commented 11 years ago

Good catch and very clear explanation! Working on a solution... Thanks!

dbrooke commented 11 years ago

I just pushed a commit which uses a signed billionths value.

https://github.com/dbrooke/TinyGPSPlus/commit/1a958a07c2f5b65e870a1e9bf64713f633395342

I guess that that will slightly reduce precision.

Also I returned absolute value for raw billionths to avoid changing the public return type but that still leaves an ambiguity of sign for raw values where degrees is zero so maybe it should return signed.

Feel free to use or ignore as you see fit.

dbrooke commented 10 years ago

Thanks for the fix.