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
473 stars 126 forks source link

use implicit conversions for lat,lon degs<->rads in grtcirc interface #1321

Closed tsteven4 closed 1 month ago

tsteven4 commented 1 month ago

@robertlipe I'm still noodling on this, but feel free to have a look. In addition to automatically converting positions in radians and degrees this also prevents passing lat,lon pairs in the wrong order. There may be lurking TODOs at this point, squawk if you find some.
One potential pitfall related to returning a PositionDeg/PositionRad is that if the caller uses auto then the return type is out of the callers control, and if they dig inside they will get degrees or radians depending on the function definition. OTOH if they assign the returned value to PositionDeg/PositionRad, then they will get that.

tsteven4 commented 1 month ago

How did we do?

usages of RAD: 0 usages of kRadiansPerDegree: 3 all in defs.h references to DEG: 1 in garmin.cc references to kDegreesPerRadian: 4 all in defs.h

tsteven4 commented 1 month ago

I think you've made it much harder (impossible?) to just call these with a couple of doubles where we don't know if they're degrees or radians and that's a great thing.

Its possible, but you have to work at it a bit: https://github.com/GPSBabel/gpsbabel/blob/b099cb4eb1060fbe6fd65fbed0d3ad56f55e2770/waypt.cc#L203-L208