public class RouteUtils extends Object
Constructor and Description |
---|
RouteUtils() |
Modifier and Type | Method and Description |
---|---|
String[] |
calculateRemainingWaypointNames(RouteProgress routeProgress)
Given a
RouteProgress , this method will calculate the remaining waypoint names
along the given route based on route option waypoint names and the progress remaining coordinates. |
List<com.mapbox.geojson.Point> |
calculateRemainingWaypoints(RouteProgress routeProgress)
Given a
RouteProgress , this method will calculate the remaining coordinates
along the given route based on total route coordinates and the progress remaining waypoints. |
Location |
createFirstLocationFromRoute(com.mapbox.api.directions.v5.models.DirectionsRoute route)
If navigation begins, a location update is sometimes needed to force a
progress change update as soon as navigation is started.
|
com.mapbox.api.directions.v5.models.BannerInstructions |
findCurrentBannerInstructions(com.mapbox.api.directions.v5.models.LegStep currentStep,
double stepDistanceRemaining)
Given the current step / current step distance remaining, this function will
find the current instructions to be shown.
|
com.mapbox.api.directions.v5.models.BannerText |
findCurrentBannerText(com.mapbox.api.directions.v5.models.LegStep currentStep,
double stepDistanceRemaining,
boolean findPrimary)
This method returns the current
BannerText based on the currentStep distance
remaining. |
com.mapbox.api.directions.v5.models.VoiceInstructions |
findCurrentVoiceInstructions(com.mapbox.api.directions.v5.models.LegStep currentStep,
double stepDistanceRemaining)
This method returns the current
VoiceInstructions based on the step distance
remaining. |
boolean |
isArrivalEvent(RouteProgress routeProgress)
Looks at the current
RouteProgressState and returns if
is RouteProgressState.ROUTE_ARRIVED . |
boolean |
isLastLeg(RouteProgress routeProgress)
Looks at the current
RouteProgress list of legs and
checks if the current leg is the last leg. |
boolean |
isNewRoute(RouteProgress previousRouteProgress,
com.mapbox.api.directions.v5.models.DirectionsRoute directionsRoute)
Compares a new routeProgress geometry to a previousRouteProgress geometry to determine if the
user is traversing along a new route.
|
boolean |
isNewRoute(RouteProgress previousRouteProgress,
RouteProgress routeProgress)
Compares a new routeProgress geometry to a previousRouteProgress geometry to determine if the
user is traversing along a new route.
|
boolean |
isValidRouteProfile(String routeProfile)
Checks if the
String route profile provided is a valid profile
that can be used with the directions API. |
public boolean isNewRoute(@Nullable RouteProgress previousRouteProgress, @NonNull RouteProgress routeProgress)
previousRouteProgress
- the past route progress with the directions route includedrouteProgress
- the route progress with the directions route includedpublic boolean isNewRoute(@Nullable RouteProgress previousRouteProgress, @NonNull com.mapbox.api.directions.v5.models.DirectionsRoute directionsRoute)
previousRouteProgress
- the past route progress with the directions route includeddirectionsRoute
- the current directions routepublic boolean isArrivalEvent(@NonNull RouteProgress routeProgress)
RouteProgressState
and returns if
is RouteProgressState.ROUTE_ARRIVED
.routeProgress
- the current route progresspublic boolean isLastLeg(RouteProgress routeProgress)
RouteProgress
list of legs and
checks if the current leg is the last leg.routeProgress
- the current route progress@Nullable public List<com.mapbox.geojson.Point> calculateRemainingWaypoints(RouteProgress routeProgress)
RouteProgress
, this method will calculate the remaining coordinates
along the given route based on total route coordinates and the progress remaining waypoints.
If the coordinate size is less than the remaining waypoints, this method will return null.
routeProgress
- for route coordinates and remaining waypointsPoint
s@Nullable public String[] calculateRemainingWaypointNames(RouteProgress routeProgress)
RouteProgress
, this method will calculate the remaining waypoint names
along the given route based on route option waypoint names and the progress remaining coordinates.
If the waypoint names are empty, this method will return null.
routeProgress
- for route waypoint names and remaining coordinatespublic Location createFirstLocationFromRoute(com.mapbox.api.directions.v5.models.DirectionsRoute route)
This method creates a location update from the first coordinate (origin) that created the route.
route
- with list of coordinatesLocation
from first coordinatepublic boolean isValidRouteProfile(String routeProfile)
String
route profile provided is a valid profile
that can be used with the directions API.routeProfile
- being validated@Nullable public com.mapbox.api.directions.v5.models.BannerInstructions findCurrentBannerInstructions(com.mapbox.api.directions.v5.models.LegStep currentStep, double stepDistanceRemaining)
currentStep
- holding the current banner instructionsstepDistanceRemaining
- to determine progress along the currentStep@Nullable public com.mapbox.api.directions.v5.models.BannerText findCurrentBannerText(com.mapbox.api.directions.v5.models.LegStep currentStep, double stepDistanceRemaining, boolean findPrimary)
BannerText
based on the currentStep distance
remaining.
When called, this is the banner text that should be shown at the given point along the route.
currentStep
- holding the current banner instructionsstepDistanceRemaining
- to determine progress along the currentStepfindPrimary
- if the primary or secondary BannerText should be retrieved@Nullable public com.mapbox.api.directions.v5.models.VoiceInstructions findCurrentVoiceInstructions(com.mapbox.api.directions.v5.models.LegStep currentStep, double stepDistanceRemaining)
VoiceInstructions
based on the step distance
remaining.currentStep
- holding the current banner instructionsstepDistanceRemaining
- to determine progress along the step© 2017 Mapbox. All rights reserved.