Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error when importing GPX 1.1 file from Opentracks #260

Closed
MartinH80 opened this issue Aug 30, 2023 · 10 comments
Closed

Parse error when importing GPX 1.1 file from Opentracks #260

MartinH80 opened this issue Aug 30, 2023 · 10 comments
Assignees

Comments

@MartinH80
Copy link

I am using Opentracks to record my running sessions.

Opentracks allows export to GPX, which I try to import in Sportstracker for analysis on my desktop.

The import fails. The console says:

2023-08-30 22:02:42 SEVERE de.saring.exerciseviewer.gui.EVMain showExercise Failed to open exercise file /home/martin/Downloads/OpenTracks-Backup.gpx! 
de.saring.exerciseviewer.core.EVException: Failed to read the TopoGrafix GPX exercise file '/home/martin/Downloads/OpenTracks-Backup.gpx'!

And later on:

Caused by: java.time.format.DateTimeParseException: Text '2023-04-09T10:44:08.037+02:00' could not be parsed, unparsed text found at index 23

This can be found at line 34 of the GPX file. The following snippet starts with the first line and ends at line 34:

<?xml version="1.0" encoding="UTF-8"?>
<gpx
version="1.1"
creator="OpenTracks"
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:topografix="http://www.topografix.com/GPX/Private/TopoGrafix/0/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:opentracks="http://opentracksapp.com/xmlschemas/v1"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2"
xmlns:gpxtrkx="http://www.garmin.com/xmlschemas/TrackStatsExtension/v1"
xmlns:cluetrust="http://www.cluetrust.com/Schemas/"
xmlns:pwr="http://www.garmin.com/xmlschemas/PowerExtension/v1"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.topografix.com/GPX/Private/TopoGrafix/0/1 http://www.topografix.com/GPX/Private/TopoGrafix/0/1/topografix.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v2 https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd http://www.garmin.com/xmlschemas/PowerExtension/v1 https://www8.garmin.com/xmlschemas/PowerExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackStatsExtension/v1 http://www.cluetrust.com/Schemas http://www.cluetrust.com/Schemas/gpxdata10.xsd http://opentracksapp.com/xmlschemas/v1 http://opentracksapp.com/xmlschemas/OpenTracks_v1.xsd">
<trk>
<name><![CDATA[2023-04-09T10:44+02]]></name>
<desc><![CDATA[]]></desc>
<type><![CDATA[hardlopen]]></type>
<extensions>
<topografix:color>c0c0c0</topografix:color>
<opentracks:trackid>5ec98da5-697e-4179-9119-c874cda8ac09</opentracks:trackid>
<gpxtrkx:TrackStatsExtension>
<gpxtrkx:Distance>2370.517578125</gpxtrkx:Distance>
<gpxtrkx:TimerTime>1118</gpxtrkx:TimerTime>
<gpxtrkx:MovingTime>1083</gpxtrkx:MovingTime>
<gpxtrkx:StoppedTime>35</gpxtrkx:StoppedTime>
<gpxtrkx:MaxSpeed>2.830949306488037</gpxtrkx:MaxSpeed>
<gpxtrkx:Ascent>51.0</gpxtrkx:Ascent>
<gpxtrkx:Descent>51.0</gpxtrkx:Descent>
</gpxtrkx:TrackStatsExtension>
</extensions>
<trkseg>
<trkpt lat="52.####" lon="5.####">
<ele>47.3</ele>
<time>2023-04-09T10:44:08.037+02:00</time>

Index 23 is the semicolon after 44.

I have compiled sportstracker 7.9.1 manually on my Suse Tumbleweed desktop using OpenJDK-17.

@ssaring
Copy link
Owner

ssaring commented Aug 30, 2023

Hi Martin, could you please attach an example file for reproducing the problem and testing the fix?

@dennisguse
Copy link

dennisguse commented Aug 30, 2023

I presume: https://www.saring.de/sportstracker/index.html#
The gpx spec doesn't specify if timestamps may contain a time offset or not (KML does).
In OpenTracks, the time offset is stored, used and thus exported.

Just open an issue with sporttracker
The fix is in their data parsing code.
You may take a look at StringUtils.parseTime() in OpenTracks and how it is done there.

More infos here: OpenTracksApp/OpenTracks#249

@MartinH80
Copy link
Author

Hi Martin, could you please attach an example file for reproducing the problem and testing the fix?

I have just created a new export and send it to you by e-mail. I prefer not everyone to be able to see where I exactly live :-)

@dennisguse
Copy link

