Skip to content

Commit 7cb8ac7

Browse files
authored
Fixed ProfileIdentifier comparison for the custom profile identifiers, so that route refresh is enabled for custom automobileAvoidingTraffic profiles. (#4776)
1 parent cb4950d commit 7cb8ac7

File tree

13 files changed

+70
-53
lines changed

13 files changed

+70
-53
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changes to the Mapbox Navigation SDK for iOS
22

3+
## v2.18.5
4+
5+
### Packaging
6+
7+
* MapboxCoreNavigation now requires [MapboxDirections v2.14.1](https://github.com/mapbox/mapbox-directions-swift/releases/tag/v2.14.1). ([#4776](https://github.com/mapbox/mapbox-navigation-ios/pull/4776))
8+
9+
### Other changes
10+
11+
* Fixed `ProfileIdentifier` comparison for the custom profile identifiers, so that route refresh is enabled for custom `automobileAvoidingTraffic` profiles.
12+
313
## v2.18.4
414

515
### Packaging

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" == 23.9.2
22
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-navigation-native/MapboxNavigationNative.xcframework.json" ~> 204.0.1
3-
github "mapbox/mapbox-directions-swift" ~> 2.12.0
3+
github "mapbox/mapbox-directions-swift" ~> 2.14.0

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" "23.9.2"
22
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-navigation-native/MapboxNavigationNative.xcframework.json" "204.0.1"
3-
github "mapbox/mapbox-directions-swift" "v2.12.0"
3+
github "mapbox/mapbox-directions-swift" "v2.14.1"
44
github "mapbox/turf-swift" "v2.8.0"
55
github "mattgallagher/CwlPreconditionTesting" "2.2.1"
66
github "pointfreeco/swift-snapshot-testing" "1.9.0"

MapboxCoreNavigation.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Pod::Spec.new do |s|
4545
s.module_name = "MapboxCoreNavigation"
4646

4747
s.dependency "MapboxNavigationNative", ">= 204.0.1", "< 205.0.0"
48-
s.dependency "MapboxDirections", "~> 2.12"
48+
s.dependency "MapboxDirections", "~> 2.14"
4949

5050
s.swift_version = "5.5"
5151
end

MapboxNavigation-SPM.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let package = Package(
2222
)
2323
],
2424
dependencies: [
25-
.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.12.0"),
25+
.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", from: "2.14.1"),
2626
.package(name: "MapboxNavigationNative", url: "https://github.com/mapbox/mapbox-navigation-native-ios.git", from: "204.0.1"),
2727
.package(name: "MapboxMaps", url: "https://github.com/mapbox/mapbox-maps-ios.git", from: "10.17.0"),
2828
.package(name: "Solar", url: "https://github.com/ceeK/Solar.git", from: "3.0.0"),

Sources/MapboxCoreNavigation/LegacyRouteController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ open class LegacyRouteController: NSObject, Router, InternalRouter, CLLocationMa
272272
let options = indexedRouteResponse.validatedRouteOptions
273273
self.routeProgress = RouteProgress(route: indexedRouteResponse.currentRoute!, options: options)
274274
self.dataSource = source
275-
self.refreshesRoute = options.profileIdentifier == .automobileAvoidingTraffic && options.refreshingEnabled
275+
self.refreshesRoute = options.profileIdentifier.isAutomobileAvoidingTraffic && options.refreshingEnabled
276276
UIDevice.current.isBatteryMonitoringEnabled = true
277277

278278
super.init()

Sources/MapboxCoreNavigation/MapboxRoutingProvider.swift

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,21 +462,29 @@ public class MapboxRoutingProvider: RoutingProvider {
462462
}
463463

464464
extension ProfileIdentifier {
465-
var nativeProfile: RoutingProfile {
466-
var mode: RoutingMode
465+
var isCycling: Bool {
466+
rawValue.hasSuffix("cycling")
467+
}
468+
469+
var mode: RoutingMode {
467470
switch self {
468-
case .automobile:
469-
mode = .driving
470-
case .automobileAvoidingTraffic:
471-
mode = .drivingTraffic
472-
case .cycling:
473-
mode = .cycling
474-
case .walking:
475-
mode = .walking
471+
case _ where isAutomobile:
472+
return .driving
473+
case _ where isAutomobileAvoidingTraffic:
474+
return .drivingTraffic
475+
case _ where isCycling:
476+
return .cycling
477+
case _ where isWalking:
478+
return .walking
476479
default:
477-
mode = .driving
480+
return .driving
478481
}
479-
return RoutingProfile(mode: mode, account: "mapbox")
482+
}
483+
484+
var nativeProfile: RoutingProfile {
485+
let accountComponent = rawValue.split(separator: "/").first.map(String.init) ?? ""
486+
let account = accountComponent.isEmpty ? "mapbox" : accountComponent
487+
return RoutingProfile(mode: mode, account: account)
480488
}
481489
}
482490

Sources/MapboxCoreNavigation/NavigationRouteOptions.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ open class NavigationRouteOptions: RouteOptions, OptimizedForNavigation {
2626
queryItems: queryItems)
2727
includesAlternativeRoutes = true
2828
attributeOptions = [.expectedTravelTime, .maximumSpeedLimit]
29-
if profileIdentifier == .automobileAvoidingTraffic {
30-
attributeOptions.update(with: .numericCongestionLevel)
31-
}
3229
includesExitRoundaboutManeuver = true
33-
if profileIdentifier == .automobileAvoidingTraffic {
30+
if let profileIdentifier, profileIdentifier.isAutomobileAvoidingTraffic {
31+
attributeOptions.update(with: .numericCongestionLevel)
3432
refreshingEnabled = true
3533
}
3634

@@ -89,11 +87,13 @@ open class NavigationMatchOptions: MatchOptions, OptimizedForNavigation {
8987
profileIdentifier: profileIdentifier,
9088
queryItems: queryItems)
9189
attributeOptions = [.expectedTravelTime]
92-
if profileIdentifier == .automobileAvoidingTraffic {
93-
attributeOptions.update(with: .numericCongestionLevel)
94-
}
95-
if profileIdentifier == .automobile || profileIdentifier == .automobileAvoidingTraffic {
96-
attributeOptions.insert(.maximumSpeedLimit)
90+
if let profileIdentifier {
91+
if profileIdentifier.isAutomobileAvoidingTraffic {
92+
attributeOptions.update(with: .numericCongestionLevel)
93+
}
94+
if profileIdentifier.isAutomobile || profileIdentifier.isAutomobileAvoidingTraffic {
95+
attributeOptions.insert(.maximumSpeedLimit)
96+
}
9797
}
9898

9999
optimizeForNavigation()

Sources/MapboxCoreNavigation/RouteController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ open class RouteController: NSObject {
676676
let options = indexedRouteResponse.validatedRouteOptions
677677

678678
self.routeProgress = RouteProgress(route: indexedRouteResponse.currentRoute!, options: options)
679-
self.refreshesRoute = isRouteOptions && options.profileIdentifier == .automobileAvoidingTraffic && options.refreshingEnabled
679+
self.refreshesRoute = isRouteOptions && options.profileIdentifier.isAutomobileAvoidingTraffic && options.refreshingEnabled
680680

681681
super.init()
682682

0 commit comments

Comments
 (0)