From b6a640b1de62ced55df370ad50731de9d9dda9fb Mon Sep 17 00:00:00 2001 From: Bobby Sudekum Date: Mon, 28 Aug 2017 14:45:15 -0400 Subject: [PATCH] Increase snapped distance, dont use course if it is bad --- MapboxCoreNavigation/Constants.swift | 2 +- MapboxCoreNavigation/RouteController.swift | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/MapboxCoreNavigation/Constants.swift b/MapboxCoreNavigation/Constants.swift index ff8e0fdadd..fb48d01a48 100644 --- a/MapboxCoreNavigation/Constants.swift +++ b/MapboxCoreNavigation/Constants.swift @@ -80,7 +80,7 @@ public var RouteControllerMaximumDistanceBeforeRecalculating: CLLocationDistance /** Accepted deviation excluding horizontal accuracy before the user is considered to be off route. */ -public var RouteControllerUserLocationSnappingDistance: CLLocationDistance = 10 +public var RouteControllerUserLocationSnappingDistance: CLLocationDistance = 20 /** Threshold user must be in within to count as completing a step. One of two heuristics used to know when a user completes a step, see `RouteControllerManeuverZoneRadius`. diff --git a/MapboxCoreNavigation/RouteController.swift b/MapboxCoreNavigation/RouteController.swift index 50d0457a83..50946d9966 100644 --- a/MapboxCoreNavigation/RouteController.swift +++ b/MapboxCoreNavigation/RouteController.swift @@ -298,7 +298,8 @@ open class RouteController: NSObject { // If the course is inaccurate or the speed is low and the user is on the route, // snap the users location and course since we know the snapped location and course is more accurate. if location.course <= 0 || location.speed <= RouteControllerMinimumSpeedThresholdForSnappingUserToRoute, snappedCoordinate.distance < RouteControllerUserLocationSnappingDistance { - return CLLocation(coordinate: snappedCoordinate.coordinate, altitude: location.altitude, horizontalAccuracy: location.horizontalAccuracy, verticalAccuracy: location.verticalAccuracy, course: absoluteDirection, speed: location.speed, timestamp: location.timestamp) + let calculatedWrappedCourse = wrap((wrappedPointBehind + wrappedPointAhead) / 2, min: 0 , max: 360) + return CLLocation(coordinate: snappedCoordinate.coordinate, altitude: location.altitude, horizontalAccuracy: location.horizontalAccuracy, verticalAccuracy: location.verticalAccuracy, course: calculatedWrappedCourse, speed: location.speed, timestamp: location.timestamp) } guard differenceBetweenAngles(absoluteDirection, location.course) < RouteControllerMaxManipulatedCourseAngle else {