[160] This specification defines how to parse GPX files.
[9] A data set has
name,
description,
keywords,
generator,
timestamp,
updated,
author,
license,
minimum latitude,
minimum longitude,
maximum latitude,
maximum longitude,
and
time-zone offset,
which are initially null
.
[19] A data set has waypoints, routes, tracks, and links, which are initially empty lists.
[26] A point has
name,
description,
timestamp,
latitude,
longitude,
elevation,
geoid height,
magnetic variation,
comment,
source,
symbol name,
type,
fix,
number of satellites,
hdop,
vdop,
age of DGPS data,
DGPS ID,
speed,
accuracy,
temperature,
water temperature,
depth,
cadence,
distance,
to distance,
heartrate,
point role,
power,
and
road type,
which are initially null
.
[189] A route has links, which is initially an empty list.
[45] A route has
name,
description,
comment,
source,
type,
and
number,
which are initially null
.
[62] A route has points and links, which are initially empty lists.
[72] A track has
name,
description,
comment,
source,
type,
and
number,
which are initially null
.
[73] A track has segments and links, which are initially empty lists.
[74] A track segment has points, which is initially an empty list.
[43] A person has
name
and
email,
which are initially null
.
[207] A person has links, which is initially an empty list.
[51] A license has
holder,
year, and
URL,
which are initially null
.
[202] A link has
URL,
MIME type,
and
text,
which are initially null
.
[188] A track is a valid timestamped route if all of the following conditions are true:
null
.[206] An implementation MUST use an XML parser that implements XML5 to parse a GPX file. It MUST NOT fetch and process external entities.
[159] An implementation MUST
use the steps to parse a GPX document to parse a Document
as
a GPX document.
[1] To parse a GPX document doc, run these steps:
gpx
:gpx
element element.[10] To parse a gpx
element element, run these steps:
creator
attribute value.null
and is not the empty string:tzoffset
attribute value in the GPX extension namespace.null
and is not the empty string:metadata
local name | Field | Rule |
---|---|---|
name | name | String |
desc | description | String |
keywords | keywords | String |
link | links | Link |
author | author | Person |
copyright | license | License |
time
:http://www.topografix.com/GPX/gpx_modified/0/1
:null
:null
:bounds
:null
:minlat
attribute value.null
:minlon
attribute value.null
:maxlat
attribute value.null
:maxlon
attribute value.wpt
rte
trk
[27] To parse a point element element, run these steps:
lat
attribute value.lon
attribute value.road
attribute value in the GPX extension namespace.pointrole
attribute value in the GPX extension namespace.todistance
attribute value in the GPX extension namespace.null
:local name | Field | Rule |
---|---|---|
sat | number of satellites | Non-negative number |
dgpsid | DGPS ID | Non-negative integer |
ele | elevation | Number |
geoidheight | geoid height | Number |
hdop | hdop | Number |
vdop | vdop | Number |
pdop | pdop | Number |
ageofdgpsdata | age of DGPS data | Number |
speed | speed | Number |
magvar | magnetic variation | Degree |
time | timestamp | Time |
name | name | String |
desc | description | String |
cmt | comment | String |
src | source | String |
sym | symbol name | String |
type | type | String |
fix | fix | String |
link | links | Link |
extensions
:[52] To parse a route element element, run these steps:
local name | Field | Rule |
---|---|---|
name | name | String |
desc | description | String |
cmt | comment | String |
src | source | String |
type | type | String |
number | number | Non-negative number |
link | links | Link |
rtept
:[63] To parse a track element element, run these steps:
local name | Field | Rule |
---|---|---|
name | name | String |
desc | description | String |
cmt | comment | String |
src | source | String |
type | type | String |
number | number | Non-negative number |
link | links | Link |
trkseg
:trkpt
:[105] The rules for parsing a latitude value text are as given in the following algorithm:
[110] The rules for parsing a longitude value text are as given in the following algorithm:
[153] To process a value element element with object and table, run these steps:
null
, abort these steps.href
attribute value.[166] A GPX MIME types is any MIME type whose essence is one of the following:
[168]
When an implementation uses a MIME type to identify GPX,
it MUST use application/gpx+xml
.
[169]
When an implementation interprets a MIME type,
it MUST recognize any GPX MIME type as equivalent to
application/gpx+xml
.
[173]
The GPX namespace is
http://www.topografix.com/GPX/1/1
.
[174]
The GPX 1.0 namespace
is
http://www.topografix.com/GPX/1/0
.
The GPX 1.0 namespace
MUST NOT be used.
[172]
The gpx
element in the GPX namespace
MAY
have a tzoffset
attribute
in the GPX extension namespace.
If specified,
its value
MUST
be a
valid time-zone offset string.
It is the time-zone offset that is appropriate as
the default time-zone offset
for rendering timestamps in the element.
[214]
The wpt
element in the GPX namespace
MAY
have a pointrole
attribute
in the GPX extension namespace.
If specified,
its value
MUST
be a
valid point role string.
It is the kind of the point in the context of a race (or similar) event
described by the document.
[215] A valid point role string is one of followings:
String | Description |
---|---|
globalStart | The first start point of the race. |
globalGoal | The last goal point of the race. |
partialStart | The start point of one of the subsections of the entire route of the race (which is not categorized as globalStart ). |
partialGoal | The goal point of one of the subsections of the entire route of the race (which is not categorized as globalGoal ). |
checkpoint | One of intermediate points during the route of the race which serves a remarkable role in the race, typically known as aid station, checkpoint, or gate. |
observer | A point that does not belong to any other kind. |
[216] How to use these roles, including how points are associated with the routes in the same document, are application dependent.
[217]
An application might impose additional context-specific constraints
for GPX document it handles. For example, an application
might require that the first point in the route
has to be the same location with the point whose
pointrole
is globalStart
.
[175]
The trkpt
element in the GPX namespace
MAY
have a road
attribute
in the GPX extension namespace.
If specified,
its value
MUST
be a
valid road type string.
It is the kind or condition of the road
at the point of the element.
[176] A valid road type string is one of followings:
String | Description |
---|---|
p | A road paved by e.g. concrete or asphalt |
d | A dirt road |
u | A completely unpaved path |
[35]
The trkpt
element in the GPX namespace
MAY
have a todistance
attribute
in the GPX extension namespace.
If specified,
its value
MUST
be a
valid floating-point number
that
parses
to a number greater than or equal to 0.
It is the distance between this
and the previous
points (i.e. the points represented by this and the nearest previous sibling
trkpt
elements in the GPX namespace),
in meters.
If there is no previous point,
the number MUST be equal to 0.
If the distance is not known,
the attribute MUST NOT be specified.
[209] To determine the distance between track points point1 and point2, run these steps:
null
:[208] The term meter https://www.bipm.org/en/publications/si-brochure/metre.html is defined by the SI Brochure: The International System of Units (SI).
[165] This specification depends on the Infra Standard. The terms list, append, contains, for each, size, and is empty, are defined by the Infra Standard.
[167] The terms MIME type and essence are defined by the MIME Sniffing Standard.
[5] The terms
previous sibling,
element, attribute,
value,
Document
,
document element,
node document,
children, local name,
and namespace are defined by the DOM Standard.
[34] The terms ASCII digits, rules for parsing non-negative integers, valid floating-point number, rules for parsing floating-point number values, parse a global date and time string, child text content, valid time-zone offset string, parse a time-zone offset string, parse a URL, resulting URL string, and XML parser, are defined by the HTML Standard.
[178] Elements in the GPX namespace and its attributes are defined by the GPX specification https://www.topografix.com/gpx.asp.
[177] There are JSON data files:
[348] Test data are available at: https://github.com/wakaba/tests-web/tree/master/gpx/parsing.
[347] Per CC0 https://creativecommons.org/publicdomain/zero/1.0/, to the extent possible under law, the author of this specification has waived all copyright and related or neighboring rights to this specification.
[349] There are implementations:
https://manakai.github.io/pod/Web/GPX/Parser (Perl),
https://github.com/wakaba/js-gpx-parser (JavaScript js-gpx-parser