Search in sources :

Example 11 with DirectionsResponse

use of com.mapbox.api.directions.v5.models.DirectionsResponse in project mapbox-navigation-android by mapbox.

the class DynamicCameraTest method buildDirectionsRoute.

private DirectionsRoute buildDirectionsRoute() throws IOException {
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(DIRECTIONS_PRECISION_6);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    return response.routes().get(0);
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse)

Example 12 with DirectionsResponse

use of com.mapbox.api.directions.v5.models.DirectionsResponse in project mapbox-navigation-android by mapbox.

the class TriggerPropertyTest method setup.

@Before
public void setup() throws IOException {
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(PRECISION_6);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    DirectionsRoute route = response.routes().get(0);
    routeProgress = RouteProgress.builder().directionsRoute(route).distanceRemaining(route.distance()).legDistanceRemaining(route.legs().get(0).distance()).stepDistanceRemaining(route.legs().get(0).steps().get(0).distance()).legIndex(0).stepIndex(1).build();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) Gson(com.google.gson.Gson) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Before(org.junit.Before)

Example 13 with DirectionsResponse

use of com.mapbox.api.directions.v5.models.DirectionsResponse in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method obtainADirectionsResponse.

private DirectionsResponse obtainADirectionsResponse() throws IOException {
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(PRECISION_6);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    return response;
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse)

Example 14 with DirectionsResponse

use of com.mapbox.api.directions.v5.models.DirectionsResponse in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method onSlowerRouteResponse_isFasterRouteIsFalse.

@Test
public void onSlowerRouteResponse_isFasterRouteIsFalse() throws Exception {
    FasterRoute fasterRouteEngine = navigation.getFasterRouteEngine();
    // Create current progress
    RouteProgress currentProgress = obtainDefaultRouteProgress();
    DirectionsRoute longerRoute = currentProgress.directionsRoute().toBuilder().duration(// Current route duration is very short
    1000d).build();
    currentProgress = currentProgress.toBuilder().directionsRoute(longerRoute).build();
    // Create new direction response
    DirectionsResponse response = obtainADirectionsResponse();
    boolean isFasterRoute = fasterRouteEngine.isFasterRoute(response, currentProgress);
    assertFalse(isFasterRoute);
}
Also used : FasterRoute(com.mapbox.services.android.navigation.v5.route.FasterRoute) DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 15 with DirectionsResponse

use of com.mapbox.api.directions.v5.models.DirectionsResponse in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method obtainADirectionsRoute.

private DirectionsRoute obtainADirectionsRoute() throws IOException {
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(PRECISION_6);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    DirectionsRoute aRoute = response.routes().get(0);
    return aRoute;
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) Gson(com.google.gson.Gson) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse)

Aggregations

DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)17 Gson (com.google.gson.Gson)14 GsonBuilder (com.google.gson.GsonBuilder)14 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)11 Before (org.junit.Before)9 Location (android.location.Location)3 Point (com.mapbox.geojson.Point)3 RouteLeg (com.mapbox.api.directions.v5.models.RouteLeg)2 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)2 FasterRoute (com.mapbox.services.android.navigation.v5.route.FasterRoute)2 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)2 Test (org.junit.Test)2 LegStep (com.mapbox.api.directions.v5.models.LegStep)1 LineString (com.mapbox.geojson.LineString)1 NavigationMapRoute (com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute)1 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)1