Search in sources :

Example 1 with RouteOptions

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"));
}
Also used : ArrayList(java.util.ArrayList) Point(com.mapbox.geojson.Point) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RouteOptions(com.mapbox.api.directions.v5.models.RouteOptions) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 2 with RouteOptions

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;
}
Also used : Point(com.mapbox.geojson.Point) RouteOptions(com.mapbox.api.directions.v5.models.RouteOptions) NavigationRoute(com.mapbox.services.android.navigation.v5.navigation.NavigationRoute) Nullable(android.support.annotation.Nullable)

Aggregations

RouteOptions (com.mapbox.api.directions.v5.models.RouteOptions)2 Point (com.mapbox.geojson.Point)2 Nullable (android.support.annotation.Nullable)1 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)1 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)1 ArrayList (java.util.ArrayList)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1