Search in sources :

Example 41 with RouteProgress

use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.

the class RouteEngine method buildRouteRequestFromCurrentLocation.

@Nullable
public static NavigationRoute.Builder buildRouteRequestFromCurrentLocation(Point origin, Double bearing, RouteProgress progress) {
    RouteOptions options = progress.directionsRoute().routeOptions();
    NavigationRoute.Builder builder = NavigationRoute.builder().origin(origin, bearing, BEARING_TOLERANCE).routeOptions(options);
    List<Point> remainingWaypoints = RouteUtils.calculateRemainingWaypoints(progress);
    if (remainingWaypoints == null) {
        Timber.e("An error occurred fetching a new route");
        return null;
    }
    addDestination(remainingWaypoints, builder);
    addWaypoints(remainingWaypoints, builder);
    return builder;
}
Also used : Point(com.mapbox.geojson.Point) RouteOptions(com.mapbox.api.directions.v5.models.RouteOptions) NavigationRoute(com.mapbox.services.android.navigation.v5.navigation.NavigationRoute) Nullable(android.support.annotation.Nullable)

Example 42 with RouteProgress

use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.

the class MapboxNavigationNotificationTest method updateDefaultNotification_onlyUpdatesNameWhenNew.

@Ignore
@Test
public void updateDefaultNotification_onlyUpdatesNameWhenNew() throws Exception {
    RouteProgress routeProgress = RouteProgress.builder().directionsRoute(route).stepIndex(0).legIndex(0).build();
    MapboxNavigationNotification mapboxNavigationNotification = new MapboxNavigationNotification(Mockito.mock(Context.class), Mockito.mock(MapboxNavigation.class));
    mapboxNavigationNotification.updateNotification(routeProgress);
// notificationManager.getActiveNotifications()[0].getNotification().contentView;
// verify(notificationManager, times(1)).getActiveNotifications()[0];
}
Also used : Context(android.content.Context) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 43 with RouteProgress

use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.

the class NavigationHelperTest method increaseIndex_increasesStepByOne.

@Test
public void increaseIndex_increasesStepByOne() throws Exception {
    RouteProgress routeProgress = routeProgressBuilder.legIndex(0).stepIndex(0).build();
    NavigationIndices previousIndices = NavigationIndices.create(0, 0);
    NavigationIndices newIndices = NavigationHelper.increaseIndex(routeProgress, previousIndices);
    assertEquals(0, newIndices.legIndex());
    assertEquals(1, newIndices.stepIndex());
}
Also used : RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 44 with RouteProgress

use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.

the class NavigationHelperTest method checkMilestones_onlyTriggeredMilestonesGetReturned.

@Test
public void checkMilestones_onlyTriggeredMilestonesGetReturned() throws Exception {
    RouteProgress routeProgress = routeProgressBuilder.legIndex(0).stepIndex(0).build();
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
    MapboxNavigation mapboxNavigation = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    mapboxNavigation.addMilestone(new StepMilestone.Builder().setTrigger(Trigger.eq(TriggerProperty.STEP_INDEX, 0)).setIdentifier(1001).build());
    mapboxNavigation.addMilestone(new StepMilestone.Builder().setTrigger(Trigger.eq(TriggerProperty.STEP_INDEX, 4)).setIdentifier(1002).build());
    List<Milestone> triggeredMilestones = checkMilestones(routeProgress, routeProgress, mapboxNavigation);
    assertEquals(1, triggeredMilestones.size());
    assertEquals(1001, triggeredMilestones.get(0).getIdentifier());
    assertNotSame(1002, triggeredMilestones.get(0).getIdentifier());
}
Also used : Context(android.content.Context) LocationEngine(com.mapbox.services.android.telemetry.location.LocationEngine) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Milestone(com.mapbox.services.android.navigation.v5.milestone.Milestone) GsonBuilder(com.google.gson.GsonBuilder) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 45 with RouteProgress

use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.

the class NavigationRouteProcessorTest method onShouldIncreaseStepIndex_indexIsIncreased.

@Test
public void onShouldIncreaseStepIndex_indexIsIncreased() throws Exception {
    RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
    int currentStepIndex = progress.currentLegProgress().stepIndex();
    routeProcessor.onShouldIncreaseIndex();
    routeProcessor.checkIncreaseIndex(navigation);
    RouteProgress secondProgress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
    int secondStepIndex = secondProgress.currentLegProgress().stepIndex();
    assertTrue(currentStepIndex != secondStepIndex);
}
Also used : RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Point(com.mapbox.geojson.Point) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Aggregations

BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)44 Test (org.junit.Test)44 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)39 Point (com.mapbox.geojson.Point)30 Location (android.location.Location)19 LineString (com.mapbox.geojson.LineString)12 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)10 DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)3 LegStep (com.mapbox.api.directions.v5.models.LegStep)3 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)3 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)3 Context (android.content.Context)2 GsonBuilder (com.google.gson.GsonBuilder)2 RouteLeg (com.mapbox.api.directions.v5.models.RouteLeg)2 FasterRoute (com.mapbox.services.android.navigation.v5.route.FasterRoute)2 MetricsRouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress)2 RouteStepProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteStepProgress)2 DistanceUtils (com.mapbox.services.android.navigation.v5.utils.DistanceUtils)2 Date (java.util.Date)2 Ignore (org.junit.Ignore)2