Package globus.glmap
Class GLMapTrackData
java.lang.Object
globus.glmap.GLNativeObject
globus.glmap.GLMapTrackData
GLMapTrackData
holds data for track-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Callback for filling track data -
Constructor Summary
ConstructorDescriptionGLMapTrackData
(GLMapTrackData.PointsCallback pointsCallback, int size) Constructor with callbackGLMapTrackData
(List<byte[]> data) Constructor from raw data -
Method Summary
Modifier and TypeMethodDescriptiondouble
Calculate length of trackcopyTrackAndAddGeoPoint
(double lat, double lon, int color, boolean startNewSegment) Copies points to new track and add new point to track.copyTrackAndAddPoint
(double x, double y, int color, boolean startNewSegment) Copies points to new track and add new point to track.findNearestPoint
(GLMapViewRenderer mapView, MapPoint point, double distanceInPoints) Calculates nearest point on track from given pointgetBBox()
Retrurns bbox of trackint
Size of internal data of GLMapTrackData.double
lineDistanceToPoint
(MapPoint point, MapPoint nearestPoint, double maxDistance) Finds nearest point of object to given point and returns line distance to itpointAtLineDistance
(double distance) Find point at distance form startdouble[]
sample
(double[] locations) Sample track at locationsstatic void
setPointData
(long nativePoint, int x, int y, int color) Sets data for native point.static void
setPointDataGeo
(long nativePoint, double lat, double lon, int color) Sets data for native point.Methods inherited from class globus.glmap.GLNativeObject
dispose
-
Constructor Details
-
GLMapTrackData
Constructor with callback- Parameters:
pointsCallback
- callback that will provide information about pointssize
- number of points in track
-
GLMapTrackData
Constructor from raw data- Parameters:
data
- List of byte arrays with raw data. Each element of this array defines track segment
-
-
Method Details
-
setPointData
public static void setPointData(long nativePoint, int x, int y, int color) Sets data for native point. Coordinates are in internal format- Parameters:
nativePoint
- nativePoint passed to callbackx
- x coordinate of pointy
- y coordinate of pointcolor
- color of track at this point
-
setPointDataGeo
public static void setPointDataGeo(long nativePoint, double lat, double lon, int color) Sets data for native point. Coordinates are in geo format.- Parameters:
nativePoint
- nativePoint passed to callbacklat
- latitude of pointlon
- longitude of pointcolor
- color of track at this point
-
getByteCount
public int getByteCount()Size of internal data of GLMapTrackData.- Returns:
- Size of internal data of GLMapTrackData.
-
getBBox
Retrurns bbox of track- Returns:
- bbox of track
-
calculateLength
public double calculateLength()Calculate length of track- Returns:
- length of track in internal units
-
sample
public double[] sample(double[] locations) Sample track at locations- Parameters:
locations
- locations where to sample track (distances from start of track)- Returns:
- result [x1, y1, dx1, dy1, x2, y2, dx1, dy2, ...]
-
copyTrackAndAddPoint
@NonNull public GLMapTrackData copyTrackAndAddPoint(double x, double y, int color, boolean startNewSegment) Copies points to new track 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.- Parameters:
x
- x coordinatey
- y coordinatecolor
- color at pointstartNewSegment
- If YES new segment will be created- Returns:
- A new track data object
-
copyTrackAndAddGeoPoint
@NonNull public GLMapTrackData copyTrackAndAddGeoPoint(double lat, double lon, int color, boolean startNewSegment) Copies points to new track 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.- Parameters:
lat
- latitude coordinatelon
- longitude coordinatecolor
- color at pointstartNewSegment
- If YES new segment will be created- Returns:
- A new track data object
-
findNearestPoint
@Nullable public MapPoint findNearestPoint(@NonNull GLMapViewRenderer mapView, @NonNull MapPoint point, double distanceInPoints) Calculates nearest point on track from given point- Parameters:
mapView
- MapView where track is displayedpoint
- Point from where calculate nearest pointdistanceInPoints
- maximum distance from track in points- Returns:
- nearest point on track from given point or null if track is too far from given point
-
pointAtLineDistance
Find point at distance form start- Parameters:
distance
- distance in meters- Returns:
- point on line that is located at given distance
-
lineDistanceToPoint
public double lineDistanceToPoint(MapPoint point, @Nullable MapPoint nearestPoint, double maxDistance) Finds nearest point of object to given point and returns line distance to it- Parameters:
point
- Point to testnearestPoint
- nearest point on linemaxDistance
- max distance from line in projected units- Returns:
- line distance to point or NAN
-