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
GLMapTrackDatawith a great-circle line fromstarttoend. 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
colorTrack color.
startStart point (geographic coordinates).
endEnd point (geographic coordinates).
qualityMaximum distance from the point to the line, used for simplification in the Douglas–Peucker algorithm. Units are map internal coordinates.
-
Initializes
GLMapTrackDatawith 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
pointsTrack points (internal map coordinates).
countNumber of points in the array.
Return Value
A new track data object.
-
Initializes
GLMapTrackDatawith points returned bypointsCallback.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
pointsCallbackCallback block used to provide track points.
countNumber of times callback is called. If 0, callback is called until it returns
NO.reverseIf
YES, reverses track direction.Return Value
A new track data object.
-
Copies points from given
GLMapTrackDataand merges segments if needed.Declaration
Objective-C
- (instancetype _Nullable)initWithData:(GLMapTrackData *_Nonnull)data mergeSegments:(BOOL)mergeSegments;Swift
init?(data: GLMapTrackData, mergeSegments: Bool)Parameters
dataSource object with points
mergeSegmentsIf YES, it tries to merge line segments into single line during construction. Otherwise it just retains
datacontents.Return Value
A new track data object
-
Copies points from the given
GLMapTrackDataand 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
dataSource object with points
ptNew point to be added
startNewSegmentIf
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
- (BOOL)isEmpty;Swift
func isEmpty() -> BoolReturn Value
YESif the track has no points. -
Declaration
Objective-C
- (size_t)segmentCount;Swift
func segmentCount() -> IntReturn Value
Number of segments inside this
GLMapTrackData. -
Calculates total length of the track geometry.
Declaration
Objective-C
- (double)calculateLength;Swift
func calculateLength() -> DoubleReturn 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>) -> UInt32Parameters
locationsDistances from the start of the track (in internal map units).
countNumber of points to sample.
resultOutput: 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>?) -> DoubleParameters
pointReference point (internal map coordinates).
nearestPointOutput: 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) -> GLMapPointParameters
distancedistance 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) -> DoubleParameters
pointPoint to test (internal map coordinates).
nearestPointOutput: nearest point on the track (required).
maxDistanceMaximum distance from the track in internal map units.
Return Value
Distance from the start of the track to
nearestPoint, in meters, orNANif nothing is withinmaxDistance.
Install in Dash