use of com.mapbox.api.directions.v5.models.RouteOptions 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.api.directions.v5.models.RouteOptions in project mapbox-navigation-android by mapbox.
the class RouteEngine method buildRouteRequestFromCurrentLocation.
@Nullable
public static NavigationRoute.Builder buildRouteRequestFromCurrentLocation(Point origin, Double bearing, RouteProgress progress) {
RouteOptions options = progress.directionsRoute().routeOptions();
NavigationRoute.Builder builder = NavigationRoute.builder().origin(origin, bearing, BEARING_TOLERANCE).routeOptions(options);
List<Point> remainingWaypoints = RouteUtils.calculateRemainingWaypoints(progress);
if (remainingWaypoints == null) {
Timber.e("An error occurred fetching a new route");
return null;
}
addDestination(remainingWaypoints, builder);
addWaypoints(remainingWaypoints, builder);
return builder;
}
Aggregations