1.0.42 • Published 6 years ago

tcx-file-class v1.0.42

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

tcx-file-class

Description

Reads a tcx file from garmin, polar, runtastic, tapiriik and introduce the class TcxFile wich has function to read all the values. It uses node-xml2js package for parsing the file.

Istallation

To install tcx-file-class use npm. npm install xml2js will do the job.

Usage

  • Import reference to TcxFile class like this:
import TcxFile from "tcx-file-class";

const tcxFile = new new TcxFile(fname, (err:string|undefined)=>{
    if (err){ //something went wrong
    }
});
  • If the class was created succesfully, the value tcxFile.isReady will be true.
  • Functions:
    • getId():string gives the Id of the file.
    • getSport():string gives a string with the Sport
    • getAuthor():Author|null give the Author class if any exists
    • getCreator():Creator|null give the Creator class if any exists
    • getLaps:Array\ | Array\ give the Laps class
    • save(filename: string, athleteId: number, zones: number, number, number, number|null, callback: (err: string) => void) save to the file (in json format), whith the proper athlete Id. The optional heart rate zones are used to calculate the time in zones.

Helper classes

These classes are created internally and is not recommended to create them by yourself.

Author

class Author {
    name: string;
    typeOfAuthor: string | any;
    build: string;
    langId: string;
    partNumber: string;
}

Creator

class Creator {
    name: string;
    typeOfCreator: string;
    productId: Number;
    unitId: Number;
    version: string;
    isRuntastic: boolean;
}

Laps

class Lap {
    startTime: string;
    averageHeartRateBpm: number;
    maximumHeartRateBpm: number;
    maximumSpeed: number;
    totalTimeSeconds: number;
    calories: number;
    distanceMeters: number;
    maxBikeCadence = consts.ERROR_NUMBER_VALUE;
    steps = consts.ERROR_NUMBER_VALUE;
    avgRunCadence = consts.ERROR_NUMBER_VALUE;
    maxRunCadence = consts.ERROR_NUMBER_VALUE;
    avgSpeed = consts.ERROR_NUMBER_VALUE;
    intensity = consts.ERROR_STRING_VALUE;
    trackPoints: Array<GpsPoint>;
    triggerMethod = consts.ERROR_STRING_VALUE;
}

GpsPoint

class GpsPoint {
    distanceMeters = consts.ERROR_NUMBER_VALUE;
    speed = consts.ERROR_NUMBER_VALUE;
    runCadence = consts.ERROR_NUMBER_VALUE;
    cadence = consts.ERROR_NUMBER_VALUE;
    heartRateBpm = consts.ERROR_NUMBER_VALUE;
    position: { latitudeDegrees: number, longitudeDegrees: number, altitudeMeters: number } =
        {
            latitudeDegrees: consts.ERROR_NUMBER_VALUE,
            longitudeDegrees: consts.ERROR_NUMBER_VALUE,
            altitudeMeters: consts.ERROR_NUMBER_VALUE
        }
    time = consts.ERROR_STRING_VALUE;

Consts used

const ERROR_NUMBER_VALUE = -1;
const ERROR_STRING_VALUE = "";

Tests

Package has number of tests. Package is written in Typescript, so if you want to change something do it in src\*.ts files.

Support

If something is wrong or you have something to propose please feel free to ask me (email me).

1.0.42

6 years ago

1.0.41

6 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago