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

No RouteProgress updates when shape format is geoJSON #2125

Closed
nilsthamm opened this issue May 12, 2019 · 4 comments · Fixed by #2319
Closed

No RouteProgress updates when shape format is geoJSON #2125

nilsthamm opened this issue May 12, 2019 · 4 comments · Fixed by #2319
Labels
blocked Blocked by dependency or unclarity. bug Something isn’t working topic: directions

Comments

@nilsthamm
Copy link

Mapbox Navigation SDK version: 0.32.0 (CocoaPods)
Xcode Version: 10.2.1
Tested on various iPads (simulator and real) with iOS 12.2

Hi everyone,
First of all, thanks for the solid framework you are providing, it's really good to work with!
While working with the results from the Mapbox Navigation API within the SDK, I discovered a bug:

If the shapeFormat parameter of the NavigationRouteOptions is set to RouteShapeFormat.geoJSON the routeProgress object is not updated during simulation. In the UI this leads to not updating route statistics, missing voice commands, and not updating direction instructions. And as shown in the example below, all properties of the routeProgress object are not updated.
Through debugging I could only narrow it down to a not correct calculated status object in RouteController.locationManager(_:didUpdateLocations:). All called update functions afterwards can't read any progress from the retrieved status object.

To reproduce the error just execute this modified version of the basic example:

import UIKit
import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let origin = CLLocationCoordinate2DMake(37.77440680146262, -122.43539772352648)
        let destination = CLLocationCoordinate2DMake(37.76556957793795, -122.42409811526268)
        let options = NavigationRouteOptions(coordinates: [origin, destination])
        
        
        /* ADDED TO SIMULATE THE ERROR */
        options.shapeFormat = RouteShapeFormat.geoJSON
        NotificationCenter.default.addObserver(self, selector: #selector(routeProgressUpdate(_:)), name: .routeControllerProgressDidChange, object: nil)
        
        Directions.shared.calculate(options) { (waypoints, routes, error) in
            guard let route = routes?.first, error == nil else {
                print(error!.localizedDescription)
                return
            }
            options.profileIdentifier = MBDirectionsProfileIdentifier.automobile
            
            // For demonstration purposes, simulate locations if the Simulate Navigation option is on.
            let navigationService = MapboxNavigationService(route: route, simulating: .always)
            let navigationOptions = NavigationOptions(navigationService: navigationService)
            let navigationViewController = NavigationViewController(for: route, options: navigationOptions)
            
            self.present(navigationViewController, animated: true, completion: nil)
        }
    }
    
    /* ADDED TO SIMULATE THE ERROR */
    @objc func routeProgressUpdate(_ notification: NSNotification) {
        let progress = notification.userInfo![RouteControllerNotificationUserInfoKey.routeProgressKey] as! RouteProgress
        print(progress.currentLegProgress.remainingSteps.count)
    }


}
@1ec5
Copy link
Contributor

1ec5 commented May 21, 2019

@kevinkreiser, do you know if MapboxNavigationNative supports GeoJSON-formatted route geometries, or only Polyline-encoded geometries?

@1ec5 1ec5 added the bug Something isn’t working label May 21, 2019
@kevinkreiser
Copy link
Contributor

@1ec5 right now it only supports polyline6 geometries but it would be a very small amount of effort to add both polyline5 and geojson imho

@1ec5
Copy link
Contributor

1ec5 commented May 24, 2019

That would be desirable. We effectively regressed this functionality when migrating to MapboxNavigationNative, because even though the default changed to polyline6, there has always been an option to customize the format.

@1ec5
Copy link
Contributor

1ec5 commented Jan 8, 2020

The workaround is to leave the shape format as the default. The default value, polyline6, consumes much less bandwidth and processing time than geojson and doesn’t affect the shape data that application code has access to.

A possible workaround in the SDK itself would be to hardcode polyline6 as the shape format when serializing back to JSON for MapboxNavigationNative’s consumption, though we’d need to first make a copy of the options object to avoid affecting rerouting requests.

encoder.userInfo[.options] = routeOptions

@1ec5 1ec5 added blocked Blocked by dependency or unclarity. blocked: upstream topic: directions labels Jan 8, 2020
@1ec5 1ec5 mentioned this issue Jan 23, 2020
14 tasks
@1ec5 1ec5 closed this as completed in #2319 Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by dependency or unclarity. bug Something isn’t working topic: directions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants