use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class OffRouteDetectorTest method isUserOffRoute_AssertFalseTwoUpdatesAwayFromManeuverThenOneTowards.
@Test
public void isUserOffRoute_AssertFalseTwoUpdatesAwayFromManeuverThenOneTowards() throws Exception {
RouteProgress routeProgress = buildDefaultRouteProgress();
LegStep currentStep = routeProgress.currentLegProgress().currentStep();
LineString lineString = LineString.fromPolyline(currentStep.geometry(), Constants.PRECISION_6);
List<Point> coordinates = lineString.coordinates();
Location firstLocationUpdate = buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637);
offRouteDetector.isUserOffRoute(firstLocationUpdate, routeProgress, options);
Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location secondLocationUpdate = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
boolean isUserOffRouteFirstTry = offRouteDetector.isUserOffRoute(secondLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteFirstTry);
Point secondLastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location thirdLocationUpdate = buildDefaultLocationUpdate(secondLastPointInCurrentStep.longitude(), secondLastPointInCurrentStep.latitude());
boolean isUserOffRouteSecondTry = offRouteDetector.isUserOffRoute(thirdLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteSecondTry);
Location fourthLocationUpdate = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
boolean isUserOffRouteThirdTry = offRouteDetector.isUserOffRoute(fourthLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteThirdTry);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class OffRouteDetectorTest method isUserOffRoute_AssertTrueWhenOnRouteButMovingAwayFromManeuver.
@Test
public void isUserOffRoute_AssertTrueWhenOnRouteButMovingAwayFromManeuver() throws Exception {
RouteProgress routeProgress = buildDefaultRouteProgress();
LegStep currentStep = routeProgress.currentLegProgress().currentStep();
LineString lineString = LineString.fromPolyline(currentStep.geometry(), Constants.PRECISION_6);
List<Point> coordinates = lineString.coordinates();
Location firstLocationUpdate = buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637);
offRouteDetector.isUserOffRoute(firstLocationUpdate, routeProgress, options);
Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location secondLocationUpdate = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
boolean isUserOffRouteFirstTry = offRouteDetector.isUserOffRoute(secondLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteFirstTry);
Point secondLastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location thirdLocationUpdate = buildDefaultLocationUpdate(secondLastPointInCurrentStep.longitude(), secondLastPointInCurrentStep.latitude());
boolean isUserOffRouteSecondTry = offRouteDetector.isUserOffRoute(thirdLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteSecondTry);
Point thirdLastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location fourthLocationUpdate = buildDefaultLocationUpdate(thirdLastPointInCurrentStep.longitude(), thirdLastPointInCurrentStep.latitude());
boolean isUserOffRouteThirdTry = offRouteDetector.isUserOffRoute(fourthLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteThirdTry);
Point fourthLastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location fifthLocationUpdate = buildDefaultLocationUpdate(fourthLastPointInCurrentStep.longitude(), fourthLastPointInCurrentStep.latitude());
boolean isUserOffRouteFourthTry = offRouteDetector.isUserOffRoute(fifthLocationUpdate, routeProgress, options);
assertFalse(isUserOffRouteFourthTry);
Point fifthLastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location sixthLocationUpdate = buildDefaultLocationUpdate(fifthLastPointInCurrentStep.longitude(), fifthLastPointInCurrentStep.latitude());
boolean isUserOffRouteFifthTry = offRouteDetector.isUserOffRoute(sixthLocationUpdate, routeProgress, options);
assertTrue(isUserOffRouteFifthTry);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class OffRouteDetectorTest method isUserOffRoute_AssertFalseWhenOnStep.
@Test
public void isUserOffRoute_AssertFalseWhenOnStep() throws Exception {
RouteProgress routeProgress = buildDefaultRouteProgress();
Point stepManeuverPoint = routeProgress.directionsRoute().legs().get(0).steps().get(0).maneuver().location();
Location firstUpdate = buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637);
offRouteDetector.isUserOffRoute(firstUpdate, routeProgress, options);
Point offRoutePoint = buildPointAwayFromPoint(stepManeuverPoint, 10, 90);
Location secondUpdate = buildDefaultLocationUpdate(offRoutePoint.longitude(), offRoutePoint.latitude());
boolean isUserOffRoute = offRouteDetector.isUserOffRoute(secondUpdate, routeProgress, options);
assertFalse(isUserOffRoute);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class OffRouteDetectorTest method isUserOffRoute_AssertTrueWhenTooFarFromStep.
@Test
public void isUserOffRoute_AssertTrueWhenTooFarFromStep() throws Exception {
RouteProgress routeProgress = buildDefaultRouteProgress();
Point stepManeuverPoint = routeProgress.directionsRoute().legs().get(0).steps().get(0).maneuver().location();
Location firstUpdate = buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637);
offRouteDetector.isUserOffRoute(firstUpdate, routeProgress, options);
Point offRoutePoint = buildPointAwayFromPoint(stepManeuverPoint, 100, 90);
Location secondUpdate = buildDefaultLocationUpdate(offRoutePoint.longitude(), offRoutePoint.latitude());
boolean isUserOffRoute = offRouteDetector.isUserOffRoute(secondUpdate, routeProgress, options);
assertTrue(isUserOffRoute);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class OffRouteDetectorTest method isUserOffRoute_AssertFalseWhenOffRouteButCloseToUpcomingStep.
@Test
public void isUserOffRoute_AssertFalseWhenOffRouteButCloseToUpcomingStep() throws Exception {
RouteProgress routeProgress = buildDefaultRouteProgress();
Point upcomingStepManeuverPoint = routeProgress.currentLegProgress().upComingStep().maneuver().location();
Location firstUpdate = buildDefaultLocationUpdate(-77.0339782574523, 38.89993519985637);
offRouteDetector.isUserOffRoute(firstUpdate, routeProgress, options);
Point offRoutePoint = buildPointAwayFromPoint(upcomingStepManeuverPoint, 30, 180);
Location secondUpdate = buildDefaultLocationUpdate(offRoutePoint.longitude(), offRoutePoint.latitude());
boolean isUserOffRoute = offRouteDetector.isUserOffRoute(secondUpdate, routeProgress, options);
assertFalse(isUserOffRoute);
verify(mockCallback, times(1)).onShouldIncreaseIndex();
}
Aggregations