Gpx

0.2.0

Swift package that implements the GPS Exchange Format (GPX) as a struct that is Codable
fjagerman/Gpx

What's New

v0.2.0

2021-12-29T20:39:12Z

Change let attributes to var

Gpx

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.

dependencies: [
    .package(url: "https://github.com/fjagerman/Gpx.git", from: "0.1.0")
]

If you're using XMLCoder in an app built with Xcode, you can also add it as a direct dependency using Xcode's GUI.

GPX schema version 1.1 - For more information on GPX and this schema, visit http://www.topografix.com/gpx.asp

GPX uses the following conventions: all coordinates are relative to the WGS84 datum. All measurements are in metric units.

<style>th { text-align: left; }</style>

Generated XML Schema (.xsd) documentation

Element

Name Type Annotation/documentation
gpx gpxType GPX is the root element in the XML file.

SimpleTypes

Name Base Constraints Annotation/documentation
latitudeType xsd:decimal -90.0 <= x <= 90.0 The latitude of the point. Decimal degrees, WGS84 datum.
longitudeType xsd:decimal -180.0 <= x The longitude of the point. Decimal degrees, WGS84 datum.
degreesType xsd:decimal 0.0 <= x Used for bearing, heading, course. Units are decimal degrees, true (not magnetic).
fixType xsd:string Elements: none, 2d, 3d, dgps, pps Type of GPS fix. none means GPS had no fix. To signify "the fix info is unknown, leave out fixType entirely. pps = military signal used
dgpsStationType xsd:integer 0 <= x <= 1023 Represents a differential GPS station.

Overview of Complex Types

Name annotation/documentation
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.
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.
wptType wpt represents a waypoint, point of interest, or named feature on a map.
rteType rte represents route - an ordered list of waypoints representing a series of turn points leading to a destination.
trkType trk represents a track - an ordered list of points describing a path.
extensionsType You can add extend GPX by adding your own elements from another schema here.
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.
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.
linkType A link to an external resource (Web page, digital photo, video clip, etc) with additional information.
emailType An email address. Broken into two parts (id and domain) to help prevent email harvesting.
personType A person or organization.
ptType A geographic point with optional elevation and time. Available for use by other schemas.
ptsegType An ordered sequence of points. (for polygons or polylines, e.g.)
boundsType 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.

No elements
Attributes
Name Type Use fixed Annotation/documentation
minlat latitudeType required The minimum latitude.
minlon longitudeType required The minimum longitude.
maxlat latitudeType required The maximum latitude.
maxlon longitudeType required The maximum longitude.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

Last updated: Wed Apr 03 2024 11:52:40 GMT-0900 (Hawaii-Aleutian Daylight Time)