GPSBabel / gpsbabel

GPSBabel: convert, manipulate, and transfer data from GPS programs or GPS receivers. Open Source and supported on MacOS, Windows, Linux, and more. Pointy clicky GUI or a command line version...
https://www.gpsbabel.org
GNU General Public License v2.0
477 stars 127 forks source link

latitude wrapping is incorrect #1329

Closed tsteven4 closed 2 months ago

tsteven4 commented 2 months ago

Our latitude wrapping is independent of longitude, and doesn't make much sense. these values in the southern hemisphere get mapped to the northern hemisphere -120 -> +60 -150 -> +30 and these in the northern hemisphere get mapped to the southern hemisphere. 120 -> -60 150 -> -30

Wouldn't it make more sense to map the latitudes as follows, and adjust the longitude by 180 degrees? (-120, 40 -> (-60, -140) (-150, -40) -> (-30, 140) (120, 60) -> (60, -120) (150, -60) -> (30, 120)

https://github.com/GPSBabel/gpsbabel/blob/5a08554b7b57802ed6f7870df6bb0ddc43c97e8f/waypt.cc#L564-L579

Perhaps something along the lines of https://gist.github.com/missinglink/d0a085188a8eab2ca66db385bb7c023a is better.

robertlipe commented 2 months ago

Now that you mention it, that's clearly dumb.

Wrapping longs makes a little bit of sense. Traveling from London to Chelmsford, you probably don't think much about a hemisphere wrap, though there's probably a big dumb sign. Does Wrapping lats around the axial poles ever make sense?

If we just whack that, we still pass regression test, even with the asserts below that.

diff --git a/waypt.cc b/waypt.cc index df02d171..ab73706b 100644 --- a/waypt.cc +++ b/waypt.cc @@ -590,7 +590,7 @@ WaypointList::waypt_add(Waypoint* wpt) double lat_orig = wpt->latitude; double lon_orig = wpt->longitude; append(wpt);

+#if 0 if (wpt->latitude < -90) { wpt->latitude += 180; } else if (wpt->latitude > +90) { @@ -601,6 +601,7 @@ WaypointList::waypt_add(Waypoint* wpt) } else if (wpt->longitude > +180) { wpt->longitude -= 360; } +#endif

if ((wpt->latitude < -90) || (wpt->latitude > 90.0)) fatal(FatalMsg() << wpt->session->name

Permission to kill pre-approved.

RJL

On Thu, Aug 22, 2024 at 5:16 PM tsteven4 @.***> wrote:

Our latitude wrapping is independent of longitude, and doesn't make much sense. these values in the southern hemisphere get mapped to the northern hemisphere -120 -> +60 -150 -> +30 and these in the northern hemisphere get mapped to the southern hemisphere. 120 -> -60 150 -> -30

Wouldn't it make more sense to map the latitudes as follows, and adjust the longitude by 180 degrees? (-120, 40 -> (-60, -140) (-150, -40) -> (-30, 140) (120, 60) -> (60, -120) (150, -60) -> (30, 120)

https://github.com/GPSBabel/gpsbabel/blob/5a08554b7b57802ed6f7870df6bb0ddc43c97e8f/waypt.cc#L564-L579

Perhaps something along the lines of https://gist.github.com/missinglink/d0a085188a8eab2ca66db385bb7c023a is better.

— Reply to this email directly, view it on GitHub https://github.com/GPSBabel/gpsbabel/issues/1329, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCSD327G3VFH3G27B73ETLZSZPKJAVCNFSM6AAAAABM7AUBJSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ4DCOJQGM3DGNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>