piscoTech / Workout

A simple iOS app that accesses Health data to export workout data to CSV for any use.
MIT License
43 stars 9 forks source link

Show and export workout routes #6

Closed piscoTech closed 4 years ago

piscoTech commented 6 years ago

I'm thinking about displaying the workout route (if any) alongside the details and exporting all GPS data in a dedicated CSV file.

Will this be useful?

maxime-killinger commented 4 years ago

A long time that I’m looking too export GPS data to GPX files. That could be useful.

matlin72 commented 4 years ago

Oh yes! Been looking for an app with exactly this feature for some time. Like the "Track Addict" app but for logging workouts. The UTC Timestamp could be usable as well.

piscoTech commented 4 years ago

Thank you for the feedback.

Do you have any request for a specific file format? I’ve heard there are a few but I’ve never used them so what’s the most common/useful

matlin72 commented 4 years ago

For me, I would say ”.csv”. I usually converts csv to json but csv gives smaller file sizes and I can for example rename a column header once to suit my needs. In json it take more job to change that in all objects. For example Track addict names the Timestamp “UTC time”. The GoPro I’ve been using lately names it “Time”. Csv makes it much easier to make such change for all data.

I saw that the level of detail goes down to one minute. Perhaps it could be useful even go down to seconds or five seconds. Different kind of activites e.g. long distance run vs mountain bike rides, needs different levels of details I guess.

maxime-killinger commented 4 years ago

For me it's .gpx, a xml based file format that it's dedicated for this usage. Location data and optionally elevation, time, and other information can be stores in this file and can be read by different websites and apps unlike .csv files. Here you can find the GPX documentation and schema from the official website : https://www.topografix.com/gpx.asp

piscoTech commented 4 years ago

I guess I'll go for both of them and allow you to choose what you want from settings.

If I remember correctly a workout route is saved inside HealthKit as a sequence of GPS data point that could be trivially converted to GPX. For CSV I could do the same with each row representing a single point in the route, I don't think that aggregating the data is the right thing to do as that's a job for details.csv so I'll keep the maximum resolution possible in the data like for GPX.

matlin72 commented 4 years ago

Sounds just fine!

piscoTech commented 4 years ago

@matlin72 How should be handled in the CSV a pause in the workout? It would be nice to include a row indicating that there has been a pause like in details.csv. Would doing so cause a problem? Do you have any other idea on how to indicate that?

For GPX there is a specific and standard way to do this so it's not a problem.

matlin72 commented 4 years ago

Oh, I haven’t thought of that. I’d better look up the .gpx-way how to do it. Is there specific data about the pauses that are of particular interest? But again, I’ll take a look at gpx.

piscoTech commented 4 years ago

The only data about the pause is the duration but in GPX by representing the route as a trkType split in multiple trksegType there's no way to represent it.

Would be fine if we just use an additional column Segment with a counter indicating to which segment the GPS point belongs and when a pause is encountered the number increases?

matlin72 commented 4 years ago

Segment is a great idea. Can’t help atart thinking about Race Render / Track Addict wihich also use a “Lap” column. There are some cases you for example run or cycles the same route several laps. Just an idea.

piscoTech commented 4 years ago

@matlin72 Here you can find the first version of the CSV export. The data is from a short walk.

Any feedback?

Edit: this message references the first revision of the gist

matlin72 commented 4 years ago

Hi! Sorry for the delay. It’s been a lot of xmas lately... Looks fine. I’m thinking about the format of ”UTC Time”. Is this the format to be or is format something the user will be able to change, e.g: Date, seconds, milliseconds?

piscoTech commented 4 years ago

That was exactly what I was unsure about. That is the ISO 8601 format for UTC time, which I chose because it's what is required by the GPX standard and because I assumed the route data would most likely be analyzed by a computer.

Other meaningful option for the time would be a more easily understandable YYYY-MM-DD hh:mm:ss.sss but whether to use UTC or the local time zone would be up to discussion. Note that from some tests the millisecond precision in time is needed as (at least for Apple Watch recorded workouts) the GPS precision tends to be about 1 seconds, sometimes slightly less.

I'm not inclined to let the user choose the format they want for the CSV file. I'm more lying towards including multiple time columns as they can be quickly dropped. The options could be UTC ISO, UTC and local time, the latter two with the YYYY-MM-DD hh:mm:ss.sss format

matlin72 commented 4 years ago

Sounds reasonable. In general, sticking to standards is a good thing. Some options too is nice. One format i’ve got used to from action cams is unix timestamp. Seconds as well as milliseconds.

piscoTech commented 4 years ago

I've update the sample files with the GPX version and the CSV with more time options (local time is CEST, GMT+2).

Do you thing they're ready?

matlin72 commented 4 years ago

Reading through the original question, the route are going to be presented along the details and be stored in a dedicated file? These details, like heart beat, burned calories will find its way to the file as well or the csv and .gpx will only contain the route?

piscoTech commented 4 years ago

The current implementation maintains the original detail.csv untouched and route.csv/gpx contains only the GPS data.

Trying to merge all data in a single file would be unfeasible for two reasons:

  1. There's no guarantee that for a given timestamp there's both GPS data and heart rate or other details
  2. While heart rate represent information for a single point in time and as such it can be attached to a single timestamp, most of the other data (distance, calories, steps/strokes) represent information relative to a time interval, i.e. a duration, so I don't see an easy way to attach them to a single timestamp. Even choosing, e.g., the start of such interval as the timestamp there's still problem 1 to consider
matlin72 commented 4 years ago

You’re right about that (intervall). One way could think of would be to at each timestamp add the accumulative number of heart beats, burnt calories since start.

But as it is, there’s something to start with and I’m really looking forward to be able and try this out. Good work!👍