GPS Exchange Format (GPX)¶
GPX (the GPS Exchange Format) is a light-weight XML data format containing GPS data (waypoints, routes, and tracks). For more information see the official GPX site.
File listing¶
All waypoints, routes, and tracks are stored in a single .gpx file.
Data Access / Connection Method¶
GPX access is available through OGR. See the OGR driver page for specific driver information.
A relative path to the .gpx file can be used in the mapfile LAYER’s CONNECTION string.
- The feature type is specified in the DATA parameter
the “tracks” feature type will usually be the track line
the “track_points” feature type will usually be the points that make up the track line
OGRINFO Examples¶
First you should make sure that your GDAL/OGR build contains the “GPX” driver, by using the ‘–formats’ command:
>ogrinfo --formats
Loaded OGR Format Drivers:
...
-> "CSV" (read/write)
-> "GML" (read/write)
-> "GPX" (read/write)
-> "KML" (read/write)
...
If you don’t have the driver, you might want to try the FWTools or MS4W packages, which include the driver.
Once you have the GPX driver you are ready to try an ogrinfo command on your file to get a list of feature types:
>ogrinfo test.gpx
INFO: Open of `test.gpx'
using driver `GPX' successful.
1: waypoints (Point)
2: routes (Line String)
3: tracks (Multi Line String)
4: route_points (Point)
5: track_points (Point)
Now use ogrinfo to get information on one of the feature types:
>ogrinfo test.gpx track_points -summary
INFO: Open of `test.gpx'
using driver `GPX' successful.
Layer name: track_points
Geometry: Point
Feature Count: 661
Extent: (-66.694270, 47.985570) - (-66.675222, 47.990791)
Layer SRS WKT:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.01745329251994328,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
track_fid: Integer (0.0)
track_seg_id: Integer (0.0)
track_seg_point_id: Integer (0.0)
ele: Real (0.0)
time: DateTime (0.0)
magvar: Real (0.0)
geoidheight: Real (0.0)
name: String (0.0)
cmt: String (0.0)
desc: String (0.0)
src: String (0.0)
...
Mapfile Example¶
Since you have confirmed that OGR can read your GPX file, now you can create a MapServer layer:
LAYER
NAME "gpx"
TYPE POINT
STATUS ON
CONNECTIONTYPE OGR
CONNECTION test.gpx
DATA "track_points"
CLASS
NAME "gpx"
STYLE
SYMBOL 'circle'
COLOR 0 119 255
SIZE 2
END
END
END # layer