gpsbabel icon indicating copy to clipboard operation
gpsbabel copied to clipboard

When converting to fit format, a name should be generated if there's none in the original format

Open ari-s opened this issue 2 years ago • 3 comments

It looks like fit files have a name inside them. At least some devices delete fit-files if that is not set.

Therefore, in the case the original file does not have a corresponding value I suggest to generate one, e.g. from the filename (maybe discarding the extension)

gpx files can have a name tag directly below the gpx root.
When I convert such a file to fit and put it on my garmin watch, the watch deletes the file. This should be avoided, hence the suggested workaround.

ari-s avatar May 01 '22 12:05 ari-s

Our writers have no idea where any given data element comes from as it may have been filtered, merged, interpolated, etc. So the GPX idea falls a bit flat, but we may be able to work with the name of the fit file we're writing - the file writer definitely knows that.

However, we have about a bazillion "name" things in our formats and code. By inspection (I don't think any of my 100+ GPSes do .fit) the only thing that catches my eye as possibly funny is that here: [garmin_fit](https://github.com/GPSBabel/gpsbabel/blob/29b154f81bad73cf9dd8da07b4f92fdb3ebd361e/garmin_fit.cc

We use the name of the first route we see (which, in GPX parlance would be a ) and that name may or may not exist, but we pass it to https://github.com/GPSBabel/gpsbabel/blob/29b154f81bad73cf9dd8da07b4f92fdb3ebd361e/garmin_fit.cc#L1080 which makes it down to https://github.com/GPSBabel/gpsbabel/blob/29b154f81bad73cf9dd8da07b4f92fdb3ebd361e/garmin_fit.cc#L920 ...which looks like it would just write a 0 terminator and then the number of bytes written (1: the terminator) which looks like some kind of FIT thing.

Maybe it would be better to not write an empty string? Maybe we need some kind of rte->rte_name.isEmpty() ? "default" : rte->rte_name to just write SOMETHING there. If that basically fixes it, we can figure out how we can clean the output name (which might be usb:: or \share\some\long\name or file:\\c:\some\name or have unsavory punctuation or something, but let's figure out if just writing something is better than writing nothing. Or, if testing that we have nothing and not wrting that at all is better.

Since you have the test case and the affected hardware, it'll probably be up to you to do the experimentation.

robertlipe avatar Dec 08 '22 06:12 robertlipe

Writers can see session information. In the common use case of one input file I think we should be able to recover the input file name.

tsteven4 avatar Dec 08 '22 16:12 tsteven4

It isn't clear to that the name in the course message is what the OP needs on his watch.

tsteven4 avatar Dec 08 '22 16:12 tsteven4