cmaion / polar

A set of command line tools written in Ruby to interact with Polar watches and decode raw data files
90 stars 22 forks source link

Only first part of a multi-sport activity included in GPX #6

Open jluttine opened 6 years ago

jluttine commented 6 years ago

I did a multi-sport activity with V800. It works so that I choose a sport at the beginning (e.g., running) and then I can switch to another sport (e.g., swimming) during the training and it also measures the transition time. Thus, it V800 records something like: running - transition - swimming - transition - running - transition - cycling. (Though, in my test case, I only had running like: running -> transition -> running -> transition -> running.) This is extremely useful in sports like triathlon, duathlon and swimrun.

In my test case, when I converted the result to GPX, it only included the first part (in this case, the first running). I'll attach the V800 directory of that activity here: 183455.tar.gz

It would be nice if the resulting GPX could include all parts and probably even the transition times.

jluttine commented 6 years ago

Here is another multi-sport activity: 180132.tar.gz

It's "Triathlon" activity, but it contains two sports: running first, swimming second. The resulting GPX contains only the running part (and no transition either): 180132_gpx.tar.gz

cmaion commented 6 years ago

Yes right now only the first activity is parsed, but parsing all of them should not be an issue.

What tool do you use to read the GPX files? Does it expect a single GPX file for all activities, or one file per activity? If you have a sample GPX file (or set of files) of a typical multi-sport training session that would help.

jluttine commented 6 years ago

I'm uploading the training files to Runalyze. For comparison, I synced my training session to Polar Flow website and then exported the session from there. It seems that the exported file is a zip file containing a separate GPX (or TCX) file for each part. So, perhaps GPX and TCX don't support multi-sport activities and the solution would be to create separate files for each part? Then, it depends on the analytics service whether they can group multiple files into a single multi-sport session (Runalyze unfortunately doesn't support that, each part is a separate activity session).

Here's the zip file I exported from Polar Flow web site (corresponds to 180132.tar.gz above): Jaakko_Luttinen_2018-07-22_18-01-32.zip

cmaion commented 6 years ago

Can you export that training session from Polar Flow as GPX too?

jluttine commented 6 years ago

Polar Flow GPX export only contains GPS track, nothing else. But here's the exported zip of the same multi-sport activity in which each part is in its own GPX file: Jaakko_Luttinen_2018-07-22_18-01-32.zip

jluttine commented 4 years ago

Is there something I could do to help with this? Can I provide something? Or do you think it's something that an external person like me could implement? I've never programmed in Ruby, but I can always learn. But I would definitely need some pointers because I'm unfamiliar with both the language and this repository.

cmaion commented 4 years ago

Hi,

Should not be really hard to implement.

  1. Data parsing should be updated to read all parts of the training session: instead of returning a simple hash hard-coded to the first training activity, it should iterate over all activities and return an array of those per-activity hash: https://github.com/cmaion/polar/blob/eca28cd92fcd9d4b6ee00b8994bfff323b0df388/lib/polar_data_parser.rb#L39 That should be easy.

  2. All converters should be updated to use this array of hashes instead of a single hash (polar_training2gpx, polar_training2tcx...), starting with just using the first activity as it is right now. Easy too.

  3. The real question then is how should those multi-part activities be generated in the other formats (TCX, GPX...): one output file per activity? All in a single file? (and if so, what is the correct way to convey the multi-part aspect?). Depending on what the output should look like, it can be trivial or a bit more work

Take a look, if you are familiar with any programming language, you should find Ruby quite easy to work with.