Skip to content

Commit

Permalink
Correct NavigationMatchOptions congestion level in cycling profile … (
Browse files Browse the repository at this point in the history
#4564)

* Correct `NavigationMatchOptions` congestion level in cycling profile (#4563)

Correct the `.numericCongestionLevel` attribute to `.congestionLevel` when using the cycling profile. This is the same as #3495 (#3496) but for `NavigationMatchOptions` instead of `NavigationRouteOptions`.

https://github.com/mapbox/mapbox-navigation-ios/blob/ff4873f77bd91505820e6027f1a4a43efc4a7a3d/Sources/MapboxCoreNavigation/NavigationRouteOptions.swift#L28-L34

Signed-off-by: Matt Robinson <[email protected]>

* Use .numericCongestionLevel option only for driving/traffic profile

* Update logic in NavigationRouteOptions

* Update changelog

* Fix tests

---------

Signed-off-by: Matt Robinson <[email protected]>
Co-authored-by: Matt Robinson <[email protected]>
  • Loading branch information
azarovalex and mattrobmattrob authored Oct 13, 2023
1 parent ff4873f commit 2c637ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes to the Mapbox Navigation SDK for iOS

## main

### Routing

* `NavigationRouteOptions` and `NavigationMatchOptions` no longer include `.numericCongestionLevel` attribute by default for profiles other than `.automobileAvoidingTraffic`.

## v2.17.0

### Packaging
Expand Down
10 changes: 5 additions & 5 deletions Sources/MapboxCoreNavigation/NavigationRouteOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ open class NavigationRouteOptions: RouteOptions, OptimizedForNavigation {
queryItems: queryItems)
includesAlternativeRoutes = true
attributeOptions = [.expectedTravelTime, .maximumSpeedLimit]
if profileIdentifier == .cycling {
// https://github.com/mapbox/mapbox-navigation-ios/issues/3495
attributeOptions.update(with: .congestionLevel)
} else {
if profileIdentifier == .automobileAvoidingTraffic {
attributeOptions.update(with: .numericCongestionLevel)
}
includesExitRoundaboutManeuver = true
Expand Down Expand Up @@ -91,7 +88,10 @@ open class NavigationMatchOptions: MatchOptions, OptimizedForNavigation {
},
profileIdentifier: profileIdentifier,
queryItems: queryItems)
attributeOptions = [.numericCongestionLevel, .expectedTravelTime]
attributeOptions = [.expectedTravelTime]
if profileIdentifier == .automobileAvoidingTraffic {
attributeOptions.update(with: .numericCongestionLevel)
}
if profileIdentifier == .automobile || profileIdentifier == .automobileAvoidingTraffic {
attributeOptions.insert(.maximumSpeedLimit)
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/MapboxCoreNavigationTests/OptionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class OptionsTests: TestCase {
XCTAssertEqual(NavigationRouteOptions(coordinates: coordinates).attributeOptions,
[.numericCongestionLevel, .expectedTravelTime, .maximumSpeedLimit])
XCTAssertEqual(NavigationRouteOptions(coordinates: coordinates, profileIdentifier: .automobile).attributeOptions,
[.numericCongestionLevel, .expectedTravelTime, .maximumSpeedLimit])
[.expectedTravelTime, .maximumSpeedLimit])
XCTAssertEqual(NavigationRouteOptions(coordinates: coordinates, profileIdentifier: .automobileAvoidingTraffic).attributeOptions,
[.numericCongestionLevel, .expectedTravelTime, .maximumSpeedLimit])
// https://github.com/mapbox/mapbox-navigation-ios/issues/3495
XCTAssertEqual(NavigationRouteOptions(coordinates: coordinates, profileIdentifier: .cycling).attributeOptions,
[.congestionLevel, .expectedTravelTime, .maximumSpeedLimit])
[.expectedTravelTime, .maximumSpeedLimit])
XCTAssertEqual(NavigationRouteOptions(coordinates: coordinates, profileIdentifier: .walking).attributeOptions,
[.numericCongestionLevel, .expectedTravelTime, .maximumSpeedLimit])
[.expectedTravelTime, .maximumSpeedLimit])
XCTAssertEqual(NavigationRouteOptions(coordinates: coordinates, profileIdentifier: .init(rawValue: "mapbox/unicycling")).attributeOptions,
[.numericCongestionLevel, .expectedTravelTime, .maximumSpeedLimit])
[.expectedTravelTime, .maximumSpeedLimit])
}
}

0 comments on commit 2c637ce

Please sign in to comment.