GLMapTrackData

Objective-C


@interface GLMapTrackData : NSObject

Swift

class GLMapTrackData : NSObject

GLMapTrackData class holds data for track and information to optimize draw at different zoom levels. Data stored without connection to mapView and could be added on different GLMapView at the same time.

  • Unavailable

    Please use inits with data.

    Not used.

    Declaration

    Objective-C

    - (instancetype _Nonnull)init;
  • Initalizes GLMapTrackData with big 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

    end

    End point

    quality

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

  • Initalizes GLMapTrackData with 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 point array

    count

    Size of point array

    Return Value

    A new track data object

  • Initializes GLMapTrackData with points that retured by pointsCallback

    Declaration

    Objective-C

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

    Swift

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

    Parameters

    pointsCallback

    Callback block used to fill track points data

    count

    Number of times callback is called. If zero callback will be called until it will return NO

    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 given GLMapTrackData and add new point to track. When frequently updated track is displayed is a good idea to add new points into small segments. Up to 100 points per segment. And then merge segments together. Track uses optimized Ramer-Douglas-Peucker, but it’s still can have O(n^2) complexity in worst case. With described solution GLMap could record tracks up to 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 new segment will be created

    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 track

  • Declaration

    Objective-C

    - (BOOL)isEmpty;

    Swift

    func isEmpty() -> Bool

    Return Value

    YES if track have no points

  • Declaration

    Objective-C

    - (size_t)segmentCount;

    Swift

    func segmentCount() -> Int

    Return Value

    Count of lines inside this GLMapTrackData

  • Calculate length of all track segments

    Declaration

    Objective-C

    - (double)calculateLength;

    Swift

    func calculateLength() -> Double

    Return Value

    length of all segments

  • Sample track at locations

    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

    locations where to sample track (distances from start of track)

    count

    number of points to sample

    result

    result of sampling

  • Find nearest point to track and return progressIndex

    Declaration

    Objective-C

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

    Swift

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

    Parameters

    point

    refrence point to calculate distance

    nearestPoint

    nearestPoint on track or nil if not needed

    Return Value

    progressIndex of nearest point

  • Find point at distance form 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 nearest point of object to given point and returns line distance 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

    nearestPoint

    nearest point on line

    maxDistance

    max distance from line in projected units

    Return Value

    line distance to point or NAN