GPXRoot
public final class GPXRoot : GPXElement, Codable
Creation of a GPX file or GPX formatted string starts here
GPXRoot holds all metadata, waypoints, tracks, routes and extensions types together before being packaged as a GPX file, or formatted as per GPX schema’s requirements.
-
GPX version that will be generated.
Declaration
Swift
public var version: String -
Name of the creator of the GPX content.
Can be your name or your app’s name
Declaration
Swift
public var creator: String? -
Metadata to be included in your GPX content.
Declaration
Swift
public var metadata: GPXMetadata? -
Array of waypoints
Declaration
Swift
public var waypoints: [GPXWaypoint] -
Array of routes
Declaration
Swift
public var routes: [GPXRoute] -
Array of tracks
Declaration
Swift
public var tracks: [GPXTrack] -
Items for extensions to GPX schema (if any)
leave it as is, if used without modification to GPX schema
Declaration
Swift
public var extensions: GPXExtensions?
-
for initializing without a creator name
It will initialize with the creator name set to its defaults.
Declaration
Swift
public required init() -
for initializing with a creator name
Declaration
Swift
public init(creator: String)Parameters
creatorname of your app, or whichever product that ends up generating a GPX file
-
Initialize if planned to use with extensions
Declaration
Swift
public init(withExtensionAttributes attributes: [String : String], schemaLocation: String)Parameters
attributesExtension attributes to be placed in the gpx tag header. Key should be name of attribute, while Value contains the value of the attribute.
schemaLocationLocation/Website of the extension schema
-
Initialize if planned to use with extensions, with creator name.
Declaration
Swift
public convenience init(withExtensionAttributes attributes: [String : String], schemaLocation: String, creator: String) -
for saving newly tracked data straight to a GPX file in a directory
Throws
An error if GPX file fails to write at
locationfor whichever reason.Declaration
Swift
public func outputToFile(saveAt location: URL, fileName: String) throwsParameters
locationA
URLwhere you wish to have the GPX file saved at.fileNameThe name of the file which you wish to save as, without extension.
-
Initializes a new
waypointwhich is also added toGPXRootautomaticallyA waypoint is initialized with latitude and longitude, then added into the array of waypoints in this
GPXRoot.Warning
This method is not recommended. It is recommended that you initialize a waypoint first, configure it, and use method
add(waypoint:)instead.Declaration
Swift
public func newWaypointWith(latitude: Double, longitude: Double) -> GPXWaypointParameters
latitudeWaypoint’s latitude in
DoubleorCLLocationDegreeslongitudeWaypoint’s latitude in
DoubleorCLLocationDegreesReturn Value
A
GPXWaypointobject. -
Add a pre-initialized and configured waypoint to
GPXRootDeclaration
Swift
public func add(waypoint: GPXWaypoint?)Parameters
waypointThe waypoint that you wish to include in
GPXRoot -
Add an array of pre-initialized and configured waypoints to
GPXRootDeclaration
Swift
public func add(waypoints: [GPXWaypoint])Parameters
waypointsArray of waypoints that you wish to include in
GPXRoot -
Removes an already added waypoint from
GPXRootDeclaration
Swift
public func remove(waypoint: GPXWaypoint)Parameters
waypointThe waypoint that you wish to remove from
GPXRoot -
Remove waypoint from root’s array at index.
Declaration
Swift
public func remove(WaypointAtIndex index: Int) -
Initializes a new
routewhich is also added toGPXRootautomaticallyA route is initialized, then added into the array of routes in this
GPXRoot.Warning
This method is not recommended. It is recommended that you initialize a route first, configure it, and use method
add(route:)instead.Declaration
Swift
public func newRoute() -> GPXRouteReturn Value
A
GPXRouteobject. -
Add a pre-initialized and configured route to
GPXRootDeclaration
Swift
public func add(route: GPXRoute?)Parameters
routeThe route that you wish to include in
GPXRoot -
Add an array of pre-initialized and configured routes to
GPXRootDeclaration
Swift
public func add(routes: [GPXRoute])Parameters
routesThe array of routes that you wish to include in
GPXRoot -
Removes an already added waypoint from
GPXRootDeclaration
Swift
public func remove(route: GPXRoute)Parameters
routeThe route that you wish to remove from
GPXRoot -
Initializes a new
trackwhich is also added toGPXRootautomaticallyA track is initialized, then added into the array of tracks in this
GPXRoot.Warning
This method is not recommended. It is recommended that you initialize a track first, configure it, and use method
add(track:)instead.Declaration
Swift
public func newTrack() -> GPXTrackReturn Value
A
GPXTrackobject. -
Add a pre-initialized and configured track to
GPXRootDeclaration
Swift
public func add(track: GPXTrack?)Parameters
trackThe track that you wish to include in
GPXRoot -
Add an array of pre-initialized and configured tracks to
GPXRootDeclaration
Swift
public func add(tracks: [GPXTrack])Parameters
tracksThe array of tracks that you wish to include in
GPXRoot -
Removes an already added track from
GPXRootDeclaration
Swift
public func remove(track: GPXTrack)Parameters
trackThe track that you wish to remove from
GPXRoot
View on GitHub
GPXRoot Class Reference