Search in sources :

Example 1 with OffRouteDetector

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

the class MapboxNavigation method initialize.

/**
 * In-charge of initializing all variables needed to begin a navigation session. Many values can
 * be changed later on using their corresponding setter. An internal progressChangeListeners used
 * to prevent users from removing it.
 */
private void initialize() {
    // Initialize event dispatcher and add internal listeners
    navigationEventDispatcher = new NavigationEventDispatcher();
    initializeDefaultLocationEngine();
    initializeDefaultCameraEngine();
    initializeTelemetry();
    // Create and add default milestones if enabled.
    milestones = new ArrayList<>();
    if (options.defaultMilestonesEnabled()) {
        addMilestone(new VoiceInstructionMilestone.Builder().setIdentifier(VOICE_INSTRUCTION_MILESTONE_ID).build());
        addMilestone(new BannerInstructionMilestone.Builder().setIdentifier(BANNER_INSTRUCTION_MILESTONE_ID).build());
    }
    if (options.snapToRoute()) {
        snapEngine = new SnapToRoute();
    }
    if (options.enableOffRouteDetection()) {
        offRouteEngine = new OffRouteDetector();
    }
    if (options().enableFasterRouteDetection()) {
        fasterRouteEngine = new FasterRouteDetector();
    }
}
Also used : VoiceInstructionMilestone(com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone) BannerInstructionMilestone(com.mapbox.services.android.navigation.v5.milestone.BannerInstructionMilestone) SnapToRoute(com.mapbox.services.android.navigation.v5.snap.SnapToRoute) FasterRouteDetector(com.mapbox.services.android.navigation.v5.route.FasterRouteDetector) OffRouteDetector(com.mapbox.services.android.navigation.v5.offroute.OffRouteDetector)

Example 2 with OffRouteDetector

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

the class MapboxNavigationTest method setOffRouteEngine_doesReplaceDefaultEngine.

@Test
public void setOffRouteEngine_doesReplaceDefaultEngine() throws Exception {
    OffRoute offRoute = navigation.getOffRouteEngine();
    assertTrue(offRoute instanceof OffRouteDetector);
    offRoute = mock(OffRoute.class);
    navigation.setOffRouteEngine(offRoute);
    assertTrue(!(navigation.getOffRouteEngine() instanceof OffRouteDetector));
    assertTrue(navigation.getOffRouteEngine() instanceof OffRoute);
}
Also used : OffRoute(com.mapbox.services.android.navigation.v5.offroute.OffRoute) OffRouteDetector(com.mapbox.services.android.navigation.v5.offroute.OffRouteDetector) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 3 with OffRouteDetector

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

the class OffRouteDetectorTest method setupStepPoints.

private void setupStepPoints(OffRouteDetector offRouteDetector) throws Exception {
    RouteProgress routeProgress = buildDefaultRouteProgress();
    LegStep currentStep = routeProgress.currentLegProgress().currentStep();
    LineString lineString = LineString.fromPolyline(currentStep.geometry(), Constants.PRECISION_6);
    List<Point> stepPoints = lineString.coordinates();
    offRouteDetector.updateStepPoints(stepPoints);
}
Also used : LineString(com.mapbox.geojson.LineString) Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) LegStep(com.mapbox.api.directions.v5.models.LegStep)

Aggregations

OffRouteDetector (com.mapbox.services.android.navigation.v5.offroute.OffRouteDetector)2 LegStep (com.mapbox.api.directions.v5.models.LegStep)1 LineString (com.mapbox.geojson.LineString)1 Point (com.mapbox.geojson.Point)1 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)1 BannerInstructionMilestone (com.mapbox.services.android.navigation.v5.milestone.BannerInstructionMilestone)1 VoiceInstructionMilestone (com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone)1 OffRoute (com.mapbox.services.android.navigation.v5.offroute.OffRoute)1 FasterRouteDetector (com.mapbox.services.android.navigation.v5.route.FasterRouteDetector)1 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)1 SnapToRoute (com.mapbox.services.android.navigation.v5.snap.SnapToRoute)1 Test (org.junit.Test)1