use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class ToleranceUtilsTest method dynamicRerouteDistanceTolerance_userFarAwayFromIntersection.
@Test
public void dynamicRerouteDistanceTolerance_userFarAwayFromIntersection() throws Exception {
RouteProgress routeProgress = RouteProgress.builder().directionsRoute(response.routes().get(0)).legDistanceRemaining(0).distanceRemaining(0).stepIndex(0).legIndex(0).build();
// Get a point on the route step which isn't close to an intersection.
List<Point> stepPoints = PolylineUtils.decode(response.routes().get(0).geometry(), PRECISION_6);
Point midPoint = TurfMeasurement.midpoint(stepPoints.get(0), stepPoints.get(1));
double tolerance = ToleranceUtils.dynamicRerouteDistanceTolerance(midPoint, routeProgress);
assertEquals(50.0, tolerance, DELTA);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class ToleranceUtilsTest method dynamicRerouteDistanceTolerance_userCloseToIntersection.
@Test
public void dynamicRerouteDistanceTolerance_userCloseToIntersection() throws Exception {
RouteProgress routeProgress = RouteProgress.builder().directionsRoute(response.routes().get(0)).legDistanceRemaining(0).distanceRemaining(0).stepIndex(0).legIndex(0).build();
double distanceToIntersection = response.routes().get(0).distance() - 39;
LineString lineString = LineString.fromPolyline(response.routes().get(0).geometry(), Constants.PRECISION_6);
Point closePoint = TurfMeasurement.along(lineString, distanceToIntersection, TurfConstants.UNIT_METERS);
double tolerance = ToleranceUtils.dynamicRerouteDistanceTolerance(closePoint, routeProgress);
assertEquals(25.0, tolerance, DELTA);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress 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.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationService method onMilestoneTrigger.
/**
* With each valid and successful rawLocation update, this will get called once the work on the
* navigation engine thread has finished. Depending on whether or not a milestone gets triggered
* or not, the navigation event dispatcher will be called to notify the developer.
*/
@Override
public void onMilestoneTrigger(List<Milestone> triggeredMilestones, RouteProgress routeProgress) {
for (Milestone milestone : triggeredMilestones) {
String instruction = buildInstructionString(routeProgress, milestone);
mapboxNavigation.getEventDispatcher().onMilestoneEvent(routeProgress, instruction, milestone);
}
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class FasterRouteDetector method validStepDurationRemaining.
private boolean validStepDurationRemaining(RouteProgress routeProgress) {
RouteStepProgress currentStepProgress = routeProgress.currentLegProgress().currentStepProgress();
// Current step duration remaining in seconds
int currentStepDurationRemaining = (int) currentStepProgress.durationRemaining();
return currentStepDurationRemaining > NAVIGATION_MEDIUM_ALERT_DURATION;
}
Aggregations