Package globus.glroute
Class GLRoute
- java.lang.Object
-
- globus.glmap.GLNativeObject
-
- globus.glroute.GLRoute
-
public class GLRoute extends globus.glmap.GLNativeObjectGLMapRouteDataused store route data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGLRoute.BikeTypestatic interfaceGLRoute.Mode
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intfindInsertionIndex(globus.glmap.MapPoint pt, globus.glmap.MapPoint[] points)Finds index where given point must be inserted to array of reference points.GLRoute[]getAlternates()Alternative routesjava.lang.StringgetApproachAlert(java.lang.String instruction, double distance)Adds 'In `distance` `units` ' before instructiondoublegetDuration()Returns estimated duration of the trackdoublegetDurationOfLeg(int index)Returns duration of legGLRouteManeuvergetFirstManeuver()Returns last maneuver in routeGLRouteElevationgetHeightData()Returns height data that was previously requested for this routejava.lang.StringgetLanguage()Returns language of instructionsGLRouteManeuvergetLastManeuver()Returns last maneuver in routedoublegetLength()Returns total length of the trackdoublegetLengthOfLeg(int index)Returns length of legGLRouteManeuver[]getManeuvers()Returns all maneuvers of routeGLRouteManeuvergetNextManeuver(GLRouteManeuver maneuver)Returns next maneuver that goes after the given maneuverjava.lang.StringgetNextShortInstruction(GLRouteManeuver maneuver)intgetNumberOfLegs()Returns number of legsintgetNumberOfTargetPoints()Returns number of target pointsGLRouteManeuvergetPreviousManeuver(GLRouteManeuver maneuver)Returns previous maneuver that goes before the given maneuverGLRoutePointgetTargetPoint(int index)Returns target pointint[]getTrackCoordinates()Returns track coordinates in pairs (x, y) If track contains several lines - (-1, -1) split one segment from otherglobus.glmap.GLMapTrackDatagetTrackData(int trackColor)Returns track data that can be used to display track of routestatic GLRouteParseFromJSON(java.lang.String json)Creates GLRoute from json StringGLRouteswitchToAlternate(int alternativeIndex)Switch to alternative routejava.lang.StringtoJSON()Serialize route to json
-
-
-
Method Detail
-
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 globus.glmap.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 java.lang.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
-
switchToAlternate
public GLRoute switchToAlternate(int alternativeIndex)
Switch to alternative route- Parameters:
alternativeIndex- index of alternative- Returns:
- switched route
-
ParseFromJSON
@Nullable public static GLRoute ParseFromJSON(@NonNull java.lang.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 java.lang.String toJSON()
Serialize route to json- Returns:
- json string
-
findInsertionIndex
public static int findInsertionIndex(@NonNull globus.glmap.MapPoint pt, @NonNull globus.glmap.MapPoint[] points)Finds index where given point must be inserted to array of reference points. It's used, for example, to add way point to route.- Parameters:
pt- At input - point to insert. At output - point that is located on route.points- Array of reference points- Returns:
- -1 if given point is too far from track.
-
getNextShortInstruction
@Nullable public java.lang.String getNextShortInstruction(@NonNull GLRouteManeuver maneuver)- Parameters:
maneuver- First maneuver to start search- Returns:
- First non empty short instruction from given maneuver to the end of route
-
getApproachAlert
@Nullable public java.lang.String getApproachAlert(@NonNull java.lang.String instruction, double distance)Adds 'In `distance` `units` ' before instruction- Parameters:
instruction- Instruction textdistance- in meters- Returns:
- Instruction with approach alert
-
-