jovandeginste / workout-tracker

A workout tracking web application for personal use (or family, friends), geared towards running and other GPX-based activities
Other
945 stars 31 forks source link

Bug: Graphing error on GPX imported via FitoTrack API #141

Closed tjhowse closed 4 months ago

tjhowse commented 4 months ago

Workout-tracker version: [branch master (5ccfa422)]

I set up the Fitotrack (app version 15.4) API to export tracks direct into workout-tracker. It worked great, except there are some oddities in the data after importing.

image

The splits don't match what is displayed in Fitotrack:

unnamed

...though the overall distance and time are mostly correct. The graph in workout-tracker is very wonky too, with strange overlapping artefacts for the elevation and average speed. It looks like the data points are being plotted out of order. Two points close together on the X axis are 8 minutes apart in time:

image

The track as downloaded from workout-tracker: track.zip.

I deleted the workout in workout tracker and re-imported the exported track. That was corrupt in the same way. I deleted the workout, then I exported the GPX from fitotrack and imported it into workout-tracker via the web interface. It imported perfectly, with proper splits and graphing:

image

Here's that track: fitotrack_export.zip

tjhowse commented 4 months ago

I can confirm that the GPX exported from workout-tracker contains out of order and duplicated timestamps:

      <trkpt lat="-27.478870846315242" lon="153.09097753756518">
        <ele>52.99221391974757</ele>
        <extensions>
          <speed>3.0840303897857666</speed>
          <wstxns13:TrackPointExtension xmlns:wstxns13="gpxtxp">
            <wstxns14:hr xmlns:wstxns14="gpxtx">87</wstxns14:hr>
          </wstxns13:TrackPointExtension>
        </extensions>
        <time>**2024-05-03T07:28:25Z**</time>
      </trkpt>
      <trkpt lat="-27.4788348375107" lon="153.0910358920251">
        <ele>52.52964198964825</ele>
        <extensions>
          <speed>3.131044626235962</speed>
          <wstxns15:TrackPointExtension xmlns:wstxns15="gpxtxp">
            <wstxns16:hr xmlns:wstxns16="gpxtx">84</wstxns16:hr>
          </wstxns15:TrackPointExtension>
        </extensions>
        <time>2024-05-03T07:28:27Z</time>
      </trkpt>
      <trkpt lat="-27.478803091643066" lon="153.091087401403">
        <ele>52.570785951963394</ele>
        <extensions>
          <speed>3.050023078918457</speed>
          <wstxns17:TrackPointExtension xmlns:wstxns17="gpxtxp">
            <wstxns18:hr xmlns:wstxns18="gpxtx">85</wstxns18:hr>
          </wstxns17:TrackPointExtension>
        </extensions>
        <time>2024-05-03T07:28:19Z</time>
      </trkpt>
      <trkpt lat="-27.47875149685273" lon="153.09112116776717">
        <ele>52.48585553204152</ele>
        <extensions>
          <speed>3.072394371032715</speed>
          <wstxns19:TrackPointExtension xmlns:wstxns19="gpxtxp">
            <wstxns20:hr xmlns:wstxns20="gpxtx">89</wstxns20:hr>
          </wstxns19:TrackPointExtension>
        </extensions>
        <time>**2024-05-03T07:28:25Z**</time>
      </trkpt>

The trackpoints are in the correct sequence, but it looks like the timestamps can get duplicated.

I will run a test where I POST a GPX to the workout-tracker fitotrack API endpoint and check whether it gets garbled during ingestion, or whether fitotrack is pushing corrupted data.

tjhowse commented 4 months ago

Good news! I POSTed the known-good GPX to the fitotrack endpoint:

curl -X POST -H "FitoTrack-Type: workout-gpx" -H "FitoTrack-Workout-Type: running" -H "FitoTrack-Comment: none" -d @workout-2024-05-03_17-28.gpx https://<snip>/api/v1/import/fitotrack?api-key=<snip>

and it's showing up uncorrupted. It looks like the problem is on the fitotrack side. There must be some preprocessing going awry before the GPX is sent to the web endpoint. I'l raise a ticket over there: https://codeberg.org/jannis/FitoTrack/issues/533