gpxstudio.github.io icon indicating copy to clipboard operation
gpxstudio.github.io copied to clipboard

Exported gpx file adds new invalid heartrate data

Open CasperVerswijvelt opened this issue 2 years ago • 5 comments

I noticed that while editing some wonky gps data of my run, the heartrate data was not correct after uploading to strave.

I looked into the original and exported gpx files and saw that all points that did not have any heartrate data, were now filled in in with <gpxtpx:hr>null</gpxtpx:hr>

Some examples with locationdata redacted Exerpt from original gpx

      <trkpt lat="" lon="">
        <ele>14.168</ele>
        <time>2022-04-16T08:31:25Z</time>
      </trkpt>
      <trkpt lat="" lon="">
        <ele>14.247</ele>
        <time>2022-04-16T08:31:26Z</time>
        <extensions>
          <gpxtpx:TrackPointExtension>
            <gpxtpx:hr>149</gpxtpx:hr>
          </gpxtpx:TrackPointExtension>
        </extensions>
      </trkpt>
      <trkpt lat="" lon="">
        <ele>14.308</ele>
        <time>2022-04-16T08:31:27Z</time>
      </trkpt>

Exerpt from exported gpx (unedited)

    <trkpt lat="" lon="">
        <ele>14.2</ele>
        <time>2022-04-16T08:31:25.000Z</time>
        <extensions>
        <gpxtpx:TrackPointExtension>
        <gpxtpx:hr>null</gpxtpx:hr>
        </gpxtpx:TrackPointExtension>
        </extensions>
    </trkpt>
    <trkpt lat="" lon="">
        <ele>14.2</ele>
        <time>2022-04-16T08:31:26.000Z</time>
        <extensions>
        <gpxtpx:TrackPointExtension>
        <gpxtpx:hr>149</gpxtpx:hr>
        </gpxtpx:TrackPointExtension>
        </extensions>
    </trkpt>
    <trkpt lat="" lon="">
        <ele>14.3</ele>
        <time>2022-04-16T08:31:27.000Z</time>
        <extensions>
        <gpxtpx:TrackPointExtension>
        <gpxtpx:hr>null</gpxtpx:hr>
        </gpxtpx:TrackPointExtension>
        </extensions>
    </trkpt>

Another issue I found was that when adding some new points to my run, they would get a heartrate of 18 assigned

    <trkpt lat="" lon="">
        <ele>10.1</ele>
        <time>2022-04-16T08:55:07.045Z</time>
        <extensions>
        <gpxtpx:TrackPointExtension>
        <gpxtpx:hr>18</gpxtpx:hr>
        </gpxtpx:TrackPointExtension>
        </extensions>
    </trkpt>
    <trkpt lat="" lon="">
        <ele>12.4</ele>
        <time>2022-04-16T08:55:36.090Z</time>
        <extensions>
        <gpxtpx:TrackPointExtension>
        <gpxtpx:hr>18</gpxtpx:hr>
        </gpxtpx:TrackPointExtension>
        </extensions>
    </trkpt>
    <trkpt lat="" lon="">
        <ele>7.7</ele>
        <time>2022-04-16T08:55:52.911Z</time>
        <extensions>
        <gpxtpx:TrackPointExtension>
        <gpxtpx:hr>18</gpxtpx:hr>
        </gpxtpx:TrackPointExtension>
        </extensions>
    </trkpt>

It seems that 18 is the average heartrate, calculated including all of the added 'null' hr tags (original gpx contained 1359 trkpt tags, where 136 of those had heartrate data of +- 180 -> (136*180)/1359 = 18) so I think fixing the first issue will also automatically fix this (although an option to disable adding heartrate data for new points would be preferred for me, this is probably tied together with the 'preserve average speed' option now?)

CasperVerswijvelt avatar Apr 16 '22 10:04 CasperVerswijvelt

I have added extra checks to prevent null values from impacting the computations. But still I don't know how null values existed in the first place. Could you send me your GPX file so I can test?

vcoppe avatar Apr 17 '22 13:04 vcoppe

Thanks for looking into this! I sent the GPX file to you via email.

I tried loading and exporting that same file again just now and while there are no more null values present and the correct average heartrate is used, all points without any heartrate data now get this average heartrate assigned, which is not really ideal when e.g. creating graphs with this data ...

In my eyes heartrate is not something that should be added to points that don't have this data, perhaps this can be put behind an option?

CasperVerswijvelt avatar Apr 17 '22 16:04 CasperVerswijvelt

@vcoppe if you agree with that behaviour I can try to make the needed changes myself too and open a PR?

CasperVerswijvelt avatar Apr 17 '22 17:04 CasperVerswijvelt

Another option would be to interpolate between the known values, would that make sense to you? I would rather avoid adding yet another setting if I can.

vcoppe avatar Apr 20 '22 08:04 vcoppe

Interpolating would be fine, but for my usecase it would still be better to not have any new heartrate data added at all.

Can't really think of a use-case where you would want to add new heartrate data

CasperVerswijvelt avatar Apr 20 '22 10:04 CasperVerswijvelt