GPXDocument

public class GPXDocument
extension GPXDocument: NativeBase
extension GPXDocument: Hashable

Use the GPXDocument to load the GPX file. Only track data is used from the GPX file format (see trkType at https://www.topografix.com/GPX/1/1/#type_trkType). Any unknown elements in the file are ignored. Any known element with an invalid value returns an error. Elevation values are ignored.

  • Create a GPX document from a file.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init(gpxFilePath: String, options: GPXOptions) throws

    Parameters

    gpxFilePath

    The path to the GPX file.

    options

    The options to customize reading.

  • Create a GPX document from a list of GPX tracks.

    Declaration

    Swift

    public init(tracks: [GPXTrack])

    Parameters

    tracks

    The list of tracks.

  • The tracks stored in this GPX document.

    Declaration

    Swift

    public var tracks: [GPXTrack] { get }
  • Create a GPX document from a string.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public static func fromString(content: String, options: GPXOptions) throws -> GPXDocument

    Parameters

    content

    The content of a GPX file as string.

    options

    The options to customize reading.

    Return Value

    An GPXDocument instance.

  • Saves the document to a file. For saving the GPXDocument.tracks modification before writing to a file, use GPXTrackWriter.

    Declaration

    Swift

    public func save(gpxFilePath: String) -> Bool

    Parameters

    gpxFilePath

    The file path where the GPX document will be saved.

    Return Value

    True if the document has been saved successfully. False if an error has been happened during saving.

  • Add track to GPX document.

    Declaration

    Swift

    public func addTrack(trackToAdd: GPXTrack)

    Parameters

    trackToAdd

    track to add to GPX document