Search in sources :

Example 6 with MapboxNavigationOptions

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

the class NavigationHelper method isUserOffRoute.

static boolean isUserOffRoute(NewLocationModel newLocationModel, RouteProgress routeProgress, OffRouteCallback callback) {
    MapboxNavigationOptions options = newLocationModel.mapboxNavigation().options();
    if (!options.enableOffRouteDetection()) {
        return false;
    }
    Location location = newLocationModel.location();
    OffRoute offRoute = newLocationModel.mapboxNavigation().getOffRouteEngine();
    setOffRouteDetectorCallback(offRoute, callback);
    return offRoute.isUserOffRoute(location, routeProgress, options);
}
Also used : OffRoute(com.mapbox.services.android.navigation.v5.offroute.OffRoute) Location(android.location.Location)

Example 7 with MapboxNavigationOptions

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

the class NavigationService method initLocationValidator.

/**
 * Creates a new location validator used to filter incoming
 * location updates from the location engine.
 */
private void initLocationValidator() {
    MapboxNavigationOptions options = mapboxNavigation.options();
    int accuracyAcceptableThreshold = options.locationAcceptableAccuracyInMetersThreshold();
    int accuracyPercentThreshold = options.locationAccuracyPercentThreshold();
    int timeInMillisThreshold = options.locationUpdateTimeInMillisThreshold();
    int velocityInMetersPerSecondThreshold = options.locationVelocityInMetersPerSecondThreshold();
    this.locationValidator = new LocationValidator(accuracyAcceptableThreshold, accuracyPercentThreshold, timeInMillisThreshold, velocityInMetersPerSecondThreshold);
}
Also used : LocationValidator(com.mapbox.services.android.navigation.v5.location.LocationValidator)

Example 8 with MapboxNavigationOptions

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

the class MapboxNavigationTest method addMilestone_milestoneOnlyGetsAddedOnce.

@Test
public void addMilestone_milestoneOnlyGetsAddedOnce() throws Exception {
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
    MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    Milestone milestone = new StepMilestone.Builder().build();
    navigationWithOptions.addMilestone(milestone);
    navigationWithOptions.addMilestone(milestone);
    assertEquals(1, navigationWithOptions.getMilestones().size());
}
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) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 9 with MapboxNavigationOptions

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

the class MapboxNavigationTest method removeMilestone_milestoneDidGetRemoved.

@Test
public void removeMilestone_milestoneDidGetRemoved() throws Exception {
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
    MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    Milestone milestone = new StepMilestone.Builder().build();
    navigationWithOptions.addMilestone(milestone);
    assertEquals(1, navigationWithOptions.getMilestones().size());
    navigationWithOptions.removeMilestone(milestone);
    assertEquals(0, navigationWithOptions.getMilestones().size());
}
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) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 10 with MapboxNavigationOptions

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

the class MapboxNavigationTest method removeMilestone_milestoneDoesNotExist.

@Test
public void removeMilestone_milestoneDoesNotExist() throws Exception {
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
    MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    Milestone milestone = new StepMilestone.Builder().build();
    navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
    navigationWithOptions.removeMilestone(milestone);
    assertEquals(1, navigationWithOptions.getMilestones().size());
}
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) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Aggregations

Context (android.content.Context)5 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)5 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)5 StepMilestone (com.mapbox.services.android.navigation.v5.milestone.StepMilestone)5 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)5 Test (org.junit.Test)5 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)3 MapboxNavigationOptions (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)3 Notification (android.app.Notification)1 Location (android.location.Location)1 GsonBuilder (com.google.gson.GsonBuilder)1 CustomNavigationNotification (com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification)1 LocationValidator (com.mapbox.services.android.navigation.v5.location.LocationValidator)1 RouteMilestone (com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)1 NavigationNotification (com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification)1 OffRoute (com.mapbox.services.android.navigation.v5.offroute.OffRoute)1 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)1