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);
}
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();
}
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;
}
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);
}
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;
}
Aggregations