Search in sources :

Example 1 with DirectionsResponse

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

the class MapboxNavigationNotificationTest method setUp.

@Before
public void setUp() throws Exception {
    final String json = loadJsonFixture(DIRECTIONS_ROUTE_FIXTURE);
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    DirectionsResponse response = gson.fromJson(json, DirectionsResponse.class);
    route = response.routes().get(0);
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Before(org.junit.Before)

Example 2 with DirectionsResponse

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

the class NavigationEventDispatcherTest method setup.

@Before
public void setup() throws IOException {
    MockitoAnnotations.initMocks(this);
    navigation = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    navigationEventDispatcher = navigation.getEventDispatcher();
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(PRECISION_6);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    route = response.routes().get(0);
    routeProgress = RouteProgress.builder().stepDistanceRemaining(100).legDistanceRemaining(100).distanceRemaining(100).directionsRoute(route).stepIndex(0).legIndex(0).build();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Before(org.junit.Before)

Example 3 with DirectionsResponse

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

the class NavigationHelperTest method setUp.

@Before
public void setUp() throws Exception {
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(MULTI_LEG_ROUTE);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    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());
    routeProgressBuilder = RouteProgress.builder().directionsRoute(route).distanceRemaining(1000).stepDistanceRemaining(1000).legDistanceRemaining(1000).stepIndex(0).legIndex(0);
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) Point(com.mapbox.geojson.Point) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Location(android.location.Location) Before(org.junit.Before)

Example 4 with DirectionsResponse

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

the class RouteProgressTest method setup.

@Before
public void setup() throws IOException {
    Gson gson = new GsonBuilder().registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
    String body = loadJsonFixture(DIRECTIONS_PRECISION_6);
    DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
    route = response.routes().get(0);
    RouteLeg firstLeg = route.legs().get(0);
    // Multiple leg route
    body = loadJsonFixture(MULTI_LEG_ROUTE);
    response = gson.fromJson(body, DirectionsResponse.class);
    multiLegRoute = response.routes().get(0);
    beginningRouteProgress = RouteProgress.builder().stepDistanceRemaining(route.legs().get(0).steps().get(0).distance()).legDistanceRemaining(route.legs().get(0).distance()).distanceRemaining(route.distance()).directionsRoute(route).stepIndex(0).legIndex(0).build();
    lastRouteProgress = RouteProgress.builder().stepDistanceRemaining(route.legs().get(0).steps().get(firstLeg.steps().size() - 1).distance()).legDistanceRemaining(route.legs().get(0).distance()).distanceRemaining(0).directionsRoute(route).stepIndex(firstLeg.steps().size() - 1).legIndex(route.legs().size() - 1).build();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) RouteLeg(com.mapbox.api.directions.v5.models.RouteLeg) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Before(org.junit.Before)

Example 5 with DirectionsResponse

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

the class SnapToRouteTest method setUp.

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

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