mapbox / mapbox/mapbox-navigation-ios
Invalid course used to orient camera and user puck
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 918
- Forks
- 326
- Avg merge
- 1h 16m
- Merged PRs (30d)
- 3
Description
We aren’t checking for `CLLocation.course` being −1 in several places:
https://github.com/mapbox/mapbox-navigation-ios/blob/abde5f63e58b686c3849e4cddc0d06dee385592b/MapboxNavigation/CarPlayNavigationViewController.swift#L252 https://github.com/mapbox/mapbox-navigation-ios/blob/abde5f63e58b686c3849e4cddc0d06dee385592b/MapboxNavigation/NavigationMapView.swift#L336 https://github.com/mapbox/mapbox-navigation-ios/blob/abde5f63e58b686c3849e4cddc0d06dee385592b/MapboxNavigation/UserCourseView.swift#L26 https://github.com/mapbox/mapbox-navigation-ios/blob/abde5f63e58b686c3849e4cddc0d06dee385592b/MapboxNavigation/UserCourseView.swift#L49
MGLMapView treats a rotation of −1° as meaning “keep the current rotation”, which may not always be accurate. More worryingly, `NavigationMapView.updateCourseTracking(location:camera:animated:)` updates not only the camera but also the user puck’s transformation. A direction of −1° would actually rotate the puck close to due north, possibly resulting in some spinning when the speed is too low for Core Location to report a course.
We can use `CLLocationDirection.isQualified` to easily perform this check. In the event of a negative value, we could calculate the direction to the next coordinate along the route line. Or better yet, we could keep a running comparison between `CLHeading.trueHeading` and `CLLocation.course` so that we can fall back on the heading (with an offset) when the course becomes less reliable than the heading.
/cc @mapbox/navigation-ios @d-prukop @kevinkreiser
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the four linked locations: CarPlayNavigationViewController.swift, NavigationMapView.swift, and UserCourseView.swift. Inspect NavigationMapView.updateCourseTracking(location:camera:animated:) and CLLocationDirection.isQualified to understand how an invalid course affects camera and puck rotation. Done means invalid courses no longer cause incorrect orientation or spinning, with behavior covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100