Git Product home page Git Product logo

fitreader's Introduction

Fitreader

Fitreader is a small gem used for read and decoding FIT files generated by various sports devices. Currently it has only been designed specifically to read files produced by a Garmin Edge 1000. It will probably mostly work out of the box with other file sources, but will probably not work 100% perfectly unless it's a Garmin cycling computer.

Installation

Add this line to your application's Gemfile:

gem 'fitreader'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fitreader

Usage

To use this gem in a ruby or rails application, simply add

gem 'fitreader'

to the Gemfile and then

require 'fitreader'

to the class you wish to call it from. After that, it's a simple matter of calling

fit_file = Fit.new(path_to_fit_file)

All of the interface and convenience functions can be found in lib/fitreader.rb.

After reading a FIT file, the file header can be inspected by calling

fit_file.header

A digest of the records found in the file is shown with

fit_file.digest

which will return a list similar to the following, showing respectively the name of the record type (as defined in the FIT SDK), and the number of records parsed

{:file_id=>1,
 :file_creator=>1,
 :device_settings=>1,
 :user_profile=>1,
 :sensor_info=>5,
 :sport=>1,
 :zones_target=>1,
 :record=>4988,
 :event=>120,
 :device_info=>30,
 :source=>43,
 :segment_lap=>2,
 :lap=>1,
 :session=>1,
 :activity=>1,
 :battery_info=>20}

Armed with this information, we can call

fit_file.type <name>

where is the name supplied by the previous command, for example

fit_file.type :session

will fetch the session record(s) in the form of a Message object. This object contains three fields: a name, a global_num (as defined by the FIT SDK), and an array of records.

The records array contains a list of hashes, with key-value pairs of field name (also according to the message-type definition) and value, for example timestamp, or coordinates, etc.

For example:

{:timestamp=>2016-04-09 11:19:51 UTC,
 :position_lat=>57.711100755259395,
 :position_long=>11.992837116122246,
 :distance=>78.94,
 :altitude=>14.200000000000045,
 :speed=>3.835,
 :heart_rate=>103,
 :cadence=>0,
 :temperature=>12,
 :fractional_cadence=>0.0},

Some things to watch out for:

  • speed is recorded as m/s, rather than kph as one might expect.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rspec spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine from a clone of the repo, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/samsari/fitreader.

License

The gem is available as open source under the terms of the MIT License.

fitreader's People

Contributors

ikbenben avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.