Package globus.glroute
Class GLRoute
java.lang.Object
globus.glmap.GLNativeObject
globus.glroute.GLRoute
GLRoute stores route data and exposes maneuvers, length, and duration.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceBike typestatic @interfaceNavigation mode -
Method Summary
Modifier and TypeMethodDescriptionstatic intfindInsertionIndex(MapPoint pt, MapPoint[] points) Finds the index where the given point should be inserted into an array of reference points.GLRoute[]Alternative routesgetApproachAlert(String instruction, double distance) Prepends a distance alert (for example, "In 200 m …") to an instruction.doubleReturns estimated duration of the trackdoublegetDurationOfLeg(int index) Returns duration of legReturns first maneuver in routeReturns height data that was previously requested for this routeReturns language of instructionsReturns last maneuver in routedoubleReturns total length of the trackdoublegetLengthOfLeg(int index) Returns length of legReturns all maneuvers of routegetNextManeuver(GLRouteManeuver maneuver) Returns next maneuver that goes after the given maneuvergetNextShortInstruction(GLRouteManeuver maneuver) Retrieves the first non-empty short instruction starting from the specified maneuver to the end of the route.intReturns number of legsintReturns number of target pointsgetPreviousManeuver(GLRouteManeuver maneuver) Returns previous maneuver that goes before the given maneuvergetTargetPoint(int index) Returns target pointint[]Returns track coordinates as flattened pairs(x, y)in internal map coordinates.getTrackData(int trackColor) Returns track data that can be used to display track of routestatic GLRouteParseFromJSON(String json) CreatesGLRoutefrom a JSON string.static StringserializeToJSON(GLRoute[] routes) Serializes routes to JSON.toJSON()Serializes route to JSON.Methods inherited from class globus.glmap.GLNativeObject
dispose
-
Method Details
-
getNumberOfTargetPoints
public int getNumberOfTargetPoints()Returns number of target points- Returns:
- number of target points
-
getTargetPoint
Returns target point- Parameters:
index- index of target point- Returns:
- target point
-
getTrackData
Returns track data that can be used to display track of route- Parameters:
trackColor- color of route track (ARGB,0xAARRGGBB)- Returns:
- track data of route
-
getTrackCoordinates
@Nullable public int[] getTrackCoordinates()Returns track coordinates as flattened pairs(x, y)in internal map coordinates.If the track contains multiple segments,
(-1, -1)is used as a separator between segments.- Returns:
- track coordinates, or
nullif no geometry is available
-
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
Returns all maneuvers of route- Returns:
- array of maneuvers
-
getNextManeuver
Returns next maneuver that goes after the given maneuver- Parameters:
maneuver- maneuver- Returns:
- next maneuver after the given maneuver
-
getPreviousManeuver
Returns previous maneuver that goes before the given maneuver- Parameters:
maneuver- maneuver- Returns:
- previous maneuver after the given maneuver
-
getFirstManeuver
Returns first maneuver in route- Returns:
- first maneuver in route
-
getLastManeuver
Returns last maneuver in route- Returns:
- last maneuver in route
-
getHeightData
Returns height data that was previously requested for this route- Returns:
- height data
-
getAlternates
Alternative routes- Returns:
- alternative routes
-
ParseFromJSON
CreatesGLRoutefrom a JSON string.- Parameters:
json- json string that was returned by GLRoute#toJSON- Returns:
GLRouteornullif data is invalid
-
toJSON
Serializes route to JSON.- Returns:
- json string
-
serializeToJSON
Serializes routes to JSON. Routes after the first will become alternatives.- Parameters:
routes- routes to serialize- Returns:
- json string
-
findInsertionIndex
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
-1if the point is too far from the track.
-
getNextShortInstruction
Retrieves the first non-empty short instruction starting from the specified maneuver to the end of the route.- Parameters:
maneuver- The startingGLRouteManeuverfor the search.- Returns:
- The first non-empty short instruction, or
nullif no such instruction exists.
-
getApproachAlert
Prepends a distance alert (for example, "In 200 m …") to an instruction.- Parameters:
instruction- Instruction textdistance- distance in meters- Returns:
- instruction with approach alert, or
nullif the instruction cannot be formatted
-