isUserOffRoute

open override fun isUserOffRoute(location: Location, routeProgress: RouteProgress, options: MapLibreNavigationOptions): Boolean

Method in charge of running a series of test based on the device current location and the user progress along the route.

Test #1: Distance remaining. If the route distance remaining is 0, then return true immediately. In the route processor this will prompt the snap-to-route logic to return the raw Location. If there isn't any distance remaining, the user will always be off-route.

Test #2: Valid or invalid off-route. An off-route check can only continue if the device has received at least 1 location update (for comparison) and the user has traveled passed the MapLibreNavigationOptions.offRouteMinimumDistanceMetersAfterReroute checked against the last re-route location.

Test #3: Distance from the step. This test is checked against the max of the dynamic rerouting tolerance or the accuracy based tolerance. If this test passes, this method then also checks if there have been >= 3 location updates moving away from the maneuver point. If false, this method will return false early.

Test #4: Checks if the user is close the upcoming step. At this point, the user is considered off-route. But, if the location update is within the MapLibreNavigationOptions.maneuverZoneRadius of the upcoming step, this method will return false as well as send fire OffRouteCallback.onShouldIncreaseIndex to let the NavigationEngine know that the step index should be increased on the next location update.

Return

true if the users off-route, else false.

Since

0.2.0