Search in sources :

Example 21 with DirectionsRoute

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;
}
Also used : DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)

Example 22 with DirectionsRoute

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();
}
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 23 with DirectionsRoute

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);
}
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 24 with DirectionsRoute

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

Example 25 with DirectionsRoute

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);
}
Also used : DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Aggregations

DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)25 DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)14 Gson (com.google.gson.Gson)11 GsonBuilder (com.google.gson.GsonBuilder)11 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)10 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)10 Test (org.junit.Test)10 RouteLeg (com.mapbox.api.directions.v5.models.RouteLeg)9 Before (org.junit.Before)7 Point (com.mapbox.geojson.Point)6 Location (android.location.Location)3 LegStep (com.mapbox.api.directions.v5.models.LegStep)3 LineString (com.mapbox.geojson.LineString)3 FasterRoute (com.mapbox.services.android.navigation.v5.route.FasterRoute)2 Feature (com.mapbox.services.commons.geojson.Feature)2 ArrayList (java.util.ArrayList)2 StepManeuver (com.mapbox.api.directions.v5.models.StepManeuver)1 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)1 LineString (com.mapbox.services.commons.geojson.LineString)1 Point (com.mapbox.services.commons.geojson.Point)1