Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase snapped distance, don't use course if it is bad #551

Merged
merged 1 commit into from Aug 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion MapboxCoreNavigation/Constants.swift
Expand Up @@ -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`.
Expand Down
3 changes: 2 additions & 1 deletion MapboxCoreNavigation/RouteController.swift
Expand Up @@ -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 {
Expand Down