mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

[Bug]: Calculate map matching routes fails when adding heading to a user location waypoint

Open eFagerman opened this issue 7 months ago • 2 comments

Mapbox Navigation SDK version

3.9.2

Steps to reproduce

  1. Create a NavigationMatchOptions for automobile with coordinates (less than 100 coordinates). let routeOptions = NavigationMatchOptions(coordinates: coordinates, profileIdentifier: .automobile)

  2. Create two waypoints, user location and destination. Set a heading to the user location waypoint

guard let userLocation = mapboxNavigation.navigation().currentLocationMatching?.location else { return }
var userWaypoint = Waypoint(location: userLocation)
userWaypoint.heading = location.course
userWaypoint.headingAccuracy = 90.0
  1. Update the NavigationMatchOptions with the two waypoints: routeOptions.waypoints = [userWaypoint, destinationWaypoint]

  2. Try to calculate a route: let routes = try await routingProvider.calculateRoutes(options: routeOptions).value

If I skip updating the user-location waypoint with a heading, the request succeeds and I get routes. However, if I add a heading to the waypoint, the request always fails. This wasn’t the case a couple of months ago. I tried reverting to Navigation SDK 3.8.1, but the issue remains.

Expected behavior

The calculateRoutes request succeed with navigation routes

Actual behavior

The calculateRoutes function throws an error: [Error, nav-native]: OnlineRouter::getRoute id 7135325 failed w/error: Invalid query param

Is this a one-time issue or a repeatable issue?

repeatable

eFagerman avatar Jun 19 '25 07:06 eFagerman

Hello Erik and thank you for reaching out, let me please investigate the issue with the team.

ArtemStepuk avatar Jun 19 '25 12:06 ArtemStepuk

Hi @eFagerman

The Map Matching API does not support the heading (aka bearings in the Directions API) parameter.

The Map Matching API and the Directions API) are used for different use cases:

  • in the case of Map Matching API, you already have the points that form a fuzzy, inaccurate route and you want to snap this route to the known routes. The waypoints in this case mostly form the shape of the route. The number of such waypoints is large;
  • in the case of Directions API, you want to receive a route connecting a source and a destination point with possible a small number of stops. The waypoints don't form the shape of the route, they only represent places to visit.

So this is why the heading is not supported for the Map Matching API. Because this parameter does not affect the created route, only the waypoints form the route shape. We will try to improve the Nav SDK API in future releases to help avoid inconsistent parameters in the request.


Please consider if your use case should be covered by Directions API request.

kried avatar Jun 24 '25 12:06 kried