Introduction
GPXParser is a JavaScript library designed to help developers to parse and use data stored with the GPX format.
It allow you to retrieve every data stored in your GPX formatted file by producing an easy to use JavaScript object structure.
Moreover, GPXParser is more than a simple XML parser, it also compute data from positioning and elevation statements to useful numeric data.
GPX Parser retrieve and compute various data :
- Tracks and routes geographic coordinates
- Elevation : gain, lose, average, min, max
- Distance : Total and partial
Start the demo
General metadata
{{ gpxParser.metadata.name }}
{{ gpxParser.metadata.desc }}
{{ gpxParser.metadata.time }}
{{ gpxParser.metadata.author.name }}
{{ gpxParser.metadata.author.email.id }}@{{ gpxParser.metadata.author.email.domain }}
Waypoints
{{ waypoint.name }}
Latitude : {{ waypoint.lat }}
Longitude : {{ waypoint.lon }}
Tracks and Routes
{{ track.name }}
Distance : {{ Math.floor(track.distance.total/1000) }}km
Elevation :
- Avg : {{ Math.floor(track.elevation.avg) }}m
- Max : {{ Math.floor(track.elevation.max) }}m
- Min : {{ Math.floor(track.elevation.min) }}m
- Positive : {{ Math.floor(track.elevation.pos) }}m
- Negative : {{ Math.floor(track.elevation.neg) }}m
How to use ?
Load JavaScript file
<script src="./js/GPXParser.js"></script>
Create and parse GPX
let gpx = new gpxParser(); //Create gpxParser Object
gpx.parse("<xml><gpx></gpx></xml>"); //parse gpx file from string data
Use the gpxParser Object
let totalDistance = gpx.tracks[0].distance.total;
gpx.tracks[0].points.push([lat, lon]);
Export gpxParser Objecto to GEOJson
let geoJSON = gpx.toGeoJSON();