diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dfab4ec552..3eb2398ca4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master +* Speculatively fixed spurious rerouting when passing an intermediate waypoint. ([#1869](https://github.com/mapbox/mapbox-navigation-ios/pull/1869)) + ### CarPlay * When selecting a search result in CarPlay, the resulting routes lead to the search result’s routable location when available. Routes to a routable location are more likely to be passable. ([#1859](https://github.com/mapbox/mapbox-navigation-ios/pull/1859)) diff --git a/MapboxCoreNavigation/RouteController.swift b/MapboxCoreNavigation/RouteController.swift index 6bc2905b50d..f4f3c8fd5c7 100644 --- a/MapboxCoreNavigation/RouteController.swift +++ b/MapboxCoreNavigation/RouteController.swift @@ -221,6 +221,12 @@ open class RouteController: NSObject, Router { Monitors the user's course to see if it is consistantly moving away from what we expect the course to be at a given point. */ func userCourseIsOnRoute(_ location: CLLocation) -> Bool { + // if we have yet to travel along the current leg, don't check for heading conformance + guard routeProgress.currentLegProgress.distanceTraveled > 0 else { + movementsAwayFromRoute = 0 + return true + } + let nearByCoordinates = routeProgress.currentLegProgress.nearbyCoordinates guard let calculatedCourseForLocationOnStep = location.interpolatedCourse(along: nearByCoordinates) else { return true }