1.1.0 • Published 11 months ago

gpx-js v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

GpxJs

npm.io npm.io

GpxJs is a lightweight JS library wich parse .gpx file and get or compute various datas like

  • GPX metadata
  • total and cumulate distances
  • min, max, average, positive and negative height difference
  • Hr, Cadence, Temperature (exported from Garmin devices)

It is created by Lucas, Original Repo

I added some support to new elements exported from my Garmin Edge 830 device as HR, Cadence and Temperature

How to do

Install from npm

npm install --save gpx-js

Load JavaScript file

From an HTML document :

<script src="./js/GpxJs.js"></script>

From a node.js script :

let gpx = require('gpx-js');

Create and parse file

var gpx = new GpxJs(); //Create GpxJs Object
gpx.parse("<xml><gpx></gpx></xml>"); //parse gpx file from string data

Use the gpx Object

var totalDistance = gpx.tracks[0].distance.total;

Export GpxJs Object to GeoJSON

let geoJSON = gpx.toGeoJSON();

Documentation

PropertyTypeDescription
xmlSourceXMLXML Object parsed from gpx string file
metadataMetadata objectFile metadata
waypointsArray of Waypoint objectArray of waypoints
tracksArray of Track objectArray of waypoints of tracks
routesArray of Route objectArray of waypoints of routes

Metadata object

PropertyTypeDescription
nameStringFile name
descStringDescription
linkLink objectWeb address
authorFloatAuthor object
timeDateTimeTime

Waypoint object

PropertyTypeDescription
nameStringPoint name
cmtStringComment
descStringPoint description
latFloatPoint latitute
lonFloatPoint longitude
eleFloatPoint elevation
timeDatePoint time

Track object

PropertyTypeDescription
nameStringPoint name
cmtStringComment
descStringPoint description
srcStringUsed device
numberStringTrack identifier
linkStringLink to a web address
typeStringTrack type
pointsArrayPoints object array
distanceDistance ObjectDistance informations about the Route
elevationElevation ObjectElevation informations about the Route
slopesFloat ArraySlope of each sub-segment

Route object

PropertyTypeDescription
nameStringPoint name
cmtStringComment
descStringPoint description
srcStringUsed device
numberStringTrack identifier
linkStringLink to a web address
typeStringRoute type
pointsArrayPoints object array
distanceDistance ObjectDistance informations about the Route
elevationElevation ObjectElevation informations about the Route
slopesFloat ArraySlope of each sub-segment

Point object

PropertyTypeDescription
latFloatPoint latitute
lonFloatPoint longitude
eleFloatPoint elevation
timeDatePoint time
hrIntPoint Hear rate
cadIntPoint Cadence
atempIntPoint Temperature

Distance object

PropertyTypeDescription
totalFloatTotal distance of the Route/Track
cumulFloatCumulative distance at each point of the Route/Track

Elevation object

PropertyTypeDescription
maxFloatMaximum elevation
minFloatMinimum elevation
posFloatPositive elevation difference
negFloatNegative elevation difference
avgFloatAverage elevation

Author object

PropertyTypeDescription
nameStringAuthor name
emailEmail objectEmail address of the author
linkLink objectWeb address

Email object

PropertyTypeDescription
idStringEmail id
domainStringEmail domain

Link object

PropertyTypeDescription
hrefStringWeb address
textStringLink text
typeStringLink type
1.1.0

11 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago