Class GLRoute


public class GLRoute extends GLNativeObject
GLMapRouteData used store route data.
  • Method Details

    • getNumberOfTargetPoints

      public int getNumberOfTargetPoints()
      Returns number of target points
      Returns:
      number of target points
    • getTargetPoint

      public GLRoutePoint getTargetPoint(int index)
      Returns target point
      Parameters:
      index - index of target point
      Returns:
      target point
    • getTrackData

      public GLMapTrackData getTrackData(int trackColor)
      Returns track data that can be used to display track of route
      Parameters:
      trackColor - color of route track
      Returns:
      track data of route
    • getTrackCoordinates

      @Nullable public int[] getTrackCoordinates()
      Returns track coordinates in pairs (x, y) If track contains several lines - (-1, -1) split one segment from other
      Returns:
      track coordinates
    • getLanguage

      @NonNull public String getLanguage()
      Returns language of instructions
      Returns:
      language of instructions
    • getLength

      public double getLength()
      Returns total length of the track
      Returns:
      length of the track in meters
    • getDuration

      public double getDuration()
      Returns estimated duration of the track
      Returns:
      duration of the track in seconds
    • getNumberOfLegs

      public int getNumberOfLegs()
      Returns number of legs
      Returns:
      number of legs
    • getLengthOfLeg

      public double getLengthOfLeg(int index)
      Returns length of leg
      Parameters:
      index - index of leg
      Returns:
      length of leg
    • getDurationOfLeg

      public double getDurationOfLeg(int index)
      Returns duration of leg
      Parameters:
      index - index of leg
      Returns:
      duration of leg
    • getManeuvers

      @NonNull public GLRouteManeuver[] getManeuvers()
      Returns all maneuvers of route
      Returns:
      array of maneuvers
    • getNextManeuver

      @Nullable public GLRouteManeuver getNextManeuver(@NonNull GLRouteManeuver maneuver)
      Returns next maneuver that goes after the given maneuver
      Parameters:
      maneuver - maneuver
      Returns:
      next maneuver after the given maneuver
    • getPreviousManeuver

      @Nullable public GLRouteManeuver getPreviousManeuver(@NonNull GLRouteManeuver maneuver)
      Returns previous maneuver that goes before the given maneuver
      Parameters:
      maneuver - maneuver
      Returns:
      previous maneuver after the given maneuver
    • getFirstManeuver

      @Nullable public GLRouteManeuver getFirstManeuver()
      Returns last maneuver in route
      Returns:
      last maneuver in route
    • getLastManeuver

      @Nullable public GLRouteManeuver getLastManeuver()
      Returns last maneuver in route
      Returns:
      last maneuver in route
    • getHeightData

      @Nullable public GLRouteElevation getHeightData()
      Returns height data that was previously requested for this route
      Returns:
      height data
    • getAlternates

      @NonNull public GLRoute[] getAlternates()
      Alternative routes
      Returns:
      alternative routes
    • ParseFromJSON

      @Nullable public static GLRoute ParseFromJSON(@NonNull String json)
      Creates GLRoute from json String
      Parameters:
      json - json string that was returned by GLRoute#toJSON
      Returns:
      GLMapRouteData or null if data is invalid
    • toJSON

      public String toJSON()
      Serialize route to json
      Returns:
      json string
    • findInsertionIndex

      public static int findInsertionIndex(@NonNull MapPoint pt, @NonNull MapPoint[] points)
      Finds the index where the given point should be inserted into an array of reference points.

      This is commonly used to add a waypoint to a route.

      Parameters:
      pt - At input, the point to insert. At output, the point adjusted to the nearest position on the route.
      points - An array of reference points that define the route.
      Returns:
      The index where the point should be inserted, or -1 if the point is too far from the track.
    • getNextShortInstruction

      @Nullable public String getNextShortInstruction(@NonNull GLRouteManeuver maneuver)
      Retrieves the first non-empty short instruction starting from the specified maneuver to the end of the route.
      Parameters:
      maneuver - The starting GLRouteManeuver for the search.
      Returns:
      The first non-empty short instruction, or null if no such instruction exists.
    • getApproachAlert

      @Nullable public String getApproachAlert(@NonNull String instruction, double distance)
      Adds 'In `distance` `units` ' before instruction
      Parameters:
      instruction - Instruction text
      distance - in meters
      Returns:
      Instruction with approach alert