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

Hybrid Router #3261

Merged
merged 4 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
* Fixed an issue where `RouteStepProgress.currentIntersection` was always returning invalid value, which in turn caused inability to correctly detect whether specific location along the route is in tunnel, or not. ([#3559](https://github.com/mapbox/mapbox-navigation-ios/pull/3559))
* Renamed the `Locale.usesMetric` property to `Locale.measuresDistancesInMetricUnits`. `Locale.usesMetric` is still available but deprecated. ([#3547](https://github.com/mapbox/mapbox-navigation-ios/pull/3547))
* Fixed an issue where the user interface did not necessarily display distances in the same units as the route by default. `NavigationRouteOptions` and `NavigationMatchOptions` now set `DirectionsOptions.distanceMeasurementSystem` to a default value matching the `NavigationSettings.distanceUnit` property. ([#3541](https://github.com/mapbox/mapbox-navigation-ios/pull/3541))
* Introduced `RoutingProvider` to parameterize routing fetching and refreshing during active guidance sessions. `Directions.calculateWithCache(options:completionHandler:)` and `Directions.calculateOffline(options:completionHandler)` functionality is deprecated by `MapboxRoutingProvider`. It is now recommended to use `MapboxRoutingProvider` to request or refresh routes instead of `Directions` object but you may also provide your own `RoutingProvider` implementation to `NavigationService`, `RouteController` or `LegacyRouteController`. Using `directions` property of listed above entities is discouraged, you should use corresponding `routingProvider` instead, albeit `Directions` also implements the protocol. ([#3261](https://github.com/mapbox/mapbox-navigation-ios/pull/3261))

## v2.0.1

Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

@available(iOS 12.0, *)
lazy var carPlayManager: CarPlayManager = CarPlayManager()
lazy var carPlayManager: CarPlayManager = CarPlayManager(routingProvider: MapboxRoutingProvider(.hybrid))

@available(iOS 12.0, *)
lazy var carPlaySearchController: CarPlaySearchController = CarPlaySearchController()
Expand Down
2 changes: 2 additions & 0 deletions Example/CustomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class CustomViewController: UIViewController {
navigationService = MapboxNavigationService(routeResponse: indexedUserRouteResponse!.routeResponse,
routeIndex: indexedUserRouteResponse!.routeIndex,
routeOptions: userRouteOptions!,
routingProvider: MapboxRoutingProvider(.hybrid),
credentials: NavigationSettings.shared.directions.credentials,
locationSource: locationManager,
simulating: simulateLocation ? .always : .inTunnels)
navigationService.delegate = self
Expand Down
9 changes: 7 additions & 2 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class ViewController: UIViewController {
}

func requestRoute(with options: RouteOptions, success: @escaping RouteRequestSuccess, failure: RouteRequestFailure?) {
NavigationSettings.shared.directions.calculateWithCache(options: options) { (session, result) in
MapboxRoutingProvider().calculateRoutes(options: options) { (session, result) in
switch result {
case let .success(response):
success(response)
Expand Down Expand Up @@ -561,7 +561,12 @@ class ViewController: UIViewController {
func navigationService(response: RouteResponse, routeIndex: Int, options: RouteOptions) -> NavigationService {
let mode: SimulationMode = simulationButton.isSelected ? .always : .inTunnels

return MapboxNavigationService(routeResponse: response, routeIndex: routeIndex, routeOptions: options, simulating: mode)
return MapboxNavigationService(routeResponse: response,
routeIndex: routeIndex,
routeOptions: options,
routingProvider: MapboxRoutingProvider(.hybrid),
credentials: NavigationSettings.shared.directions.credentials,
simulating: mode)
}

// MARK: - Utility methods
Expand Down
24 changes: 20 additions & 4 deletions MapboxNavigation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
16EF6C1E21193A9600AA580B /* CarPlayManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16EF6C1D21193A9600AA580B /* CarPlayManagerTests.swift */; };
16EF6C22211BA4B300AA580B /* CarPlayMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16EF6C21211BA4B300AA580B /* CarPlayMapViewController.swift */; };
1FFDFD92249C1AA80091746A /* JunctionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FFDFD91249C1AA70091746A /* JunctionView.swift */; };
2B01E4B6274671550002A5F7 /* MapboxRoutingProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B01E4B3274671540002A5F7 /* MapboxRoutingProvider.swift */; };
2B01E4B7274671550002A5F7 /* RoutingProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B01E4B4274671540002A5F7 /* RoutingProvider.swift */; };
2B01E4B8274671550002A5F7 /* Directions+RoutingProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B01E4B5274671550002A5F7 /* Directions+RoutingProvider.swift */; };
2B07444124B4832400615E87 /* TokenTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B07444024B4832400615E87 /* TokenTestViewController.swift */; };
2B3ED38C2609FA7900861A84 /* ArrivalController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B3ED38B2609FA7900861A84 /* ArrivalController.swift */; };
2B3ED3962609FB2300861A84 /* CameraController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B3ED3952609FB2300861A84 /* CameraController.swift */; };
Expand All @@ -50,7 +53,6 @@
2B81EC28241A237E00145086 /* SpeechSynthesizersControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B81EC27241A237E00145086 /* SpeechSynthesizersControllerTests.swift */; };
2B871272263966F0001082A9 /* TileStoreConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B8712682639631C001082A9 /* TileStoreConfiguration.swift */; };
2B91C9B12416357700E532A5 /* MapboxSpeechSynthesizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B91C9B02416357700E532A5 /* MapboxSpeechSynthesizer.swift */; };
2B955B1C25EFDDCB00BBFEC6 /* Directions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B955B1B25EFDDCB00BBFEC6 /* Directions.swift */; };
2BBED92F265E2C7D00F90032 /* NativeHandlersFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBED92E265E2C7D00F90032 /* NativeHandlersFactory.swift */; };
2BBED93B267A3AB900F90032 /* BillingHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBED93A267A3AB900F90032 /* BillingHandler.swift */; };
2BBEEDA52508DB1700C8DA4A /* RouteLegProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBEEDA42508DB1700C8DA4A /* RouteLegProgress.swift */; };
Expand All @@ -64,6 +66,8 @@
2BE7013D25359C7B00F46E4E /* RouteAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BE7013C25359C7B00F46E4E /* RouteAlert.swift */; };
2BE7016925371E3400F46E4E /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BE7016825371E3400F46E4E /* Incident.swift */; };
2BE70189253734A000F46E4E /* TollCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BE7012C2535946300F46E4E /* TollCollection.swift */; };
2BF398C1274BDEA8000C9A72 /* Directions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BF398C0274BDEA8000C9A72 /* Directions.swift */; };
2BF398C3274FE99A000C9A72 /* HandlerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BF398C2274FE99A000C9A72 /* HandlerFactory.swift */; };
2E50E0C0264E35CA009D3848 /* RoadObjectMatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E50E0BF264E35CA009D3848 /* RoadObjectMatcher.swift */; };
2E50E0D2264E468B009D3848 /* RoadObjectMatcherError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E50E0D1264E468B009D3848 /* RoadObjectMatcherError.swift */; };
2E50E0DC264E49C8009D3848 /* RoadObjectMatcherDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E50E0DB264E49C8009D3848 /* RoadObjectMatcherDelegate.swift */; };
Expand Down Expand Up @@ -538,6 +542,9 @@
16EF6C1D21193A9600AA580B /* CarPlayManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlayManagerTests.swift; sourceTree = "<group>"; };
16EF6C21211BA4B300AA580B /* CarPlayMapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlayMapViewController.swift; sourceTree = "<group>"; };
1FFDFD91249C1AA70091746A /* JunctionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JunctionView.swift; sourceTree = "<group>"; };
2B01E4B3274671540002A5F7 /* MapboxRoutingProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapboxRoutingProvider.swift; sourceTree = "<group>"; };
2B01E4B4274671540002A5F7 /* RoutingProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoutingProvider.swift; sourceTree = "<group>"; };
2B01E4B5274671550002A5F7 /* Directions+RoutingProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Directions+RoutingProvider.swift"; sourceTree = "<group>"; };
2B07444024B4832400615E87 /* TokenTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenTestViewController.swift; sourceTree = "<group>"; };
2B3ED38B2609FA7900861A84 /* ArrivalController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrivalController.swift; sourceTree = "<group>"; };
2B3ED3952609FB2300861A84 /* CameraController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraController.swift; sourceTree = "<group>"; };
Expand All @@ -554,7 +561,6 @@
2B81EC27241A237E00145086 /* SpeechSynthesizersControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeechSynthesizersControllerTests.swift; sourceTree = "<group>"; };
2B8712682639631C001082A9 /* TileStoreConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileStoreConfiguration.swift; sourceTree = "<group>"; };
2B91C9B02416357700E532A5 /* MapboxSpeechSynthesizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxSpeechSynthesizer.swift; sourceTree = "<group>"; };
2B955B1B25EFDDCB00BBFEC6 /* Directions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Directions.swift; sourceTree = "<group>"; };
2BBED92E265E2C7D00F90032 /* NativeHandlersFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeHandlersFactory.swift; sourceTree = "<group>"; };
2BBED93A267A3AB900F90032 /* BillingHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BillingHandler.swift; sourceTree = "<group>"; };
2BBEEDA42508DB1700C8DA4A /* RouteLegProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouteLegProgress.swift; sourceTree = "<group>"; };
Expand All @@ -568,6 +574,8 @@
2BE701342535948100F46E4E /* RestStop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestStop.swift; sourceTree = "<group>"; };
2BE7013C25359C7B00F46E4E /* RouteAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouteAlert.swift; sourceTree = "<group>"; };
2BE7016825371E3400F46E4E /* Incident.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Incident.swift; sourceTree = "<group>"; };
2BF398C0274BDEA8000C9A72 /* Directions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Directions.swift; sourceTree = "<group>"; };
2BF398C2274FE99A000C9A72 /* HandlerFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HandlerFactory.swift; sourceTree = "<group>"; };
2E50E0BF264E35CA009D3848 /* RoadObjectMatcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoadObjectMatcher.swift; sourceTree = "<group>"; };
2E50E0D1264E468B009D3848 /* RoadObjectMatcherError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoadObjectMatcherError.swift; sourceTree = "<group>"; };
2E50E0DB264E49C8009D3848 /* RoadObjectMatcherDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoadObjectMatcherDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1750,7 +1758,6 @@
C582FD5E203626E900A9086E /* CLLocationDirection.swift */,
2E82B9DB26E61F4600B7837F /* CongestionLevel.swift */,
C5D9800E1EFBCDAD006DBF2E /* Date.swift */,
2B955B1B25EFDDCB00BBFEC6 /* Directions.swift */,
3A163AE2249901D000D66A0D /* FixLocation.swift */,
DAF27247264E028B00C0AC37 /* Geometry.swift */,
C51DF8651F38C31C006C6A15 /* Locale.swift */,
Expand Down Expand Up @@ -1810,11 +1817,14 @@
B4843886270F8E1600E161E6 /* SimulationType.swift */,
2BBED93A267A3AB900F90032 /* BillingHandler.swift */,
C58D6BAC1DDCF2AE00387F53 /* CoreConstants.swift */,
2BF398C0274BDEA8000C9A72 /* Directions.swift */,
2B01E4B5274671550002A5F7 /* Directions+RoutingProvider.swift */,
351BEC0B1E5BCC72006FE110 /* DistanceFormatter.swift */,
B417913A2624F9EA001E0348 /* MBXInfo.plist */,
C5ADFBCD1DDCC7840011824B /* Info.plist */,
C5ADFBCC1DDCC7840011824B /* MapboxCoreNavigation.h */,
41B901EA271048BD007F9F78 /* HistoryRecording.swift */,
2BF398C2274FE99A000C9A72 /* HandlerFactory.swift */,
2BBED92E265E2C7D00F90032 /* NativeHandlersFactory.swift */,
353E68FB1EF0B7F8007B2AE5 /* NavigationLocationManager.swift */,
C5E7A31B1F4F6828001CB015 /* NavigationRouteOptions.swift */,
Expand All @@ -1833,6 +1843,8 @@
2B7ACA9925E3F84600B0ACFD /* PredictiveCacheManager.swift */,
3582A25120EFA9680029C5DE /* RouterDelegate.swift */,
C5ADFBFB1DDCC9AD0011824B /* RouteProgress.swift */,
2B01E4B4274671540002A5F7 /* RoutingProvider.swift */,
2B01E4B3274671540002A5F7 /* MapboxRoutingProvider.swift */,
2BBEEDA42508DB1700C8DA4A /* RouteLegProgress.swift */,
2BBEEDA62508E1E300C8DA4A /* RouteStepProgress.swift */,
3582A24F20EEC46B0029C5DE /* Router.swift */,
Expand Down Expand Up @@ -2717,24 +2729,28 @@
3A163AE3249901D000D66A0D /* FixLocation.swift in Sources */,
2E50E0D2264E468B009D3848 /* RoadObjectMatcherError.swift in Sources */,
8D2AA745211CDD4000EB7F72 /* NavigationService.swift in Sources */,
2B01E4B8274671550002A5F7 /* Directions+RoutingProvider.swift in Sources */,
2B7ACA9C25E3F84700B0ACFD /* PredictiveCacheOptions.swift in Sources */,
35A5413B1EFC052700E49846 /* RouteOptions.swift in Sources */,
DA5F44F525F07D3B00F573EC /* RoadObjectStoreDelegate.swift in Sources */,
2E82B9DC26E61F4600B7837F /* CongestionLevel.swift in Sources */,
DA5F44C725F07AB700F573EC /* RoadName.swift in Sources */,
DA5F44AC25F07A6800F573EC /* RoadGraphPosition.swift in Sources */,
2E50E0E6264E49EF009D3848 /* OpenLRIdentifier.swift in Sources */,
2BF398C1274BDEA8000C9A72 /* Directions.swift in Sources */,
353E69041EF0C4E5007B2AE5 /* SimulatedLocationManager.swift in Sources */,
2B01E4B7274671550002A5F7 /* RoutingProvider.swift in Sources */,
DA5F450025F07DE200F573EC /* ElectronicHorizonOptions.swift in Sources */,
DAFA92071F01735000A7FB09 /* DistanceFormatter.swift in Sources */,
2B955B1C25EFDDCB00BBFEC6 /* Directions.swift in Sources */,
DAF27252264E02D800C0AC37 /* RoadObject.swift in Sources */,
5A39B9282498F9890026DFD1 /* PassiveLocationManager.swift in Sources */,
118D883526F8CA0700B2ED7B /* EndOfRouteFeedback.swift in Sources */,
C5C94C1D1DDCD2370097296A /* RouteProgress.swift in Sources */,
2BBED93B267A3AB900F90032 /* BillingHandler.swift in Sources */,
2BE701352535948100F46E4E /* RestStop.swift in Sources */,
2B01E4B6274671550002A5F7 /* MapboxRoutingProvider.swift in Sources */,
8D4CF9C621349FFB009C3FEE /* NavigationServiceDelegate.swift in Sources */,
2BF398C3274FE99A000C9A72 /* HandlerFactory.swift in Sources */,
118D883626F8CA0700B2ED7B /* ActiveNavigationFeedbackType.swift in Sources */,
C5CFE4881EF2FD4C006F48E8 /* MMEEventsManager.swift in Sources */,
11B3D6D626A60EBD0057C6F4 /* ActiveNavigationEventDetails.swift in Sources */,
Expand Down
7 changes: 0 additions & 7 deletions Sources/MapboxCoreNavigation/CoreNavigationNavigator.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import MapboxNavigationNative
import MapboxDirections
@_implementationOnly import MapboxCommon_Private
@_implementationOnly import MapboxNavigationNative_Private

class Navigator {

Expand All @@ -18,12 +17,6 @@ class Navigator {

private(set) var cacheHandle: CacheHandle

lazy var routerInterface: MapboxNavigationNative_Private.RouterInterface = {
return MapboxNavigationNative_Private.RouterFactory.build(for: .hybrid,
cache: cacheHandle,
historyRecorder: historyRecorder)
}()

var mostRecentNavigationStatus: NavigationStatus? = nil

private(set) var tileStore: TileStore
Expand Down
Loading