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

Navigation Native, Part 2 #1618

Merged
merged 50 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
faf2e4a
Bring in nav-native
frederoni Aug 22, 2018
f4d0cd5
Fix Obj-C example
frederoni Aug 30, 2018
324b767
Bump dependencies
frederoni Sep 27, 2018
8ac2a7e
Update to nav-native 3.0
frederoni Sep 27, 2018
4c40994
Switch to dynamic flavor of nav-native and fix merge conflicts
frederoni Sep 27, 2018
05e13b0
Link and embed MapboxNavigationNative in CarPlay example app
Sep 27, 2018
f536153
Documenting `NavigationService`, updating existing docs.
Sep 27, 2018
351fac4
Hooking up the Carplay End Of Route template to the very-much-extant …
Sep 27, 2018
919c458
Pin nav-native to specific version
frederoni Sep 28, 2018
8e160c8
Replace conversion functions with initializers
frederoni Sep 28, 2018
e1d0b10
NativeRouteController -> PortableRouteController
frederoni Sep 28, 2018
0e124c0
Add a meaningful assertion message
frederoni Sep 28, 2018
b18dae9
func -> computed property
frederoni Sep 28, 2018
3883aad
Merge branch 'epic/nav-native' into nav-native-2
Sep 28, 2018
a3fbaed
PR Comments, Removing accidental usage of over-the-wire Directions cl…
Sep 28, 2018
8b389d0
Fix up test overlooked by running on wrong sim version
Sep 28, 2018
a41c39d
Fix up CarPlayManager conditional providing of MapboxNavigationService
Sep 28, 2018
d28008b
Public documentation updates
Sep 29, 2018
9e9e582
Upgrading Nav-Native deliverable and switching default router over to…
Sep 29, 2018
90e325b
Fixing issue where the NVC didn't have the correct method signature
Sep 29, 2018
be50df4
Fixing issue where off-routing at intersection between steps would no…
Sep 30, 2018
e55fb31
Fixing testing issue where Native Navigator requires a few 'good' upd…
Sep 30, 2018
9ef649c
Fixing issue where apple links things spookily when you don't refer t…
Sep 30, 2018
aa040be
Updating cartfile resolution for newest build
Sep 30, 2018
dc32804
Adding obsoletes to initalizers
Sep 30, 2018
8d02b40
Changing `isInTunnel` to be an instance method -- which will help us …
Sep 30, 2018
3b83a71
typo
Sep 30, 2018
f223972
updating release version resolution
Sep 30, 2018
12ba9da
Adding additional obsoletes, moving all to extension, removing RMVC a…
Sep 30, 2018
3aa45f1
Adding proper access keywords onto `ExitView` and `GenericRouteShield…
Sep 30, 2018
ab721c5
Adding proper privacy modifiers for `ExitView`. Also adding some miss…
Sep 30, 2018
eff5a53
YES ONLY END SIMULATION IF WE'RE NOT SIMULATING BRILLIANT IDEA JERRAD
Oct 1, 2018
5215374
Arm the timer on the first good location update.
Oct 1, 2018
41f8d9d
Update dependencies
Oct 1, 2018
96c28d5
Remove pinned branch of MapboxDirections from Podfile integration test
Oct 1, 2018
4a87a13
Updating pod integation Podfile.lock
Oct 1, 2018
afce27d
Fixing issues in relation to poor GPS route simulation
Oct 1, 2018
1c78fce
typo
Oct 1, 2018
0bbcb07
Merge branch 'epic/nav-native' into nav-native-2
Oct 1, 2018
cab8775
Updating carfile
Oct 1, 2018
f738d16
Improving changelog, adding readme update
Oct 1, 2018
858767b
Pinning nav-native to 3.1.4
Oct 1, 2018
9008fe4
This sounds nice
Oct 1, 2018
43d3cce
Update CHANGELOG.md
1ec5 Oct 1, 2018
5fcf351
ONE MORE TIME
Oct 1, 2018
b281a9e
just kidding
Oct 1, 2018
74e9f72
YES SORRY MISTER PODFILE TEST CANT FORGET ABOUT YOU
Oct 1, 2018
5e737e0
also bringing in the project changes
Oct 1, 2018
a4c59eb
updating jazzy
Oct 1, 2018
9c6c932
Updating cover doc
Oct 1, 2018
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

## master

### Packaging

* Added a dependency on the Mapbox Navigation Native framework. If you use Carthage to install this framework, your target should also link against `MapboxNavigationNative.framework`. ([#1618](https://github.com/mapbox/mapbox-navigation-ios/pull/1618))

### User location

* Added a `NavigationService` protocol implemented by classes that provide location awareness functionality. `RouteController` and a new `MapboxNavigationService` class both conform to this protocol. ([#1602](https://github.com/mapbox/mapbox-navigation-ios/pull/1602))
* `NavigationViewController.init(for:styles:directions:styles:routeController:locationManager:voiceController:eventsManager)` has been renamed `NavigationViewController.init(for:styles:navigationService:voiceController:)`.
* `NavigationViewController.routeController` has been replaced by `NavigationViewController.navigationService`.
* If you currently use `RouteController` directly, you should migrate to `NavigationService`.
* If you currently use `SimulatedLocationManager` directly, you should instead pass `SimulationOption.always` into `MapboxNavigationService(route:directions:locationSource:eventsManagerType:simulating:)`.
* Improved the reliability of off-route detection. ([#1618](https://github.com/mapbox/mapbox-navigation-ios/pull/1618))

### User interface

Expand Down
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" ~> 4.3
github "mapbox/MapboxDirections.swift" ~> 0.23.0
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" ~> 3.1
github "mapbox/MapboxDirections.swift" ~> 0.24
github "mapbox/turf-swift" ~> 0.2
github "mapbox/mapbox-events-ios" ~> 0.5
github "ceeK/Solar" ~> 2.1.0
Expand Down
7 changes: 4 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
binary "https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json" "4.4.1"
binary "https://www.mapbox.com/ios-sdk/MapboxNavigationNative.json" "3.1.4"
github "CedarBDD/Cedar" "v1.0"
github "Quick/Nimble" "v7.3.1"
github "Quick/Quick" "v1.3.2"
github "ceeK/Solar" "2.1.0"
github "mapbox/MapboxDirections.swift" "v0.23.0"
github "mapbox/MapboxDirections.swift" "v0.24.0"
github "mapbox/MapboxGeocoder.swift" "v0.10.0"
github "mapbox/mapbox-events-ios" "v0.5.1"
github "mapbox/mapbox-voice-swift" "v0.0.1"
github "mapbox/turf-swift" "v0.2.0"
github "mapbox/mapbox-voice-swift" "v0.0.2"
github "mapbox/turf-swift" "v0.2.1"
github "raphaelmor/Polyline" "v4.2.0"
github "uber/ios-snapshot-test-case" "4.0.0"
2 changes: 1 addition & 1 deletion Examples/Objective-C/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ - (void)getRoute {
}

- (void)startNavigation:(MBRoute *)route {
MBNavigationService *service = [[MBNavigationService alloc ] initWithRoute:route directions:self.directions locationSource:nil eventsManagerType:nil simulating:MBNavigationSimulationOptionsAlways];
MBNavigationService *service = [[MBNavigationService alloc] initWithRoute:route directions:self.directions locationSource:nil eventsManagerType:nil simulating:MBNavigationSimulationOptionsAlways routerType:nil];

self.navigation = service;
MBNavigationViewController *controller = [[MBNavigationViewController alloc] initWithRoute:route styles:nil navigationService:service voiceController: nil];
Expand Down
6 changes: 3 additions & 3 deletions Examples/Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ class ViewController: UIViewController, MGLMapViewDelegate {
func navigationService() -> NavigationService? {
guard let route = routes?.first else { return nil }
let simulate = simulationButton.isSelected
let option: SimulationOption = simulate ? .always : .onPoorGPS
return MapboxNavigationService(route: route, simulating: option)
let mode: SimulationMode = simulate ? .always : .onPoorGPS
return MapboxNavigationService(route: route, simulating: mode)
}

func presentAndRemoveMapview(_ navigationViewController: NavigationViewController) {
Expand Down Expand Up @@ -335,7 +335,7 @@ extension ViewController: VoiceControllerDelegate {
return SpokenInstruction(distanceAlongStep: instruction.distanceAlongStep, text: "New Instruction!", ssmlText: "<speak>New Instruction!</speak>")
}

// By default, the routeController will attempt to filter out bad locations.
// By default, the navigation service will attempt to filter out unqualified locations.
// If however you would like to filter these locations in,
// you can conditionally return a Bool here according to your own heuristics.
// See CLLocation.swift `isQualified` for what makes a location update unqualified.
Expand Down
3 changes: 2 additions & 1 deletion MapboxCoreNavigation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxCoreNavigation"

s.dependency "MapboxDirections.swift", "~> 0.23.0"
s.dependency "MapboxNavigationNative", "~> 3.1"
s.dependency "MapboxDirections.swift", "~> 0.24.0"
s.dependency "MapboxMobileEvents", "~> 0.5"
s.dependency "Turf", "~> 0.2"

Expand Down
15 changes: 15 additions & 0 deletions MapboxCoreNavigation/CLLocation.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CoreLocation
import MapboxDirections
import MapboxNavigationNative
import Turf

extension CLLocation {
Expand All @@ -9,6 +10,10 @@ extension CLLocation {
0...100 ~= horizontalAccuracy
}

var isQualifiedForStartingRoute: Bool {
return 0...20 ~= horizontalAccuracy
}

/// Returns a dictionary representation of the location.
public var dictionaryRepresentation: [String: Any] {
var locationDictionary: [String: Any] = [:]
Expand Down Expand Up @@ -59,6 +64,16 @@ extension CLLocation {
timestamp: date!)
}

convenience init(_ location: MBFixLocation) {
self.init(coordinate: location.location,
altitude: location.altitude?.doubleValue ?? 0,
horizontalAccuracy: location.accuracyHorizontal?.doubleValue ?? 0,
verticalAccuracy: 0,
course: location.bearing?.doubleValue ?? 0,
speed: location.speed?.doubleValue ?? 0,
timestamp: location.time)
}

/**
Returns a Boolean value indicating whether the receiver is within a given distance of a route step.
*/
Expand Down
4 changes: 2 additions & 2 deletions MapboxCoreNavigation/EventDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ struct EventDetails: Encodable {
var newDurationRemaining: TimeInterval?
var newGeometry: String?

init(dataSource: EventsManagerDataSource, session: SessionState) {
init(dataSource: EventsManagerDataSource, session: SessionState, defaultInterface: Bool) {
coordinate = dataSource.location?.coordinate
startTimestamp = session.departureTimestamp ?? nil
sdkIdentifier = dataSource.usesDefaultUserInterface ? "mapbox-navigation-ui-ios" : "mapbox-navigation-ios"
sdkIdentifier = defaultInterface ? "mapbox-navigation-ui-ios" : "mapbox-navigation-ios"
profile = dataSource.routeProgress.route.routeOptions.profileIdentifier.rawValue
simulation = dataSource.locationProvider is SimulatedLocationManager.Type

Expand Down
17 changes: 8 additions & 9 deletions MapboxCoreNavigation/EventsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import MapboxMobileEvents
import MapboxDirections

/**
The `EventsManager` is responsible for being the liaison between the RouteController and the telemetry framework.
The `EventsManager` is responsible for being the liaison between MapboxCoreNavigation and the telemetry framework.

`SessionState` is a struct that stores all memoized statistics that we later send to the telemetry engine.
*/

@objc public protocol EventsManagerDataSource: class {
var routeProgress: RouteProgress { get }
var usesDefaultUserInterface: Bool { get set }
var location: CLLocation? { get }
var desiredAccuracy: CLLocationAccuracy { get }
var locationProvider: NavigationLocationManager.Type { get }
Expand All @@ -36,7 +35,7 @@ open class EventsManager: NSObject {
let token = dict["MGLMapboxAccessToken"] as? String else {
//we can assert here because if the token was passed in, it would of overriden this closure.
//we return an empty string so we don't crash in production (in keeping with behavior of `assert`)
assertionFailure("`accessToken` must be set in the Info.plist as `MGLMapboxAccessToken` or the `Route` passed into the `RouteController` must have the `accessToken` property set.")
assertionFailure("`accessToken` must be set in the Info.plist as `MGLMapboxAccessToken` or the `Route` passed into the `NavigationService` must have the `accessToken` property set.")
return ""
}
return token
Expand Down Expand Up @@ -79,15 +78,15 @@ open class EventsManager: NSObject {
manager.isMetricsEnabledInSimulator = true
manager.isMetricsEnabledForInUsePermissions = true
let userAgent = usesDefaultUserInterface ? "mapbox-navigation-ui-ios" : "mapbox-navigation-ios"
manager.initialize(withAccessToken: accessToken, userAgentBase: userAgent, hostSDKVersion: String(describing: Bundle(for: RouteController.self).object(forInfoDictionaryKey: "CFBundleShortVersionString")!))
manager.initialize(withAccessToken: accessToken, userAgentBase: userAgent, hostSDKVersion: String(describing: Bundle.mapboxCoreNavigation.object(forInfoDictionaryKey: "CFBundleShortVersionString")!))
manager.disableLocationMetrics()
manager.sendTurnstileEvent()
}

func navigationCancelEvent(rating potentialRating: Int? = nil, comment: String? = nil) -> EventDetails {

let rating = potentialRating ?? MMEEventsManager.unrated
var event = EventDetails(dataSource: dataSource, session: sessionState)
var event = EventDetails(dataSource: dataSource, session: sessionState, defaultInterface: usesDefaultUserInterface)
event.event = MMEEventTypeNavigationCancel
event.arrivalTimestamp = sessionState?.arrivalTimestamp

Expand All @@ -102,13 +101,13 @@ open class EventsManager: NSObject {
}

func navigationDepartEvent() -> EventDetails {
var event = EventDetails(dataSource: dataSource, session: sessionState)
var event = EventDetails(dataSource: dataSource, session: sessionState, defaultInterface: usesDefaultUserInterface)
event.event = MMEEventTypeNavigationDepart
return event
}

func navigationArriveEvent() -> EventDetails {
var event = EventDetails(dataSource: dataSource, session: sessionState)
var event = EventDetails(dataSource: dataSource, session: sessionState, defaultInterface: usesDefaultUserInterface)
event.event = MMEEventTypeNavigationArrive
return event
}
Expand All @@ -122,7 +121,7 @@ open class EventsManager: NSObject {
}

func navigationFeedbackEvent(type: FeedbackType, description: String?) -> EventDetails {
var event = EventDetails(dataSource: dataSource, session: sessionState)
var event = EventDetails(dataSource: dataSource, session: sessionState, defaultInterface: usesDefaultUserInterface)
event.event = MMEEventTypeNavigationFeedback

event.userId = UIDevice.current.identifierForVendor?.uuidString
Expand All @@ -137,7 +136,7 @@ open class EventsManager: NSObject {
func navigationRerouteEvent(eventType: String = MMEEventTypeNavigationReroute) -> EventDetails {
let timestamp = Date()

var event = EventDetails(dataSource: dataSource, session: sessionState)
var event = EventDetails(dataSource: dataSource, session: sessionState, defaultInterface: usesDefaultUserInterface)
event.event = eventType
if let lastRerouteDate = sessionState?.lastRerouteDate {
event.secondsSinceLastReroute = round(timestamp.timeIntervalSince(lastRerouteDate))
Expand Down
4 changes: 2 additions & 2 deletions MapboxCoreNavigation/Feedback.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Foundation

/**
Feedback type is used to specify the type of feedback being recorded with `RouteController.recordFeedback()`.
Feedback type is used to specify the type of feedback being recorded with `EventsManager.recordFeedback(type:description:)`.
*/
@objc(MBFeedbackType)
public enum FeedbackType: Int, CustomStringConvertible {
/**
Indicates general feedback. You should provide a `description` string to `RouteController.recordFeedback()` to elaborate on the feedback if possible.
Indicates general feedback. You should provide a `description` string to `EventsManager.recordFeedback(type:description:)` to elaborate on the feedback if possible.
*/
case general

Expand Down
16 changes: 16 additions & 0 deletions MapboxCoreNavigation/MBFixLocation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Foundation
import MapboxNavigationNative
import CoreLocation

extension MBFixLocation {

convenience init(_ location: CLLocation) {
self.init(location: location.coordinate,
time: location.timestamp,
speed: location.speed as NSNumber,
bearing: location.course as NSNumber,
altitude: location.altitude as NSNumber,
accuracyHorizontal: location.horizontalAccuracy as NSNumber,
provider: nil)
}
}
1 change: 1 addition & 0 deletions MapboxCoreNavigation/NavigationRouteOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ open class NavigationRouteOptions: RouteOptions {
return $0
}, profileIdentifier: profileIdentifier)
includesAlternativeRoutes = true
shapeFormat = .polyline6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does MapboxNavigationNative handle polyline 5 format gracefully? If not, this is the first property being set here that the SDK strictly requires. Perhaps we should assert on the use of polyline 6 format or just go ahead and set it at the point of use in addition to here.

includesSteps = true
routeShapeResolution = .full
attributeOptions = [.congestionLevel, .expectedTravelTime]
Expand Down
Loading