3.0.8 • Published 3 years ago

gpxparser v3.0.8

Weekly downloads
84
License
MIT
Repository
github
Last release
3 years ago

GPXParser

GPXParser.js

npm.io npm.io

GPXParser.js 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 différence

GPX ? What is this ?

Wikipedia say :

GPX, or GPS Exchange Format, is an XML schema designed as a common GPS data format for software applications.

gpx files are based on xml with specific tags and attributes

For more information about gpx format see http://www.topografix.com/gpx_manual.asp

How to do

Install from npm

npm install --save gpxparser

Load JavaScript file

From an HTML document :

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

From a node.js script :

let gpxParser = require('gpxparser');

Create and parse file

var gpx = new gpxParser(); //Create gpxParser 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 gpxParser Objecto 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

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
3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago