use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class StepMilestoneTest 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 TriggerTest 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);
Location location = new Location("test");
List<Point> coords = PolylineUtils.decode(route.legs().get(0).steps().get(1).geometry(), Constants.PRECISION_6);
location.setLatitude(coords.get(0).latitude());
location.setLongitude(coords.get(0).longitude());
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 obtainDefaultRouteProgress.
private RouteProgress obtainDefaultRouteProgress() throws Exception {
DirectionsRoute aRoute = obtainADirectionsRoute();
RouteProgress defaultRouteProgress = RouteProgress.builder().stepDistanceRemaining(100).legDistanceRemaining(700).distanceRemaining(1000).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 FasterRouteDetectorTest method onFasterRouteResponse_isFasterRouteIsTrue.
@Test
public void onFasterRouteResponse_isFasterRouteIsTrue() throws Exception {
FasterRoute fasterRouteEngine = navigation.getFasterRouteEngine();
// Create current progress
RouteProgress currentProgress = obtainDefaultRouteProgress();
DirectionsRoute longerRoute = currentProgress.directionsRoute().toBuilder().duration(// Current route duration is very long
10000000d).build();
currentProgress = currentProgress.toBuilder().directionsRoute(longerRoute).build();
// Create new direction response
DirectionsResponse response = obtainADirectionsResponse();
boolean isFasterRoute = fasterRouteEngine.isFasterRoute(response, currentProgress);
assertTrue(isFasterRoute);
}
use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class RouteUtilsTest method isArrivalEvent_returnsTrueWhenUpcomingManeuverTypeIsArrival_andIsValidMetersRemaining.
@Test
public void isArrivalEvent_returnsTrueWhenUpcomingManeuverTypeIsArrival_andIsValidMetersRemaining() throws Exception {
DirectionsRoute aRoute = buildDirectionsRoute();
int lastStepIndex = obtainLastStepIndex(aRoute);
RouteProgress defaultRouteProgress = buildDefaultRouteProgress();
RouteProgress theRouteProgress = defaultRouteProgress.toBuilder().legDistanceRemaining(30).stepIndex(lastStepIndex - 1).build();
boolean isArrivalEvent = RouteUtils.isArrivalEvent(theRouteProgress);
assertTrue(isArrivalEvent);
}
Aggregations