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