scrapper / fit4ruby

Fit4Ruby is a Ruby library to read and write FIT files.
GNU General Public License v2.0
26 stars 17 forks source link

Add support for lengths #15

Closed jpablobr closed 5 years ago

jpablobr commented 5 years ago

Hi, this pull request adds support for Length(s).

No sure on what other sports Length(s) are used but for swimming (pool swimming specifically) they are very important as they are the main way to keep track of distance. Pool swimming relies on the pool length/size (e.g., 25mts, 50mts, etc... prespecified by the user) and (as far as I understand) some type of accelerometer sensor capable of determining a swimmer's swim-turn/stop to then determine how many Length(s) they have done and hence the overall distance (e.i., swam-Length(s) Length(s)-length/size [e.g., 450mts=200mts]). Furthermore, thanks to this additional data, we then get a bunch more of cool things to measure! (Which actually you already have specified in message 101 in GlobalFitMessages)

As it is, with this script, I was able to recreate all the data displayed on my Garmin Connect (which already isn't that great but it is what it is...).

https://connect.garmin.com/modern/activity/4007435358

garmin-connect-swim f4r-swim-export

Fit file: 4007435358.fit.txt (remove the .txt extension)

Eventually, I'd like to be able to edit a fit file. The problem with these accelerometers is that if for example you do something weird like adjust your goggles in the middle of your Length it will think that you actually completed the Length and, by the end of that Length, you'll end up with two Length in basically half the time! (But that's not for this PR, just thought it wouldn't hurt to mention)

Please let me know if I missed something and if the PR needs further things to be actioned. I'm not 100% sure on the way Records are being linked to other objects.

scrapper commented 5 years ago

Sorry, but I had to revert this commit. It's breaking all all fit files without length. Please extend tests to test for fit files with and without length.