jovandeginste / workout-tracker

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

Automatic detection of workouts and metrics differences #184

Closed muzzah closed 1 month ago

muzzah commented 1 month ago

Hey

Nice project! Thanks for your efforts. I imported my 300+ apple fitness workouts that are made up mainly of running, hiking, walking workouts. Everything is automatically detected as either running or walking. The hikes are I assume categorised as walking workouts. I guess its not easy to differentiate between the two without specific signals. Im also seeing a bit of a discrepency between what apple fitness metrics and what the this web app shows.

Im assuming the iOS device uses different ways to calculate some of these metrics vs using purely the GPX file data. Is this a known issue?

jovandeginste commented 1 month ago

The type is detected first if there is a hint (maybe Apple has different hints?) and then purely based on average speed of the total workout (without pause).

See these two functions: https://github.com/jovandeginste/workout-tracker/blob/master/pkg/database/workouts.go#L129-L173

jovandeginste commented 1 month ago

If you have a demo GPX file that you can share, we can look into it?

muzzah commented 1 month ago

It seems there arent many hints in the gpx file exported from apple workouts. Ive pasted the contents of a sample file below which was a run

<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="HealthKitExporter" xmlns="http://www.topografix.com/GPX/1/1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
    <trk>
        <trkseg>
            <trkpt lat="52.479905" lon="13.423994">
                <ele>53.534778638742864</ele>
                <time>2024-07-21T07:14:52Z</time>
            </trkpt>
            <trkpt lat="52.479909" lon="13.423963">
                <ele>53.54285910911858</ele>
                <time>2024-07-21T07:14:53Z</time>
            </trkpt>
            <trkpt lat="52.479912" lon="13.423930">
                <ele>53.54961864557117</ele>
                <time>2024-07-21T07:14:54Z</time>
            </trkpt>
            <trkpt lat="52.479914" lon="13.423895">
                <ele>53.55538054089993</ele>
                <time>2024-07-21T07:14:55Z</time>
            </trkpt>
            <trkpt lat="52.479916" lon="13.423857">
                <ele>53.564768677577376</ele>
                <time>2024-07-21T07:14:56Z</time>
            </trkpt>
            <trkpt lat="52.479917" lon="13.423818">
                <ele>53.5731300637126</ele>
                <time>2024-07-21T07:14:57Z</time>
            </trkpt>
            <trkpt lat="52.479917" lon="13.423780">
                <ele>53.577292738482356</ele>
                <time>2024-07-21T07:14:58Z</time>
            </trkpt>
            <trkpt lat="52.479918" lon="13.423740">
                <ele>53.58410771470517</ele>
                <time>2024-07-21T07:14:59Z</time>
            </trkpt>
            <trkpt lat="52.479918" lon="13.423701">
                <ele>53.5882831113413</ele>
                <time>2024-07-21T07:15:00Z</time>
            </trkpt>
            <trkpt lat="52.479918" lon="13.423662">
                <ele>53.59123161341995</ele>
                <time>2024-07-21T07:15:01Z</time>
            </trkpt>
            <trkpt lat="52.479919" lon="13.423622">
                <ele>53.5945692602545</ele>
                <time>2024-07-21T07:15:02Z</time>
            </trkpt>
.......
        </trkseg>
    </trk>
</gpx>
muzzah commented 1 month ago

Btw, if you want a walking based gpx file and a hiking one to compare and test with I can send it to you personally rather than attach it here as it contains location info I dont want to share publicly.

jovandeginste commented 1 month ago

There is no hint as to which type of activity was tracked in this gpx (unless the other files contain anything useful?)

This means we can only infer based on speed, which is what we do so far.

You can change the type after uploading.

You see any other solution?

jovandeginste commented 1 month ago

I will close this for now, let me know if you have any ideas!

muzzah commented 2 weeks ago

I think the only way to do this with GPX files like the one apple produces is to use historical data and create a model based on other workouts. Otherwise it would be difficult. All good. Thanks for looking into it.