mapbox / mapbox/mapbox-navigation-ios
Map Matching confidence unavailable after conversion to NavigationRoutes — iOS SDK 3.28.4
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 918
- Forks
- 326
- Avg merge
- 1h 16m
- Merged PRs (30d)
- 3
Description
## Summary
We need a supported way to access the original `Match.confidence` associated with a `NavigationRoutes` result, without performing a second Map Matching calculation.
Our app lets users follow previously recorded running or cycling GPS traces. We use `NavigationMatchOptions` with walking/cycling profiles and want to validate the matching confidence before starting Active Guidance.
## Environment
- Mapbox Navigation SDK for iOS **3.28.4**
- `MapboxNavigationCore` and `MapboxNavigationUIKit`, integrated through Swift Package Manager
- Custom Swift native module in a React Native / Expo app
- The reproduction below isolates `MapboxDirections` and does not require React Native or Expo.
## Observed behavior
`RoutingProvider.calculateRoutes(options:)` with `NavigationMatchOptions` returns `NavigationRoutes`, but we have not found a supported public API exposing the original `Match.confidence`.
The lower-level `Directions.calculate(_:completionHandler:)` provides a `MapMatchingResponse`, including `Match.confidence`. However, we have not found a supported public workflow to convert that existing response into `NavigationRoutes`.
We initially attempted to read:
```swift
navigationRoutes.mainRoute.route.foreignMembers["confidence"]
```
However, confidence is absent after the `Match` → `Route` conversion.
We understand that `confidence` is a typed property of `Match`, not `Route`, and that this foreign-member lookup is not necessarily a supported contract. We are asking for clarification on the intended workflow.
## Minimal offline reproduction
This synthetic example demonstrates the metadata conversion behavior with the `MapboxDirections` sources shipped in Navigation SDK 3.28.4.
It performs no network request, uses no real credentials or user GPS data, and does not start Active Guidance. It is a conversion-only fixture, not a navigable route.
```swift
import Foundation
import MapboxDirections
import Turf
let options = MatchOptions(coordinates: [
LocationCoordinate2D(latitude: 0, longitude: 0),
LocationCoordinate2D(latitude: 0, longitude: 0.001),
])
let match = Match(
legs: [],
shape: nil,
distance: 1,
expectedTravelTime: 1,
confidence: 0.9,
weight: Weight(value: 1, metric: "synthetic")
)
// Dummy credentials; no request is performed.
let credentials = Credentials(
accessToken: "synthetic-not-a-token",
host: URL(string: "https://invalid.example")!
)
let response = MapMatchingResponse(
httpResponse: nil,
matches: [match],
tracepoints: nil,
options: options,
credentials: credentials
)
let converted = try RouteResponse(
matching: response,
options: options,
credentials: credentials
)
let route = converted.routes!.first!
print(match.confidence)
print(route.foreignMembers["confidence"] != nil)
print(route.foreignMembers.isEmpty)
```
Observed output:
```text
0.9
false
true
```
The original `Match` contains confidence `0.9`, but the converted `Route` has no confidence entry in its foreign members.
## Expected capability
Access to the real matching confidence corresponding to the navigation route produced by the same calculation. We do not require it to be exposed specifically through `Route.foreignMembers`.
We want to preserve the original value, not fabricate confidence or bypass route-quality validation.
## Questions and interim workaround
1. Is there a supported public API to retrieve the original `Match.confidence` associated with the returned `NavigationRoutes`?
2. Is there a supported way to convert an existing `MapMatchingResponse` into `NavigationRoutes` while retaining access to its matching metadata?
3. If neither is currently available, could you recommend an interim workaround, hotfix, or narrowly scoped patch? A sample implementation would be helpful.
4. Does a newer SDK version address this? Are there production or support limitations associated with any recommended workaround?
We have not modified the SDK.
## Related references
- #4845 requests a public conversion API for an existing Directions API response. Our case is related but specifically involves Map Matching confidence.
- [[RouteResponse.swift in SDK 3.28.4](https://github.com/mapbox/mapbox-navigation-ios/blob/3.28.4/Sources/MapboxDirections/RouteResponse.swift)](https://github.com/mapbox/mapbox-navigation-ios/blob/3.28.4/Sources/MapboxDirections/RouteResponse.swift)
- [[Commit 7c28392 / NAVIOS-2837](https://github.com/mapbox/mapbox-navigation-ios/commit/7c28392)](https://github.com/mapbox/mapbox-navigation-ios/commit/7c28392) addresses the separate missing top-level `code: "Ok"` parsing issue. This report concerns confidence access/preservation, not that parsing fix.
Thank you for your guidance.
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 RouteResponse.swift in the SDK 3.28.4 sources and compare the MapMatchingResponse-to-Route conversion described in the reproduction. Review related issue #4845 and determine whether a supported conversion or metadata-preserving API can expose Match.confidence through NavigationRoutes; done means a documented supported workflow or an agreed narrowly scoped implementation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100