Skip to content
GPX file parser javascript library
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo Update demo Oct 23, 2019
src Merge branch 'develop' Oct 23, 2019
LICENSE Create LICENSE Nov 3, 2018
README.md Total rework for accept multiple tracks/waypoints/routes Nov 3, 2018
index.html Update demo Oct 23, 2019
package.json Total rework for accept multiple tracks/waypoints/routes Nov 3, 2018

README.md

gpx-parser

gpx-parser is a lightweight JS library wich parse .gpx file and get or calculate some datas like

  • gpx metadatas
  • 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

Load JavaScript file

<script src="./js/gpx-parser.js"></script>

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;

Documentation

Property Type Description
xmlSource XML XML Object parsed from gpx string file
metadata Metadata object File metadata
waypoints Array of Waypoint object Array of waypoints
tracks Array of Track object Array of waypoints of tracks
routes Array of Route object Array of waypoints of routes
  • xmlSource
  • metadata
    • name
    • desc
    • link
      • href
      • text
      • type
    • author
      • name
      • email
        • id
        • domain
      • link
        • href
        • text
        • type
    • time
  • waypoints
    • waypoint
      • name
      • cmt
      • desc
      • lat
      • lon
      • ele
  • tracks
    • track
      • name
      • cmt
      • desc
      • src
      • number
      • link
      • type
      • points
        • lat
        • lon
        • ele
      • distance
        • total
        • cumul
          • incremental values
          • [...]
      • elevation
        • min
        • max
        • pos
        • neg
        • avg
    • [track]
      • [...]
  • routes
    • route
      • name
      • cmt
      • desc
      • src
      • number
      • link
      • type
      • points
        • lat
        • lon
        • ele
      • distance
        • total
        • cumul
          • incremental values
          • [...]
      • elevation
        • min
        • max
        • pos
        • neg
        • avg
    • [route]
      • [...]

Metadata object

Property Type Description
name String File name
desc String Description
link Link object Web address
author Float Author object
time DateTime Time

Waypoint object

Property Type Description
name String Point name
cmt String Comment
desc String Point description
lat Float Point latitute
lon Float Point longitude
ele Float Point elevation

Track object

Property Type Description
name String Point name
cmt String Comment
desc String Point description
src String Used device
number String Track identifier
link String Link to a web address
type String Track type
points Array Points object array
distance Distance Object Distance informations about the Route
elevation Elevation Object Elevation informations about the Route

Route object

Property Type Description
name String Point name
cmt String Comment
desc String Point description
src String Used device
number String Track identifier
link String Link to a web address
type String Route type
points Array Points object array
distance Distance Object Distance informations about the Route
elevation Elevation Object Elevation informations about the Route

Point object

Property Type Description
lat Float Point latitute
lon Float Point longitude
ele Float Point elevation

Distance object

Property Type Description
total Float Total distance of the Route/Track
cumul Float Cumulative distance at each point of the Route/Track

Elevation object

Property Type Description
max Float Maximum elevation
min Float Minimum elevation
pos Float Positive elevation difference
neg Float Negative elevation difference
avg Float Average elevation

Author object

Property Type Description
name String Author name
email Email object Email address of the author
link Link object Web address

Email object

Property Type Description
id String Email id
domain String Email domain

Link object

Property Type Description
href String Web address
text String Link text
type String Link type
You can’t perform that action at this time.