Package globus.glmap

Class GLMapTrackData

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

public class GLMapTrackData extends GLNativeObject
GLMapTrackData holds data for track
  • Constructor Details

    • GLMapTrackData

      public GLMapTrackData(@NonNull 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(@NonNull List<byte[]> 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
    • 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 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(@NonNull GLMapViewRenderer mapView, @NonNull 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
    • pointAtLineDistance

      @NonNull public MapPoint pointAtLineDistance(double distance)
      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 test
      nearestPoint - nearest point on line
      maxDistance - max distance from line in projected units
      Returns:
      line distance to point or NAN