Giter VIP home page Giter VIP logo

tcx-builder's Introduction

TCX BUILDER

This package allows you to generate tcx file from Javascript Class. See tcx file definition here.

How to use ?

Install package using npm :

npm install tcx-builder

Import package

// First way
const tcxBuilder = require('tcx-builder');

// Prefered way
const { TrainingCenterDatabase } = require('tcx-builder');

// Using imports
import { TrainingCenterDatabase } from 'tcx-builder';

Check garmin tcx file description for more informations.

Example

import {
  TrainingCenterDatabase,
  Activity,
  ActivityLap,
  Track,
  TrackPoint,
  Position,
  HeartRateBpm,
  TrackPointExtensions,
  ActivityList,
  HeartRateInBeatsPerMinute,
} from 'tcx-builder';

const trackPoints: TrackPoint[] = [
  new TrackPoint({
    time: new Date(),
    position: new Position(48.853444, 2.348780),
    altitudeMeters: 100,
    distanceMeters: 0,
    heartRateBpm: new HeartRateBpm(150),
    cadence: 80,
    sensorState: 'Present',
    extensions: new TrackPointExtensions({
      Speed: 10,
      Watts: 200,
    }),
  }),
];

const myLap: ActivityLap = new ActivityLap(new Date(), {
  Calories: 0,
  DistanceMeters: 40000,
  Intensity: 'Active',
  TotalTimeSeconds: 4000,
  TriggerMethod: 'Distance',
  MaximumSpeed: 12,
  MaximumHeartRateBpm: new HeartRateInBeatsPerMinute({ value: 180 }),
  AverageHeartRateBpm: new HeartRateInBeatsPerMinute({ value: 160 }),
  Cadence: 80,
  Track: new Track({ trackPoints }),
});

const tcxActivity = new Activity('Biking', {
  Id: new Date(),
  Laps: [ myLap ],
  Notes: 'Activity Description',
});
const activityList = new ActivityList({ activity: [tcxActivity] });

const tcxObj = new TrainingCenterDatabase({ activities: activityList });

const xml: string = tcxObj.toXml();

tcx-builder's People

Contributors

anthony2856 avatar dboroujerdi avatar falg05911 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.