Gpx is a generated swift package. It provides a struct that conforms to the Codable protocol. The implemtation is build on top of the XMLCoder package provided by Max Desiatov.
Installation
Only Swift Package Manager is described here.
Including Gpx in a swift package
Once you have your Swift package set up, add Gpx as a dependency by adding it to the dependencies value of your Package.swift.
GPX documents contain a metadata header, followed by waypoints, routes, and tracks. You can add your own elements
to the extensions section of the GPX document.
Information about the GPX file, author, and copyright restrictions goes in the metadata section. Providing rich,
meaningful information about your GPX files allows others to search for and use your GPS data.
A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data.
Information about the copyright holder and any license governing use of this file. By linking to an appropriate license,
you may place your data into the public domain or grant additional usage rights.
Two lat/lon pairs defining the extent of an element.
Definition of Complex Types
Complextype gpxType
GPX documents contain a metadata header, followed by waypoints, routes, and tracks. You can add your own elements
to the extensions section of the GPX document.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
metadata
metadataType
0
Metadata about the file.
wpt
wptType
0
unbounded
A list of waypoints.
rte
rteType
0
unbounded
A list of routes.
trk
trkType
0
unbounded
A list of tracks.
extensions
extensionsType
0
You can add extend GPX by adding your own elements from another schema here.
Attributes
Name
Type
Use
fixed
Annotation/documentation
version
xsd:string
required
1.1
You must include the version number in your GPX document.
creator
xsd:string
required
You must include the name or URL of the software that created your GPX document. This allows others to
inform the creator of a GPX instance document that fails to validate.
Complextype metadataType
Information about the GPX file, author, and copyright restrictions goes in the metadata section. Providing rich,
meaningful information about your GPX files allows others to search for and use your GPS data.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
name
xsd:string
0
The name of the GPX file.
desc
xsd:string
0
A description of the contents of the GPX file.
author
personType
0
The person or organization who created the GPX file.
copyright
copyrightType
0
Copyright and license information governing use of the file.
link
linkType
0
unbounded
URLs associated with the location described in the file.
time
xsd:dateTime
0
The creation date of the file.
keywords
xsd:string
0
Keywords associated with the file. Search engines or databases can use this information to classify the data.
bounds
boundsType
0
Minimum and maximum coordinates which describe the extent of the coordinates in the file.
extensions
extensionsType
0
You can add extend GPX by adding your own elements from another schema here.
No attributes
Complextype wptType
wpt represents a waypoint, point of interest, or named feature on a map.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
ele
xsd:decimal
0
Elevation (in meters) of the point.
time
xsd:dateTime
0
Creation/modification timestamp for element. Date and time in are in Univeral Coordinated Time (UTC), not local time! Conforms to ISO 8601 specification for date/time representation. Fractional seconds are allowed for millisecond timing in tracklogs.
magvar
degreesType
0
Magnetic variation (in degrees) at the point
geoidheight
xsd:decimal
0
Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message.
name
xsd:string
0
The GPS name of the waypoint. This field will be transferred to and from the GPS. GPX does not place restrictions on the length of this field or the characters contained in it. It is up to the receiving application to validate the field before sending it to the GPS.
cmt
xsd:string
0
GPS waypoint comment. Sent to GPS as comment.
desc
xsd:string
0
A text description of the element. Holds additional information about the element intended for the user, not the GPS.
src
xsd:string
0
Source of data. Included to give user some idea of reliability and accuracy of data. "Garmin eTrex", "USGS quad Boston North", e.g.
link
linkType
0
unbounded
Link to additional information about the waypoint.
sym
xsd:string
0
Text of GPS symbol name. For interchange with other programs, use the exact spelling of the symbol as displayed on the GPS. If the GPS abbreviates words, spell them out.
type
xsd:string
0
Type (classification) of the waypoint.
fix
fixType
0
Type of GPX fix.
sat
xsd:nonNegativeInteger
0
Number of satellites used to calculate the GPX fix.
hdop
xsd:decimal
0
Horizontal dilution of precision.
vdop
xsd:decimal
0
Vertical dilution of precision.
pdop
xsd:decimal
0
Position dilution of precision.
ageofdgpsdata
xsd:decimal
0
Number of seconds since last DGPS update.
dgpsid
dgpsStationType
0
ID of DGPS station used in differential correction.
extensions
extensionsType
0
You can add extend GPX by adding your own elements from another schema here.
Attributes
Name
Type
Use
fixed
Annotation/documentation
lat
latitudeType
required
The latitude of the point. This is always in decimal degrees, and always in WGS84 datum.
lon
longitudeType
required
The longitude of the point. This is always in decimal degrees, and always in WGS84 datum.
Complextype rteType
rte represents route - an ordered list of waypoints representing a series of turn points leading to a destination.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
name
xsd:string
0
GPS name of route.
cmt
xsd:string
0
GPS comment for route.
desc
xsd:string
0
Text description of route for user. Not sent to GPS.
src
xsd:string
0
Source of data. Included to give user some idea of reliability and accuracy of data.
link
linkType
0
unbounded
Links to external information about the route.
number
xsd:nonNegativeInteger
0
GPS route number.
type
xsd:string
0
Type (classification) of route.
extensions
extensionsType
0
You can add extend GPX by adding your own elements from another schema here.
rtept
wptType
0
unbounded
A list of route points.
No attributes
Complextype trkType
trk represents a track - an ordered list of points describing a path.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
name
xsd:string
0
GPS name of track.
cmt
xsd:string
0
GPS comment for track.
desc
xsd:string
0
User description of track.
src
xsd:string
0
Source of data. Included to give user some idea of reliability and accuracy of data.
link
linkType
0
unbounded
Links to external information about track.
number
xsd:nonNegativeInteger
0
GPS track number.
type
xsd:string
0
Type (classification) of track.
extensions
extensionsType
0
You can add extend GPX by adding your own elements from another schema here.
trkseg
trksegType
0
unbounded
A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data.
No attributes
Complextype extensionsType
You can add extend GPX by adding your own elements from another schema here.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
No attributes
Complextype trksegType
A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
trkpt
wptType
0
unbounded
A Track Point holds the coordinates, elevation, timestamp, and metadata for a single point in a track.
extensions
extensionsType
0
You can add extend GPX by adding your own elements from another schema here.
No attributes
Complextype copyrightType
Information about the copyright holder and any license governing use of this file. By linking to an appropriate license,
you may place your data into the public domain or grant additional usage rights.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
year
xsd:gYear
0
Year of copyright.
license
xsd:anyURI
0
Link to external file containing license text.
Attributes
Name
Type
Use
fixed
Annotation/documentation
author
xsd:string
required
Copyright holder (TopoSoft, Inc.)
Complextype linkType
A link to an external resource (Web page, digital photo, video clip, etc) with additional information.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
text
xsd:string
0
Text of hyperlink.
type
xsd:string
0
Mime type of content (image/jpeg)
Attributes
Name
Type
Use
fixed
Annotation/documentation
href
xsd:anyURI
required
URL of hyperlink.
Complextype emailType
An email address. Broken into two parts (id and domain) to help prevent email harvesting.
No elements
Attributes
Name
Type
Use
fixed
Annotation/documentation
id
xsd:string
required
id half of email address (billgates2004)
domain
xsd:string
required
domain half of email address (hotmail.com)
Complextype personType
A person or organization.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
name
xsd:string
0
Name of person or organization.
email
emailType
0
Email address.
link
linkType
0
Link to Web site or other external information about person.
No attributes
Complextype ptType
A geographic point with optional elevation and time. Available for use by other schemas.
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
ele
xsd:decimal
0
The elevation (in meters) of the point.
time
xsd:dateTime
0
The time that the point was recorded.
Attributes
Name
Type
Use
fixed
Annotation/documentation
lat
latitudeType
required
The latitude of the point. Decimal degrees, WGS84 datum.
lon
longitudeType
required
The latitude of the point. Decimal degrees, WGS84 datum.
Complextype ptsegType
An ordered sequence of points. (for polygons or polylines, e.g.)
Elements
Name
Type
Min Occurs
Max Occurs
Annotation/documentation
pt
ptType
0
unbounded
Ordered list of geographic points.
No attributes
Complextype boundsType
Two lat/lon pairs defining the extent of an element.