GLMapTrackData

Objective-C


@interface GLMapTrackData : NSObject

Swift

class GLMapTrackData : NSObject

GLMapTrackData holds track geometry and precomputed information used to optimize drawing at different zoom levels. Track data is independent of a particular GLMapView and can be used by multiple map views simultaneously.

  • Unavailable

    Please use inits with data.

    Not used.

    Declaration

    Objective-C

    - (instancetype _Nonnull)init;
  • Initializes GLMapTrackData with a great-circle line from start to end. Useful to display plane routes.

    Declaration

    Objective-C

    - (instancetype _Nullable)initWithColor:(GLMapColor)color
                                      start:(GLMapGeoPoint)start
                                        end:(GLMapGeoPoint)end
                                    quality:(double)quality;

    Swift

    init?(color: GLMapColor, start: GLMapGeoPoint, end: GLMapGeoPoint, quality: Double)

    Parameters

    color

    Track color.

    start

    Start point (geographic coordinates).

    end

    End point (geographic coordinates).

    quality

    Maximum distance from the point to the line, used for simplification in the Douglas–Peucker algorithm. Units are map internal coordinates.

  • Initializes GLMapTrackData with an array of points.

    Declaration

    Objective-C

    - (instancetype _Nullable)initWithPoints:(const GLTrackPoint *_Nonnull)points
                                       count:(NSUInteger)count;

    Swift

    init?(points: UnsafePointer<GLTrackPoint>, count: UInt)

    Parameters

    points

    Track points (internal map coordinates).

    count

    Number of points in the array.

    Return Value

    A new track data object.

  • Initializes GLMapTrackData with points returned by pointsCallback.

    Declaration

    Objective-C

    - (instancetype _Nullable)initWithPointsCallback:
                                  (GLMapTrackPointsCallback _Nonnull)pointsCallback
                                               count:(NSUInteger)count
                                             reverse:(BOOL)reverse;

    Swift

    init?(pointsCallback: @escaping GLMapTrackPointsCallback, count: UInt, reverse: Bool)

    Parameters

    pointsCallback

    Callback block used to provide track points.

    count

    Number of times callback is called. If 0, callback is called until it returns NO.

    reverse

    If YES, reverses track direction.

    Return Value

    A new track data object.

  • Copies points from given GLMapTrackData and merges segments if needed.

    Declaration

    Objective-C

    - (instancetype _Nullable)initWithData:(GLMapTrackData *_Nonnull)data
                             mergeSegments:(BOOL)mergeSegments;

    Swift

    init?(data: GLMapTrackData, mergeSegments: Bool)

    Parameters

    data

    Source object with points

    mergeSegments

    If YES, it tries to merge line segments into single line during construction. Otherwise it just retains data contents.

    Return Value

    A new track data object

  • Copies points from the given GLMapTrackData and adds a new point to the track. When displaying a frequently updated track, it is recommended to add new points into small segments (up to ~100 points per segment) and then merge segments together. The track uses an optimized Ramer–Douglas–Peucker algorithm, but it still can have O(n^2) complexity in the worst case. With the described solution, GLMap can record tracks up to a million points.

    Declaration

    Objective-C

    - (instancetype _Nullable)initWithData:(GLMapTrackData *_Nonnull)data
                               andNewPoint:(GLTrackPoint)pt
                           startNewSegment:(BOOL)startNewSegment;

    Swift

    init?(data: GLMapTrackData, andNewPoint pt: GLTrackPoint, startNewSegment: Bool)

    Parameters

    data

    Source object with points

    pt

    New point to be added

    startNewSegment

    If YES, a new segment will be started.

    Return Value

    A new track data object.

  • Creates new copy of track data with merged segments that have same start/end points.

    Declaration

    Objective-C

    - (instancetype _Nullable)trackDataWithMergedSegments;

    Swift

    func withMergedSegments() -> Self?

    Return Value

    A new track data object

  • Declaration

    Objective-C

    - (GLMapBBox)bbox;

    Swift

    func bbox() -> GLMapBBox

    Return Value

    Bounding box of the track (internal map coordinates).

  • Declaration

    Objective-C

    - (BOOL)isEmpty;

    Swift

    func isEmpty() -> Bool

    Return Value

    YES if the track has no points.

  • Declaration

    Objective-C

    - (size_t)segmentCount;

    Swift

    func segmentCount() -> Int

    Return Value

    Number of segments inside this GLMapTrackData.

  • Calculates total length of the track geometry.

    Declaration

    Objective-C

    - (double)calculateLength;

    Swift

    func calculateLength() -> Double

    Return Value

    Length in internal map units (same units as GLMapPointLength).

  • Samples the track at distances from the start.

    Declaration

    Objective-C

    - (uint32_t)sample:(const double *_Nonnull)locations
                 count:(uint32_t)count
                result:(GLTrackSampleResult *_Nonnull)result;

    Swift

    func sample(_ locations: UnsafePointer<Double>, count: UInt32, result: UnsafeMutablePointer<GLTrackSampleResult>) -> UInt32

    Parameters

    locations

    Distances from the start of the track (in internal map units).

    count

    Number of points to sample.

    result

    Output: sampling results (positions in internal map coordinates; direction is a normalized vector).

    Return Value

    Number of points written to result (<= count).

  • Finds the nearest point on the track and returns the corresponding progress index.

    Declaration

    Objective-C

    - (double)findProgressByPoint:(GLMapPoint)point
                     nearestPoint:(GLMapPoint *_Nullable)nearestPoint;

    Swift

    func findProgress(by point: GLMapPoint, nearestPoint: UnsafeMutablePointer<GLMapPoint>?) -> Double

    Parameters

    point

    Reference point (internal map coordinates).

    nearestPoint

    Output: nearest point on the track (optional).

    Return Value

    Progress index of the nearest point (fractional point index).

  • Finds a point at distance from the start

    Declaration

    Objective-C

    - (GLMapPoint)pointAtLineDistance:(double)distance;

    Swift

    func point(atLineDistance distance: Double) -> GLMapPoint

    Parameters

    distance

    distance in meters

    Return Value

    point on line that is located at given distance

  • Finds the nearest point on the track and returns distance from the track start to it.

    Declaration

    Objective-C

    - (double)lineDistanceToPoint:(GLMapPoint)point
                     nearestPoint:(GLMapPoint *_Nonnull)nearestPoint
                      maxDistance:(double)maxDistance;

    Swift

    func lineDistance(to point: GLMapPoint, nearestPoint: UnsafeMutablePointer<GLMapPoint>, maxDistance: Double) -> Double

    Parameters

    point

    Point to test (internal map coordinates).

    nearestPoint

    Output: nearest point on the track (required).

    maxDistance

    Maximum distance from the track in internal map units.

    Return Value

    Distance from the start of the track to nearestPoint, in meters, or NAN if nothing is within maxDistance.