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
GLMapTrackDatawith big 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
endEnd point
qualityMaximum distance from point to line, used for simplification in Douglas Peucker algorithm. Units is map internal coordinates.
-
Initalizes
GLMapTrackDatawith array of pointsDeclaration
Objective-C
- (instancetype _Nullable)initWithPoints:(const GLTrackPoint *_Nonnull)points count:(NSUInteger)count;Swift
init?(points: UnsafePointer<GLTrackPoint>, count: UInt)Parameters
pointsTrack point array
countSize of point array
Return Value
A new track data object
-
Initializes
GLMapTrackDatawith points that retured bypointsCallbackDeclaration
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 fill track points data
countNumber of times callback is called. If zero callback will be called until it will return NO
reverseReverse track direction if true
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 given
GLMapTrackDataand 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
dataSource object with points
ptNew point to be added
startNewSegmentIf 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
- (BOOL)isEmpty;Swift
func isEmpty() -> BoolReturn Value
YESif track have no points -
Declaration
Objective-C
- (size_t)segmentCount;Swift
func segmentCount() -> IntReturn Value
Count of lines inside this GLMapTrackData
-
Calculate length of all track segments
Declaration
Objective-C
- (double)calculateLength;Swift
func calculateLength() -> DoubleReturn 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>) -> UInt32Parameters
locationslocations where to sample track (distances from start of track)
countnumber of points to sample
resultresult 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>?) -> DoubleParameters
pointrefrence point to calculate distance
nearestPointnearestPoint 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) -> GLMapPointParameters
distancedistance 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) -> DoubleParameters
pointPoint to test
nearestPointnearest point on line
maxDistancemax distance from line in projected units
Return Value
line distance to point or NAN
Install in Dash