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

garmin_fit does not support course_point types well #1182

Open googol42 opened 12 months ago

googol42 commented 12 months ago

Hello,

I am using gpsbabel to convert gpx files to fit. After some debugging I have found out that gpsbabel does not take the icon types into account when converting the gpx to fit.

I tried the following combinations in my gpx file:

I then converted those 6 files to fit using gpsbabel -i gpx -f file_x.gpx -o garmin_fit -F file_x.fit

I then converted the fit files to csv using the FitCSVTool from the Fit/Garmin SDK (https://developer.garmin.com/fit/download/):

java -jar Downloads/FitSDKRelease_21.115.00/java/FitCSVTool.jar -b file_x.fit file_x.csv

Then I was sure that it must be an error in gpsbabel. I search your repository and found this line: https://github.com/GPSBabel/gpsbabel/blob/dfc770ac0a68a0827f89ddf8ef09c5766f16a53c/jeeps/gpscom.cc#L1282C5-L1282C34 I am not sure if this code is really used when converting....

I did not find any upstream repository for "jeeps" so I am reporting this here.

I would expect that when I convert a gpx file with a waypoint with <type>WATER</type> (or maybe <type>water</type>) to be converted to a course_point with type = 3

googol42 commented 12 months ago

Also the list of types is not complete (I know it is only a comment): https://github.com/GPSBabel/gpsbabel/blob/dfc770ac0a68a0827f89ddf8ef09c5766f16a53c/jeeps/gps.h#L224

A full list of types can be found in the mentioned SDK. Open FitSDKRelease_21.115.00/py/garmin_fit_sdk/profile.py and search for 'course_point': which gives you a list of 54 types.

googol42 commented 12 months ago

I figured out that the code is not called and found this: https://github.com/GPSBabel/gpsbabel/blob/dfc770ac0a68a0827f89ddf8ef09c5766f16a53c/garmin_fit.cc#L1277

Unfortunately the intermediate "format" Waypoint does not support something like a type or symbol. The code above attempts (to some extend) to extract the type from the (short)name.

Could that be enhanced? For example: gpx waypoint has the name "water spring" or "WATER spring" the course_point is assigned type 3 and the name "spring". Or do you see any other way to around that limitation?

tsteven4 commented 11 months ago

Unfortunately the intermediate "format" Waypoint does not support something like a type or symbol.

Actually, the gpx reader records the value of the sym element as the field icon_descr in the Waypoint class.

GPSBabelDeveloper commented 11 months ago

What he said.

We have dozens of examples (some good, some bad) of code turning numeric values into textual strings inside icon_descr and then doing the inverse for the opposite in read/write. Supporting round-trip to GPX/CSV is table stakes. You get bonus (imaginary internet) points for applying the Postel Principle. If you can take take either "red flag" and "flag, red" on read and convert those to 1,475 internally (or whatever) and then write the "best" on output, everyone wins.

hummin_bird_icons is a reasonable example. osm_icon_mapping is a featureful example as they have complicated problems garmin_icon_tables contains hundreds of icon # mappings as used in their receiver and mapping products. It's complicated because "Airport" is 107 in Mapsource and 16384 in PCX, for example.

It looks like the code you've pointed to kind of tries to do this, but only for five languages worth of "left" and 'right". That is, well, interesting.

Our older formats tend to use brute force traditional linear table lookups. Newer code tends to use more C++ indigenous structures like maps and hashes

If you have knowledge of a number<->string mapping for icons, there are plenty of examples for you to add here. Looks like you found the place on read and probably let fit_parse_data look in lappt (?) f.course_data_type or whatever to look up the textual valu of that number. We can work with you to get it integrated if you can work out the tymbol table and get it basically working from your device/.

On Mon, Oct 9, 2023 at 4:11 PM tsteven4 @.***> wrote:

Unfortunately the intermediate "format" Waypoint does not support something like a type or symbol.

Actually, the gpx reader records the value of the sym element as the field icon_descr in the Waypoint class.

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