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

NaN issue when importing from a gpx #7

Closed davidwul closed 8 years ago

davidwul commented 8 years ago

Hi I'm pursuing the import from gpx feature. It's starting to give some results. I have a problem with Nan value. /var/lib/gems/2.3.0/gems/fit4ruby-1.4.0/lib/fit4ruby/GlobalFitMessage.rb:121:in `to_i': NaN (FloatDomainError) I'm not sure why and what is happening. I want to ask your expertise about if my fix makes sense? Or should I understand why these NaN values appears? Thanks for your comments.

scrapper commented 8 years ago

That fix is just a workaround for your specific problem. Somehow you have assigned a NaN value (usually a division by 0 result) into the Fit4Ruby data structures. There is little to no sanity checking right now when you create your own fit file. As the FIT file is strongly typed, it would make sense to add some checking when values are passed during FIT message creation.