public class RouteUtils
extends java.lang.Object
This is an experimental API. Experimental APIs are quickly evolving and might change or be removed in minor versions.
| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_OFF_ROUTE_THRESHOLD_KM |
| Constructor and Description |
|---|
RouteUtils()
Deprecated.
All methods in RouteUtils are now static.
|
RouteUtils(double offRouteThresholdKm)
Deprecated.
All methods in RouteUtils are now static.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
getClosestStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg)
Get the closest routeLeg step to the given position.
|
static double |
getDistanceToEndOfRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route,
int geometryPrecision,
java.lang.String units)
Measures from the provided position (typically the user location), to the end of a
DirectionsRoute. |
static double |
getDistanceToEndOfRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route,
java.lang.String units)
Measures from the provided position (typically the user location), to the end of a
DirectionsRoute. |
static double |
getDistanceToNextLeg(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
java.lang.String units,
int geometryPrecision)
Measures the distance from a position to the end of the given
RouteLeg. |
static double |
getDistanceToNextStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
Measures the distance from a position to the end of the route step.
|
static double |
getDistanceToNextStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
java.lang.String units)
Measures the distance from a position to the end of the route step.
|
static double |
getDistanceToNextStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
java.lang.String units,
int geometryPrecision)
Measures the distance from a position to the end of the route step.
|
static double |
getDistanceToStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
Computes the distance between the position and the closest point in routeLeg step.
|
static com.mapbox.services.commons.geojson.LineString |
getGeometryRemainingOnRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route)
Get the remaining route geometry from the position provided to the end of the directions route.
|
static com.mapbox.services.commons.geojson.LineString |
getGeometryRemainingOnRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route,
int geometryPrecision)
Get the remaining route geometry from the position provided to the end of the directions route.
|
double |
getOffRouteThresholdKm()
Deprecated.
All methods in RouteUtils are now static.
|
static com.mapbox.services.commons.models.Position |
getSnapToRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
Snaps given position to a
RouteLeg step. |
static com.mapbox.services.commons.models.Position |
getSnapToRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
int geometryPrecision)
Snaps given position to a
RouteLeg step. |
boolean |
isInStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
Deprecated.
use the static equivalent of this method.
|
static boolean |
isInStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
double threshold)
Compute the distance between the position and the step line (the closest point), and checks
if it's within the off-route threshold.
|
boolean |
isOffRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg)
Deprecated.
Use the new static
isOffRoute() method. |
static boolean |
isOffRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
double threshold)
Method to check whether the position given is outside the routeLeg using the threshold.
|
public static final double DEFAULT_OFF_ROUTE_THRESHOLD_KM
@Deprecated public RouteUtils()
@Deprecated public RouteUtils(double offRouteThresholdKm)
offRouteThresholdKm - Double value using unit kilometers. This value determines the
distance till you are notified.@Deprecated public double getOffRouteThresholdKm()
@Deprecated
public boolean isInStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
position - you want to verify is on or near the routeLeg step. If using for navigation,
this would typically be the users current location.routeLeg - a directions routeLeg.stepIndex - integer index for step in routeLeg.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static boolean isInStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
double threshold)
position - you want to verify is on or near the routeLeg step. If using for navigation,
this would typically be the users current location.routeLeg - a directions routeLeg.stepIndex - integer index for step in routeLeg.public static double getDistanceToStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
position - you want to measure distance to from route. If using for navigation, this
would typically be the users current location.routeLeg - a directions routeLeg.stepIndex - integer index for step in routeLeg.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static double getDistanceToNextStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
position - you want to measure distance to from route. If using for navigation, this would typically be the
users current location.routeLeg - a directions route.stepIndex - integer index for step in route.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static double getDistanceToNextStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
java.lang.String units)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
position - you want to measure distance to from route. If using for navigation, this would typically be the
users current location.routeLeg - a directions RouteLeg.stepIndex - integer index for step in route.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static double getDistanceToNextStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
java.lang.String units,
int geometryPrecision)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
position - you want to measure distance to from route. If using for navigation, this would typically
be the users current location.routeLeg - a directions route.stepIndex - integer index for step in route.geometryPrecision - either Constants.PRECISION_5 or Constants.PRECISION_6com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static double getDistanceToNextLeg(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
java.lang.String units,
int geometryPrecision)
RouteLeg. The position provided is snapped
to the route before distance is calculated.position - you want to measure distance to from route. If using for navigation, this would typically be the
users current location.routeLeg - a directions RouteLeg.public static double getDistanceToEndOfRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route,
java.lang.String units)
DirectionsRoute. The
Position provided will be automatically snapped to the closest point to the route.position - you want to measure distance to from route. If using for navigation, this would typically be the
users current location.route - a DirectionsRoute.units - pass in the measurement units.public static double getDistanceToEndOfRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route,
int geometryPrecision,
java.lang.String units)
DirectionsRoute. The
Position provided will be automatically snapped to the closest point to the route.position - you want to measure distance to from route. If using for navigation, this would typically
be the users current location.route - a DirectionsRoute.units - pass in the measurement units.geometryPrecision - either Constants.PRECISION_5 or Constants.PRECISION_6public static com.mapbox.services.commons.models.Position getSnapToRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
RouteLeg step.position - that you want to snap to routeLeg. If using for navigation, this would
typically be the users current location.routeLeg - that you want to snap position to.stepIndex - integer index for step in routeLeg.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static com.mapbox.services.commons.models.Position getSnapToRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
int stepIndex,
int geometryPrecision)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
RouteLeg step.position - that you want to snap to routeLeg. If using for navigation, this would
typically be the users current location.routeLeg - that you want to snap position to.stepIndex - integer index for step in routeLeg.geometryPrecision - either Constants.PRECISION_5 or Constants.PRECISION_6com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.@Deprecated
public boolean isOffRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg)
throws com.mapbox.services.api.ServicesException,
com.mapbox.services.api.utils.turf.TurfException
isOffRoute() method.position - you want to verify is on or near the routeLeg. If using for navigation, this
would typically be the users current location.routeLeg - a directions routeLeg.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static boolean isOffRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg,
double threshold)
position - you want to verify is on or near the routeLeg. If using for navigation, this
would typically be the users current location.routeLeg - a directions routeLeg.threshold - double value used to determine if position is outside the range.public static int getClosestStep(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.RouteLeg routeLeg)
throws com.mapbox.services.api.utils.turf.TurfException,
com.mapbox.services.api.ServicesException
position - that you want to get closest routeLeg step to.routeLeg - a directions routeLeg.com.mapbox.services.api.ServicesException - if error occurs Mapbox API related.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static com.mapbox.services.commons.geojson.LineString getGeometryRemainingOnRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route)
throws com.mapbox.services.api.utils.turf.TurfException
position - the new starting postion of the route geometry. If using for navigation, this would typically be
the users current location.route - a Directions route.LineString representing the new route geometry.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.public static com.mapbox.services.commons.geojson.LineString getGeometryRemainingOnRoute(com.mapbox.services.commons.models.Position position,
com.mapbox.services.api.directions.v5.models.DirectionsRoute route,
int geometryPrecision)
throws com.mapbox.services.api.utils.turf.TurfException
position - the new starting postion of the route geometry. If using for navigation, this would
typically be the users current location.route - a Directions route.geometryPrecision - either Constants.PRECISION_5 or Constants.PRECISION_6LineString representing the new route geometry.com.mapbox.services.api.utils.turf.TurfException - signals that a Turf exception of some sort has occurred.