Actually the correct issue for OpenTracks is: OpenTracksApp/OpenTracks#301

@ssaring
Copy link
Owner

ssaring commented Aug 31, 2023

I have just created a new export and send it to you by e-mail. I prefer not everyone to be able to see where I exactly live :-

Thanks for sharing, will take a look on that in the next days.

ssaring added a commit that referenced this issue Sep 1, 2023
- added support for timestamps with timezone / offset info
@ssaring ssaring added the bug label Sep 1, 2023
@ssaring ssaring self-assigned this Sep 1, 2023
@ssaring
Copy link
Owner

ssaring commented Sep 1, 2023

Just fixed that by adding timezone / offset support in the GPX file importer. Bugfix is available on the main branch.

Please be aware that the unreleased (but for my usage very stable) 8.0.0 release now stores its date in a SQLite database instead of XML files. Data migration will be done during initial start.

@ssaring ssaring closed this as completed Sep 1, 2023
@MartinH80
Copy link
Author

@ssaring and @dennisguse Thanks for the quick action! Unfortunately it doesn't work for me at the moment using the current master branch.

Opentracks allows export in several formats, plus it allows to export all tracks in 1 file, or 1 file per recorded track.

KMZ seems not supported by Sportstracker, which is not a must have, but would be nice.

When I try to open a GPX file that has all recorded tracks, it looks like it recognizes it as 1 track.

When I try to open a GPX file from my latest recorded track only, it does show correct date and duration. Unfortunately when I click 'close', I expect the exercise to be added to the database, but no exercise is added at all. What i noticed is that when I open the file the Sport Type is n.a.. In Opentracks it is called 'hardlopen' (Dutch for running) and I have up front added that to the list of sport types.

The gpx export does contain the sport type:

<type><![CDATA[hardlopen]]></type>

Console only says:

2023-09-03 21:48:08 INFO de.saring.sportstracker.gui.STControllerImpl onOpenHrmFile Opening HRM file '/home/martin/Downloads/2023-09-03_10_10_02.384_2023-09-03T10_10+02.gpx' in ExerciseViewer...

@dennisguse
Copy link

@MartinH80 the sport type is localized in OpenTracks and it also exported this way. However, exporting the localized version is not how it should be done as it makes it really complicated for applications to exchange data. So, this will be changed in OpenTracks in the future, so OpenTracks exports the sport type in English. See OpenTracksApp/OpenTracks#1608

@ssaring
Copy link
Owner

ssaring commented Sep 4, 2023

Opentracks allows export in several formats, plus it allows to export all tracks in 1 file, or 1 file per recorded track.
KMZ seems not supported by Sportstracker, which is not a must have, but would be nice.
When I try to open a GPX file that has all recorded tracks, it looks like it recognizes it as 1 track.

SportsTracker does support only the import of files with one single activity. Multiple files does not make sense in ST as an file is directly attached to one single activity entry.
KMZ is not supported as this is not the native format of any known and relevant sports tracking hardware device.

When I try to open a GPX file from my latest recorded track only, it does show correct date and duration. Unfortunately when I click 'close', I expect the exercise to be added to the database, but no exercise is added at all. What i noticed is that when I open the file the Sport Type is n.a.. In Opentracks it is called 'hardlopen' (Dutch for running) and I have up front added that to the list of sport types.

Opening a file is not importing, Open means simply show the content of the file in the ExerciseViewer window. For importing you need to drag and drop one activity file (GPX or FIT or any other supported format) from your OS file explorer to the Calender View of SportsTracker. You can either attach the file to an existing entry by dropping the file to it or you can import and add a new entry by dropping the file somewhere else on the calendar days.

When importing new activities, a dialog will appear where the user needs to select the selected sport type or subtype. The sport types are not matched by name, this would be way to error prone. There's no standard definition of sport type names, in SportsTracker the user will create his own sport type list for his/her preferences.

Users of Garmin (and some other) watches can be happy, the FIT standard and file format contains sport type and subtype information which can be mapped in SportsTracker to the sport types of the user. Then the sport type and subtype will be automatically in the import dialog.

BTW, that's all described in the docs/README.txt.

@MartinH80
Copy link
Author

@ssaring and @dennisguse thanks again!

@ssaring Your last comment hurts my ego a bit, happy to see that it is all explained in there :-)

The import of a single gpx recorded track now works! Even with the localized sports type as this can be entered when importing the track.

ssaring added a commit that referenced this issue Sep 23, 2023
- added support for timestamps with timezone / offset info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants