use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class RouteUtilsTest method isArrivalEvent_returnsFalseWhenManeuverTypeIsArrival_andIsNotValidMetersRemaining.
@Test
public void isArrivalEvent_returnsFalseWhenManeuverTypeIsArrival_andIsNotValidMetersRemaining() throws Exception {
DirectionsRoute aRoute = buildDirectionsRoute();
int lastStepIndex = obtainLastStepIndex(aRoute);
RouteProgress defaultRouteProgress = buildDefaultRouteProgress();
RouteProgress theRouteProgress = defaultRouteProgress.toBuilder().stepIndex(lastStepIndex).legDistanceRemaining(100).build();
boolean isArrivalEvent = RouteUtils.isArrivalEvent(theRouteProgress);
assertFalse(isArrivalEvent);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class RouteUtilsTest method isArrivalEvent_returnsTrueWhenManeuverTypeIsArrival_andIsValidMetersRemaining.
@Test
public void isArrivalEvent_returnsTrueWhenManeuverTypeIsArrival_andIsValidMetersRemaining() throws Exception {
DirectionsRoute aRoute = buildDirectionsRoute();
int lastStepIndex = obtainLastStepIndex(aRoute);
RouteProgress defaultRouteProgress = buildDefaultRouteProgress();
RouteProgress theRouteProgress = defaultRouteProgress.toBuilder().stepDistanceRemaining(30).legDistanceRemaining(30).distanceRemaining(30).stepIndex(lastStepIndex).build();
boolean isArrivalEvent = RouteUtils.isArrivalEvent(theRouteProgress);
assertTrue(isArrivalEvent);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class RouteUtilsTest method isArrivalEvent_returnsFalseWhenManeuverTypeIsNotArrival_andIsNotValidMetersRemaining.
@Test
public void isArrivalEvent_returnsFalseWhenManeuverTypeIsNotArrival_andIsNotValidMetersRemaining() throws Exception {
DirectionsRoute aRoute = buildDirectionsRoute();
int lastStepIndex = obtainLastStepIndex(aRoute);
RouteProgress defaultRouteProgress = buildDefaultRouteProgress();
RouteProgress theRouteProgress = defaultRouteProgress.toBuilder().stepDistanceRemaining(200).legDistanceRemaining(300).distanceRemaining(300).stepIndex(lastStepIndex - 1).build();
boolean isArrivalEvent = RouteUtils.isArrivalEvent(theRouteProgress);
assertFalse(isArrivalEvent);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class RouteUtilsTest method isNewRoute_returnsTrueWhenPreviousGeometriesNull.
@Test
public void isNewRoute_returnsTrueWhenPreviousGeometriesNull() throws Exception {
RouteProgress defaultRouteProgress = buildDefaultRouteProgress();
boolean isNewRoute = RouteUtils.isNewRoute(null, defaultRouteProgress);
assertTrue(isNewRoute);
RouteProgress previousRouteProgress = buildDefaultRouteProgress();
isNewRoute = RouteUtils.isNewRoute(previousRouteProgress, defaultRouteProgress);
assertFalse(isNewRoute);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class ToleranceUtilsTest method dynamicRerouteDistanceTolerance_userJustPastTheIntersection.
@Test
public void dynamicRerouteDistanceTolerance_userJustPastTheIntersection() throws Exception {
RouteProgress routeProgress = RouteProgress.builder().directionsRoute(response.routes().get(0)).legDistanceRemaining(0).distanceRemaining(0).stepIndex(0).legIndex(0).build();
double distanceToIntersection = response.routes().get(0).distance();
LineString lineString = LineString.fromPolyline(response.routes().get(0).geometry(), Constants.PRECISION_6);
Point closePoint = TurfMeasurement.along(lineString, distanceToIntersection, TurfConstants.UNIT_METERS);
double tolerance = ToleranceUtils.dynamicRerouteDistanceTolerance(closePoint, routeProgress);
assertEquals(25.0, tolerance, DELTA);
}
Aggregations