Package globus.glmap

Class GLMapTrackData

java.lang.Object
globus.glmap.GLNativeObject
globus.glmap.GLMapTrackData

@ParametersAreNonnullByDefault
public class GLMapTrackData
extends GLNativeObject
GLMapTrackData holds data for track
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static interface  GLMapTrackData.PointsCallback
    Callback for filling track data
  • Constructor Summary

    Constructors
    Constructor Description
    GLMapTrackData​(GLMapTrackData.PointsCallback pointsCallback, int size)
    Constructor with callback
    GLMapTrackData​(java.util.List data)
    Constructor from raw data
  • Method Summary

    Modifier and Type Method Description
    GLMapTrackData copyTrackAndAddGeoPoint​(double lat, double lon, int color, boolean startNewSegment)
    Copies points to new track and add new point to track.
    GLMapTrackData copyTrackAndAddPoint​(double x, double y, int color, boolean startNewSegment)
    Copies points to new track and add new point to track.
    MapPoint findNearestPoint​(GLMapView mapView, MapPoint point, double distanceInPoints)
    Calculates nearest point on track from given point
    GLMapBBox getBBox()
    Retrurns bbox of track
    int getByteCount()
    Size of internal data of GLMapTrackData.
    static 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

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GLMapTrackData

      public GLMapTrackData​(GLMapTrackData.PointsCallback pointsCallback, int size)
      Constructor with callback
      Parameters:
      pointsCallback - callback that will provide information about points
      size - number of points in track
    • GLMapTrackData

      public GLMapTrackData​(java.util.List data)
      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 callback
      x - x coordinate of point
      y - y coordinate of point
      color - 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 callback
      lat - latitude of point
      lon - longitude of point
      color - color of track at this point
    • getByteCount

      public int getByteCount()
      Size of internal data of GLMapTrackData.
      Returns:
      Size of internal data of GLMapTrackData.
    • getBBox

      @NonNull public GLMapBBox getBBox()
      Retrurns bbox of track
      Returns:
      bbox of track
    • 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 coordinate
      y - y coordinate
      color - color at point
      startNewSegment - 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 coordinate
      lon - longitude coordinate
      color - color at point
      startNewSegment - If YES new segment will be created
      Returns:
      A new track data object
    • findNearestPoint

      @Nullable public MapPoint findNearestPoint​(GLMapView mapView, MapPoint point, double distanceInPoints)
      Calculates nearest point on track from given point
      Parameters:
      mapView - MapView where track is displayed
      point - Point from where calculate nearest point
      distanceInPoints - maximum distance from track in points
      Returns:
      nearest point on track from given point or null if track is too far from given point