use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class BaseTest method buildDefaultRouteProgress.
protected RouteProgress buildDefaultRouteProgress() throws Exception {
DirectionsRoute aRoute = buildDirectionsRoute();
RouteProgress defaultRouteProgress = RouteProgress.builder().stepDistanceRemaining(100).legDistanceRemaining(100).distanceRemaining(100).directionsRoute(aRoute).stepIndex(0).legIndex(0).build();
return defaultRouteProgress;
}
use of com.mapbox.api.directions.v5.models.DirectionsRoute 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.DirectionsRoute 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.DirectionsRoute 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;
}
use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class RouteUtilsTest method isNewRoute_returnsTrueWhenGeometriesDoNotEqual.
@Test
public void isNewRoute_returnsTrueWhenGeometriesDoNotEqual() throws Exception {
DirectionsRoute aRoute = buildDirectionsRoute();
RouteProgress defaultRouteProgress = buildDefaultRouteProgress();
RouteProgress previousRouteProgress = defaultRouteProgress.toBuilder().directionsRoute(aRoute.toBuilder().geometry("vfejnqiv").build()).build();
boolean isNewRoute = RouteUtils.isNewRoute(previousRouteProgress, defaultRouteProgress);
assertTrue(isNewRoute);
}
Aggregations