Search in sources :

Example 1 with StepIntersection

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

the class ToleranceUtils method dynamicRerouteDistanceTolerance.

public static double dynamicRerouteDistanceTolerance(Point snappedPoint, RouteProgress routeProgress) {
    List<StepIntersection> intersections = routeProgress.currentLegProgress().currentStepProgress().intersections();
    List<Point> intersectionsPoints = new ArrayList<>();
    for (StepIntersection intersection : intersections) {
        intersectionsPoints.add(intersection.location());
    }
    Point closestIntersection = TurfClassification.nearestPoint(snappedPoint, intersectionsPoints);
    if (closestIntersection.equals(snappedPoint)) {
        return NavigationConstants.MINIMUM_DISTANCE_BEFORE_REROUTING;
    }
    double distanceToNextIntersection = TurfMeasurement.distance(snappedPoint, closestIntersection, TurfConstants.UNIT_METERS);
    if (distanceToNextIntersection <= NavigationConstants.MANEUVER_ZONE_RADIUS) {
        return NavigationConstants.MINIMUM_DISTANCE_BEFORE_REROUTING / 2;
    }
    return NavigationConstants.MINIMUM_DISTANCE_BEFORE_REROUTING;
}
Also used : StepIntersection(com.mapbox.api.directions.v5.models.StepIntersection) ArrayList(java.util.ArrayList) Point(com.mapbox.geojson.Point)

Example 2 with StepIntersection

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

the class InstructionStepResources method intersectionTurnLanes.

private void intersectionTurnLanes(LegStep step) {
    StepIntersection intersection = step.intersections().get(0);
    List<IntersectionLanes> lanes = intersection.lanes();
    if (checkForNoneIndications(lanes)) {
        turnLanes = null;
        return;
    }
    turnLanes = lanes;
}
Also used : StepIntersection(com.mapbox.api.directions.v5.models.StepIntersection) IntersectionLanes(com.mapbox.api.directions.v5.models.IntersectionLanes)

Aggregations

StepIntersection (com.mapbox.api.directions.v5.models.StepIntersection)2 IntersectionLanes (com.mapbox.api.directions.v5.models.IntersectionLanes)1 Point (com.mapbox.geojson.Point)1 ArrayList (java.util.ArrayList)1