GithubHelp home page GithubHelp logo

easy-fit's Introduction

NOTE: this lib is currently being rewritten in a new repository.

easy-fit

Parse your .FIT files easily, directly from JS. Written in ES6.

Install

$ npm install easy-fit --save

How to use

See in examples folder:

// Require the module
var EasyFit = require('./../dist/easy-fit.js').default;

// Read a .FIT file
var fs = require('fs');
fs.readFile('./example.fit', function (err, content) {

  // Create a EasyFit instance (options argument is optional)
  var easyFit = new EasyFit({
    force: true,
    speedUnit: 'km/h',
    lengthUnit: 'km',
    temperatureUnit: 'kelvin',
    elapsedRecordField: true,
    mode: 'cascade',
  });
  
  // Parse your file
  easyFit.parse(content, function (error, data) {
  
    // Handle result of parse method
    if (error) {
      console.log(error);
    } else {
      console.log(JSON.stringify(data));
    }
    
  });
  
});

API Documentation

new EasyFit(Object options)

Needed to create a new instance. options is optional, and is used to customize the returned object.

Allowed properties :

  • mode: String
    • cascade: Returned object is organized as a tree, eg. each lap contains a records fields, that is an array of its records (default)
    • list: Returned object is organized as lists of sessions, laps, records, etc..., without parent-child relation
    • both: A mix of the two other modes, eg. records are available inside the root field as well as inside each laps
  • lengthUnit: String
    • m: Lengths are in meters (default)
    • km: Lengths are in kilometers
    • mi: Lengths are in miles
  • temperatureUnit: String
    • celsius:Temperatures are in °C (default)
    • kelvin: Temperatures are in °K
    • farhenheit: Temperatures are in °F
  • speedUnit: String
    • m/s: Speeds are in meters per seconds (default)
    • km/h: Speeds are in kilometers per hour
    • mph: Speeds are in miles per hour
  • force: Boolean
    • true: Continues even if they are errors (default for now)
    • false: Stops if an error occurs
  • elapsedRecordField: Boolean
    • true: Includes a elapsed_time field inside each record field, containing the elapsed time in seconds since the first record (default)
    • false

easyFit.parse(Buffer file, Function callback)

callback receives two arguments, the first as a error String, and the second as Object, result of parsing.

Contributors

Big thanks to Mikael Lofjärd for his early prototype. See CONTRIBUTORS.

License

MIT license; see LICENSE.

(c) 2016 by Pierre Jacquier

easy-fit's People

Contributors

aengus1 avatar ianforsyth avatar manuelbaun avatar pierremtb avatar srskc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

easy-fit's Issues

How can i use it without node

How can i use it without node. I would like to use it in an angularjs application.
So require didn t exists. How to transpil it ?
Thanks

Fails to parse FIT file with developer fields

Parsing fails when record contains developer defined fields which are used by third party app developers and new in FIT 2.0 (?) spec.

The parsing itself does not crash but data after such a message becomes jibberish.

I created a fork with a fix, tests are passing but still early in the process, will create a PR to main repo once stable.

If anyone wants to have a look, here it is:

FrostDigital#1

Use in browser (client side)

Is it possible to modify easy-fit to be used client side (in the browser)?

Update: This has been discussed (and solved) in one of the closed issues.

Add timer time to records

👋Hi! Thanks so much for this awesome library. It makes working with .FIT files a breeze. ✨

I noticed that records fields have an elapsed_time field that tells us how many seconds have passed since the start of the activity. I think it would be great if records also included a timer_time field that tells us the time on the device when the record happened.

This would be useful because I'll often stop my watch when I stop at a red light, for example, and start it when I begin moving again. Platforms like Garmin Connect and Strava use the time on the device, not the total elapsed time including the time the device was stopped, to calculate splits, and I'd like to do the same.

Happy to take a stab at this one! Just wanted to open an issue in case anyone had already started thinking about this or working on it.

Thanks again! ❤️

left_right_balance not being parsed correct

The left_right balance is incorrect it seems.

in the fit.js file it states
left_right_balance: {
0: 0,
127: 'mask',
128: 'right'
},
left_right_balance_100: {
0: 0,
16383: 'mask',
32768: 'right'
},

I'm getting values of 178 for left_right and 37885 for left_right_balance_100. On top of this, the left right balance should be a balance percentage not a value "right" or "mask"

gps coordinates

Hello,

I have realised that

activity -> sessions -> laps -> records -> [position_lat, position_long]

the coordinates are incorrect. I don't know the exact conversion, but at least negative values are represented as positive, and it needs some other conversion to place the record in the proper point.

Incorrect sport mapping: hang gliding instead of paragliding

26: 'hang_gliding',

Sorry - this was based on the Assumption that Suunto follows the API standard which it does not. According to the Standard 26 is indeed hang_gliding - even if that might only be the case because someone at Garmin messed up.

Original text:
Hi, based on a .fit file from Suunto 26 should be mapped to paragliding instead of hang_gliding.

For people not familiar with the sports:

release a version with the latest fit.js?

Any chance of a version release to the registry that has the latest fit.js file? The mileage conversion in npm is way off but it's been fixed in source, just not pushed to the registry.

Incorrrect offset for altitude fields

The offset value for altitudes should be -500, it appears to be configured as +500.

When encoding altitude fit will use
uint16 = 5 * (altM + 500)

So decoding should use
altM = uint16 / 5 - 500 // offset should be -500

Records incomplete when trying to parse a fit file from a Wahoo GPS

I've tried to parse a fit file from a Wahoo GPS, but I always get 2 records in the resulting json while the file itself (verified in Basecamp) have thousands of track points in it.

Any idea what's wrong here?
I have no issues with the parsing of other fit files (from Garmin units), all of these are ok.
Wahoo.zip

Power Data messed up when no powermeter available

When reading a FIT file from a cycling ride without Powermeter connected, all powerdata show 65535 as value.

This includes avg_power, max_power and all other related values such as training_stress_score (which is 6553.5 in this case).

Thanks for having a look.

Incorrect location records and activity after parsing

I'm getting some unusual data for locations and activity type after parsing attached FIT file (Generated by Garmin). Below are the activity and location records I get after parsing to JSON:

sport:
{ name: 67,
sport: 'generic',
sub_sport: 'bike_to_run_transition' },
zones_target: { max_heart_rate: 195, hr_calc_type: 'percent_max_hr' },
sessions: [],
laps: [],
records:
[ { timestamp: '2017-12-10T14:02:05.000Z',
position_lat: 49.8264604434371,
position_long: 262.8936153743416,
distance: 21.78,
altitude: 1231.6,
speed: 3.322,
heart_rate: 91,
cadence: 95,
fractional_cadence: 0,
elapsed_time: 0 },
{ timestamp: '1990-08-15T13:16:08.000Z',
position_lat: 350.1582593098283,
position_long: 98.81422287784517,
distance: 2392564.2,
altitude: 727,
speed: 13.456,
heart_rate: 109,
cadence: 35,
fractional_cadence: 196 } ],


I confirmed this activity is a genuine running activity and there are valid locations by uploading it back to Garmin.

2374117972.zip

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.