gpsbabel icon indicating copy to clipboard operation
gpsbabel copied to clipboard

Garmin Extensions may not be correctly written in GPX

Open GPSBabelDeveloper opened this issue 4 years ago • 1 comments

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 for all'. 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'. gpxx:CityWinter Harbor</gpxx:City> gpxx:CityGouldsboro Twn</gpxx:City> gpxx:CityWinter Harbor Twn</gpxx:City>

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.

GPSBabelDeveloper avatar Aug 10 '20 02:08 GPSBabelDeveloper

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

tsteven4 avatar Aug 10 '20 22:08 tsteven4