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
471 stars 125 forks source link

Garmin Extensions may not be correctly written in GPX #623

Open GPSBabelDeveloper opened 4 years ago

GPSBabelDeveloper commented 4 years ago

Given a file that clearly contains Garmin Format Specific stuff, we can see it written by unicsv: ./gpsbabel -i gdb -f reference/gdb-sample-v3-autoroute.gdb -o unicsv -F - No,Latitude,Longitude,Name,Altitude,Description,Notes,Symbol,Date,Time,Address,City,PostalCode,State,Country,Phone [ ... ] 39,44.390710,-68.045377,"1 Birch Harbor Rd",,"1 Birch Harbor Rd,Winter Harbor, ME, 04693, USA","1 Birch Harbor Rd,Winter Harbor, ME, 04693, USA","Flag, Blue",2020/06/08,13:39:00,"1 Birch Harbor Rd","Winter Harbor","04693","ME","USA",

If we write this file back to GPX, turning on garminextensions (which does set gpxver = 1.1) we might expect to find a City written by garmin_fs_xml_fprint(). We don't: $ ./gpsbabel -i gdb -f reference/gdb-sample-v3-autoroute.gdb -o gpx,garminextensions -F - | grep gpxx:City $

If we chase this into gpx_waypt_pr(), we see the lone call to garmin_fs_xml_fprint is inside a block that's blocked by: if (!(opt_humminbirdext || opt_garminext)) {

This evaluates true only if both options are false. This means we ONLY go grub around inside gmsd if we have neither flag. Since garminextensions set gpx_1_1, this means we only hit garmin_fs_xml_fprint if we explicitly set gpxver and to NOT set garminextensions

gpsbabel % make && ./gpsbabel -i gdb -f reference/gdb-sample-v3-autoroute.gdb -o gpx,garminextensions,gpxver=1.1 -F - | grep gpxx:City make: Nothing to be done for all'. gpsbabel % make && ./gpsbabel -i gdb -f reference/gdb-sample-v3-autoroute.gdb -o gpx,garminextensions=1,gpxver=1.1 -F - | grep gpxx:City make: Nothing to be done forall'. gpsbabel % make && ./gpsbabel -i gdb -f reference/gdb-sample-v3-autoroute.gdb -o gpx,garminextensions=0,gpxver=1.1 -F - | grep gpxx:City make: Nothing to be done for `all'.

Winter Harbor Gouldsboro Twn Winter Harbor Twn That's pretty counterintuitive. Do we have that outer test backward? Of course, "fixing" this has fallout in our test suite, but I *think* the fallout is good and should be accepted. I think. We have this same mind-bending logic in a the track and route cases, too. Our test here has gotten out of hand. If we have either extensions option set, we have gpx 1.1 set, so some of this can just go away.
tsteven4 commented 4 years ago

This came about in https://github.com/gpsbabel/gpsbabel/commit/1de556602. I think this started here https://sourceforge.net/p/gpsbabel/mailman/gpsbabel-misc/thread/512B750E.3030009%40ehu.es/#msg30528640 and spread to here https://sourceforge.net/p/gpsbabel/mailman/gpsbabel-code/thread/DED0F2D3-DF69-47F5-8493-446A132423AD%40tacorp.net/#msg30559628