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

MapboxNavigationNative v18.0.1 #2477

Merged
merged 13 commits into from
Aug 5, 2020
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
59 changes: 33 additions & 26 deletions CHANGELOG.md

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@ When reporting a bug in the navigation SDK itself, please indicate:

To build this SDK, you need Xcode 11.4.1 and [Carthage](https://github.com/Carthage/Carthage/) v0.35:

1. Create a [Bintray](https://bintray.com/mapbox) account, then [request to be added to the Mapbox Navigation SDK beta testing program](https://docs.google.com/forms/d/1mzknLZf5W9o8-KnQJ1GiYyG2grXVRqNxqHruWYTRVPc/viewform).

1. [Get a Bintray API key](https://bintray.com/profile/edit).
1. Go to your [Mapbox account dashboard](https://account.mapbox.com/) and create an access token that has the `DOWNLOADS:READ` scope. **PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file.** Create a file named `.netrc` in your home directory if it doesn’t already exist, then add the following lines to the end of the file:
```
machine api.mapbox.com
login mapbox
password PRIVATE_MAPBOX_API_TOKEN
```
where _PRIVATE_MAPBOX_API_TOKEN_ is your Mapbox API token with the `DOWNLOADS:READ` scope.

1. Add or append to a .netrc file in your home directory:
1. _(Optional)_ Clear your Carthage caches:
```bash
rm -rf ~/Library/Caches/carthage/ ~/Library/Caches/org.carthage.CarthageKit/binaries/{MapboxAccounts,MapboxCommon-ios,MapboxNavigationNative,mapbox-ios-sdk-dynamic}
```
machine dl.bintray.com
login username@mapbox
password BINTRAY_API_KEY

1. Create a [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#github-repositories) with the following dependency:
```cartfile
github "mapbox/mapbox-navigation-ios" "v1.0.0-beta.1"
```
where _username_ is your user name and _BINTRAY_API_KEY_ is your Bintray API key.

1. Run `carthage bootstrap --platform iOS --cache-builds --use-netrc`.

Expand Down
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
binary "https://www.mapbox.com/ios-sdk/MapboxAccounts.json" ~> 2.3.0
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-maps/mapbox-ios-sdk-dynamic.json" ~> 6.0
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-navigation-native/MapboxNavigationNative.json" ~> 14.1.5
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-navigation-native/MapboxNavigationNative.json" ~> 18.0.2
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon-ios.json" == 4.0.0
github "mapbox/mapbox-directions-swift" ~> 0.33
github "mapbox/turf-swift" ~> 0.5
github "mapbox/mapbox-events-ios" ~> 0.10
Expand Down
3 changes: 2 additions & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon-ios.json" "4.0.0"
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-maps/mapbox-ios-sdk-dynamic.json" "6.0.0"
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-navigation-native/MapboxNavigationNative.json" "14.1.6"
binary "https://api.mapbox.com/downloads/v2/carthage/mobile-navigation-native/MapboxNavigationNative.json" "18.0.2"
binary "https://www.mapbox.com/ios-sdk/MapboxAccounts.json" "2.3.0"
github "CedarBDD/Cedar" "v1.0"
github "Quick/Nimble" "v8.1.1"
Expand Down
4 changes: 2 additions & 2 deletions Example/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
/* Title of sheet confirming waypoint removal */
"REMOVE_WAYPOINT_CONFIRM_TITLE" = "Remove Waypoint?";

/* Alert message when a router has been configured; 1 = number of map tiles */
"ROUTER_CONFIGURED_MSG" = "Router configured with %ld tile(s).";
/* Alert message when a router has been configured */
"ROUTER_CONFIGURED_MSG" = "Router configured.";

/* Title of table view item that downloads a new offline region */
"SETTINGS_ITEM_DOWNLOAD_REGION_TITLE" = "Download Region";
Expand Down
2 changes: 1 addition & 1 deletion Example/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SettingsViewController: UITableViewController {
let tilesURL = Bundle.mapboxCoreNavigation.suggestedTileURL(version: selectedOfflineVersion)

Settings.directions.configureRouter(tilesURL: tilesURL!) { [weak self] (numberOfTiles) in
let message = String.localizedStringWithFormat(NSLocalizedString("ROUTER_CONFIGURED_MSG", value: "Router configured with %ld tile(s).", comment: "Alert message when a router has been configured; 1 = number of map tiles"), numberOfTiles)
let message = NSLocalizedString("ROUTER_CONFIGURED_MSG", value: "Router configured.", comment: "Alert message when a router has been configured")
self?.presentAlert(message: message)
}
}
Expand Down
19 changes: 1 addition & 18 deletions Example/en.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ROUTER_CONFIGURED_MSG</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@tiles@</string>
<key>tiles</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>one</key>
<string>Router configured with %ld tile.</string>
<key>other</key>
<string>Router configured with %ld tiles.</string>
</dict>
</dict>
</dict>
<dict/>
</plist>
22 changes: 0 additions & 22 deletions Example/yo.lproj/Localizable.stringsdict

This file was deleted.

2 changes: 1 addition & 1 deletion MapboxCoreNavigation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.module_name = "MapboxCoreNavigation"

s.dependency "MapboxNavigationNative", "~> 14.1.5"
s.dependency "MapboxNavigationNative", "~> 18.0.2"
s.dependency "MapboxAccounts", "~> 2.3.0"
s.dependency "MapboxDirections", "~> 0.33.0"
s.dependency "MapboxMobileEvents", "~> 0.10.2" # Always pin to a patch release if pre-1.0
Expand Down
1 change: 1 addition & 0 deletions MapboxCoreNavigation/FixLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extension FixLocation {
}

self.init(coordinate: location.coordinate,
monotonicTimestampNanoseconds: 0, // use time instead; see also `Navigator.status(at:)`
time: location.timestamp,
speed: location.speed >= 0 ? location.speed as NSNumber : nil,
bearing: location.course >= 0 ? location.course as NSNumber : nil,
Expand Down
9 changes: 9 additions & 0 deletions MapboxCoreNavigation/Navigator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation
import MapboxNavigationNative

extension Navigator {
func status(at timestamp: Date) -> NavigationStatus {
// Because `FixLocation(_:)` passes in 0 as `monotonicTimestampNanoseconds`, we need to always call `getStatusForTimestamp(_:)` instead of `getStatusForMonotonicTimestampNanoseconds(_:)`.
return getStatusForTimestamp(timestamp)
}
}
10 changes: 5 additions & 5 deletions MapboxCoreNavigation/OfflineDirections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MapboxNavigationNative
/**
A closure to call when the `NavigationDirections` router has been configured completely.
*/
public typealias NavigationDirectionsCompletionHandler = (_ numberOfTiles: UInt64) -> Void
public typealias NavigationDirectionsCompletionHandler = (_ tilesURL: URL) -> Void

/**
An error that occurs when calculating directions potentially offline using the `NavigationDirections.calculate(_:offline:completionHandler:)` method.
Expand Down Expand Up @@ -117,9 +117,9 @@ public class NavigationDirections: Directions {
public func configureRouter(tilesURL: URL, completionHandler: @escaping NavigationDirectionsCompletionHandler) {
NavigationDirectionsConstants.offlineSerialQueue.sync {
let params = RouterParams(tilesPath: tilesURL.path, inMemoryTileCache: nil, mapMatchingSpatialCache: nil, threadsCount: nil, endpointConfig: nil)
let tileCount = self.navigator.configureRouter(for: params)
self.navigator.configureRouter(for: params)
DispatchQueue.main.async {
completionHandler(tileCount)
completionHandler(tilesURL)
}
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public class NavigationDirections: Directions {
let navigator: Navigator = {
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
return Navigator(profile: settingsProfile, customConfig: "")
return Navigator(profile: settingsProfile, config: NavigatorConfig(), customConfig: "")
}()
let numberOfTiles = navigator.unpackTiles(forPackedTilesPath: tilePath, outputDirectory: outputPath)

Expand Down Expand Up @@ -242,7 +242,7 @@ public class NavigationDirections: Directions {
if _navigator == nil {
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
self._navigator = Navigator(profile: settingsProfile, customConfig: "")
self._navigator = Navigator(profile: settingsProfile, config: NavigatorConfig(), customConfig: "")
}

return _navigator
Expand Down
21 changes: 6 additions & 15 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class RouteController: NSObject {
lazy var navigator: Navigator = {
let settingsProfile = SettingsProfile(application: ProfileApplication.kMobile,
platform: ProfilePlatform.KIOS)
return Navigator(profile: settingsProfile, customConfig: "")
return Navigator(profile: settingsProfile, config: NavigatorConfig(), customConfig: "")
}()

public var route: Route {
Expand Down Expand Up @@ -64,15 +64,6 @@ open class RouteController: NSObject {

var isFirstLocation: Bool = true

public var config: NavigatorConfig? {
get {
return navigator.getConfig()
}
set {
navigator.setConfigFor(newValue)
}
}

/**
Details about the user’s progress along the current route, leg, and step.
*/
Expand All @@ -94,7 +85,7 @@ open class RouteController: NSObject {
- important: If the rawLocation is outside of the route snapping tolerances, this value is nil.
*/
var snappedLocation: CLLocation? {
let status = navigator.getStatusForTimestamp(Date())
let status = navigator.status(at: Date())
guard status.routeState == .tracking || status.routeState == .complete else {
return nil
}
Expand Down Expand Up @@ -202,7 +193,7 @@ open class RouteController: NSObject {

locations.forEach { navigator.updateLocation(for: FixLocation($0)) }

let status = navigator.getStatusForTimestamp(location.timestamp)
let status = navigator.status(at: location.timestamp)

// Notify observers if the step’s remaining distance has changed.
update(progress: routeProgress, with: CLLocation(status.location), rawLocation: location)
Expand Down Expand Up @@ -351,11 +342,11 @@ open class RouteController: NSObject {
a future timestamp compared to the last location received by the location manager.
*/
public func projectedLocation(for timestamp: Date) -> CLLocation {
return CLLocation(navigator.getStatusForTimestamp(timestamp).location)
return CLLocation(navigator.status(at:timestamp).location)
}

public func advanceLegIndex(location: CLLocation) {
let status = navigator.getStatusForTimestamp(location.timestamp)
let status = navigator.status(at: location.timestamp)
routeProgress.legIndex = Int(status.legIndex)
}

Expand Down Expand Up @@ -390,7 +381,7 @@ extension RouteController: Router {
return true
}

let status = status ?? navigator.getStatusForTimestamp(location.timestamp)
let status = status ?? navigator.status(at: location.timestamp)
let offRoute = status.routeState == .offRoute || status.routeState == .invalid
return !offRoute
}
Expand Down
1 change: 1 addition & 0 deletions MapboxCoreNavigationTests/CLLocationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CLLocationTests: XCTestCase {
let bearingAccuracy: CLLocationAccuracy = 35

let fixLocation = FixLocation(coordinate: coordinate,
monotonicTimestampNanoseconds: 0, // use time instead; see also `Navigator.status(at:)`
time: timestamp,
speed: speed as NSNumber,
bearing: bearing as NSNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
buildConfigurationList = 352544F91E66623D004C8F1C /* Build configuration list for PBXNativeTarget "PodInstall" */;
buildPhases = (
FCAEDB6CF8C116409B047EA1 /* [CP] Check Pods Manifest.lock */,
DBC6C5683D9BDC04331D7A2D /* [CP] Prepare Artifacts */,
352544D81E66623D004C8F1C /* Sources */,
352544D91E66623D004C8F1C /* Frameworks */,
352544DA1E66623D004C8F1C /* Resources */,
Expand Down Expand Up @@ -231,6 +232,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-PodInstall/Pods-PodInstall-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/cocoapods-artifacts-${CONFIGURATION}.txt",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/C4CEBB96-98D0-316A-AACC-B5CFBF29F45A.bcsymbolmap",
Expand All @@ -244,7 +246,7 @@
"${BUILT_PRODUCTS_DIR}/MapboxNavigation/MapboxNavigation.framework",
"${PODS_ROOT}/MapboxNavigationNative/MapboxNavigationNative.framework",
"${PODS_ROOT}/MapboxNavigationNative/MapboxNavigationNative.framework.dSYM",
"${PODS_ROOT}/MapboxNavigationNative/3B99A79B-2E8B-34B5-ABAA-D85AB8D5565D.bcsymbolmap",
"${PODS_ROOT}/MapboxNavigationNative/A67EB591-798A-3BA5-9F94-23F239B2B5A8.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/MapboxSpeech/MapboxSpeech.framework",
"${BUILT_PRODUCTS_DIR}/Polyline/Polyline.framework",
"${BUILT_PRODUCTS_DIR}/Solar/Solar.framework",
Expand All @@ -265,7 +267,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxNavigationNative.framework",
"${DWARF_DSYM_FOLDER_PATH}/MapboxNavigationNative.framework.dSYM",
"${BUILT_PRODUCTS_DIR}/3B99A79B-2E8B-34B5-ABAA-D85AB8D5565D.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/A67EB591-798A-3BA5-9F94-23F239B2B5A8.bcsymbolmap",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxSpeech.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Polyline.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Solar.framework",
Expand All @@ -276,6 +278,24 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PodInstall/Pods-PodInstall-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
DBC6C5683D9BDC04331D7A2D /* [CP] Prepare Artifacts */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-PodInstall/Pods-PodInstall-artifacts.sh",
"${PODS_ROOT}/MapboxCommon/MapboxCommon.xcframework",
);
name = "[CP] Prepare Artifacts";
outputPaths = (
"${BUILT_PRODUCTS_DIR}/cocoapods-artifacts-${CONFIGURATION}.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PodInstall/Pods-PodInstall-artifacts.sh\"\n";
showEnvVarsInLog = 0;
};
FCAEDB6CF8C116409B047EA1 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
12 changes: 8 additions & 4 deletions MapboxCoreNavigationTests/CocoaPodsTest/PodInstall/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ PODS:
- Mapbox-iOS-SDK (6.0.0):
- MapboxMobileEvents (= 0.10.2)
- MapboxAccounts (2.3.0)
- MapboxCommon (4.0.0)
- MapboxCoreNavigation (1.0.0-beta.1):
- MapboxAccounts (~> 2.3.0)
- MapboxDirections (~> 0.33.0)
- MapboxMobileEvents (~> 0.10.2)
- MapboxNavigationNative (~> 14.1.5)
- MapboxNavigationNative (~> 18.0.2)
- Turf (~> 0.5.0)
- MapboxDirections (0.33.0):
- Polyline (~> 4.2)
Expand All @@ -18,7 +19,8 @@ PODS:
- MapboxMobileEvents (~> 0.10.2)
- MapboxSpeech (~> 0.3.0)
- Solar (~> 2.1)
- MapboxNavigationNative (14.1.6)
- MapboxNavigationNative (18.0.2):
- MapboxCommon (= 4.0.0)
- MapboxSpeech (0.3.0)
- Polyline (4.2.1)
- Solar (2.1.0)
Expand All @@ -32,6 +34,7 @@ SPEC REPOS:
trunk:
- Mapbox-iOS-SDK
- MapboxAccounts
- MapboxCommon
- MapboxDirections
- MapboxMobileEvents
- MapboxNavigationNative
Expand All @@ -49,11 +52,12 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Mapbox-iOS-SDK: 48ff7550bd459b8494da8ef4d660a668e9187ef0
MapboxAccounts: 84abfdde95d9dc483f604c1b0fe1861edf691ce7
MapboxCoreNavigation: f6ee6f4093a5fd02619bd9d3fc35b1e8cefe61b2
MapboxCommon: dd235a3715fa752aee83bb3be1d4ce0ba93e3b68
MapboxCoreNavigation: 59410745f7c047f00b38b5a060678ec97ef8b493
MapboxDirections: dd01b8f9053719e02d87538b68355d3206321c81
MapboxMobileEvents: 2bc0ca2eedb627b73cf403258dce2b2fa98074a6
MapboxNavigation: e031095fa956e6a4af90e57577392709e3826da0
MapboxNavigationNative: 05d47617f3d18c5e45d9b549cb82dc39cdb67693
MapboxNavigationNative: 2d599b1f5bceb5e353cca64b49b3b6d4f389491b
MapboxSpeech: 403415e932e084cf290b9d55c49ab7ea210b9595
Polyline: 0e9890790292741c8186201a536b6bb6a78d02dd
Solar: 2dc6e7cc39186cb0c8228fa08df76fb50c7d8f24
Expand Down
4 changes: 2 additions & 2 deletions MapboxCoreNavigationTests/NavigationServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import os.log
fileprivate let mbTestHeading: CLLocationDirection = 50

// minimum distance threshold between two locations (in meters)
fileprivate let distanceThreshold: CLLocationDistance = 1
fileprivate let distanceThreshold: CLLocationDistance = 2

// minimum threshold for both latitude and longitude between two coordinates
fileprivate let coordinateThreshold: CLLocationDistance = 0.0005
Expand Down Expand Up @@ -208,7 +208,7 @@ class NavigationServiceTests: XCTestCase {
altitude: 0,
horizontalAccuracy: 30,
verticalAccuracy: 10,
course: -finalHeading,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m surprised we got away with this until now, but negating a CLLocationDegrees makes it invalid rather than pointing it in the other direction.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, when I read docs here it states A negative value indicates that the course information is invalid.

course: (finalHeading + 180).truncatingRemainder(dividingBy: 360),
speed: 5,
timestamp: Date() + 5)

Expand Down
Loading