use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class NavigationRouteTest method addRouteOptionsIncludedInRequest.
@Test
public void addRouteOptionsIncludedInRequest() throws Exception {
List<Point> coordinates = new ArrayList<>();
coordinates.add(Point.fromLngLat(1.0, 2.0));
coordinates.add(Point.fromLngLat(1.0, 5.0));
RouteOptions routeOptions = RouteOptions.builder().accessToken(ACCESS_TOKEN).baseUrl("https://api-directions-traf.com").requestUuid("XYZ_UUID").alternatives(true).language(Locale.US.getLanguage()).profile(DirectionsCriteria.PROFILE_WALKING).coordinates(coordinates).voiceUnits(DirectionsCriteria.METRIC).user("example_user").build();
NavigationRoute navigationRoute = NavigationRoute.builder().origin(coordinates.get(0)).destination(coordinates.get(1)).routeOptions(routeOptions).build();
String request = navigationRoute.getCall().request().url().toString();
assertThat(request, containsString("https://api-directions-traf.com"));
assertThat(request, containsString("alternatives=true"));
assertThat(request, containsString(ACCESS_TOKEN));
assertThat(request, containsString("voice_units=metric"));
assertThat(request, containsString("example_user"));
assertThat(request, containsString("language=en"));
assertThat(request, containsString("walking"));
}
use of com.mapbox.geojson.Point 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.geojson.Point 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.geojson.Point 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.geojson.Point 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);
}
Aggregations