Skip to content

Commit 5ce5bc2

Browse files
committed
Update NavNative to 124.0
NavNative breaking changes in RoadName structure required adaptation on SDK side. As part of this: RoadName and Shield was updated to match native side.
1 parent eda88d9 commit 5ce5bc2

8 files changed

Lines changed: 99 additions & 53 deletions

File tree

Example/ViewController+FreeDrive.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,7 @@ extension ViewController {
158158
guard let metadata = passiveLocationManager?.roadGraph.edgeMetadata(edgeIdentifier: identifier) else {
159159
return []
160160
}
161-
let names = metadata.names.map { name -> String in
162-
switch name {
163-
case .name(let name):
164-
return name
165-
case .code(let code):
166-
return "(\(code))"
167-
}
168-
}
161+
let names = metadata.names.map(\.text)
169162

170163
// If the road is unnamed, fall back to the road class.
171164
if names.isEmpty {

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

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

Package.resolved

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

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ let package = Package(
2424
dependencies: [
2525
.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", .exact("2.9.0-rc.2")),
2626
.package(name: "MapboxMobileEvents", url: "https://github.com/mapbox/mapbox-events-ios.git", from: "1.0.0"),
27-
.package(name: "MapboxNavigationNative", url: "https://github.com/mapbox/mapbox-navigation-native-ios.git", from: "123.1.0"),
28-
.package(name: "MapboxMaps", url: "https://github.com/mapbox/mapbox-maps-ios.git", from: "10.10.1"),
27+
.package(name: "MapboxNavigationNative", url: "https://github.com/mapbox/mapbox-navigation-native-ios.git", from: "124.0.0"),
28+
.package(name: "MapboxMaps", url: "https://github.com/mapbox/mapbox-maps-ios.git", .exact("10.11.0-beta.1")),
2929
.package(name: "Solar", url: "https://github.com/ceeK/Solar.git", from: "3.0.0"),
3030
.package(name: "MapboxSpeech", url: "https://github.com/mapbox/mapbox-speech-swift.git", from: "2.0.0"),
3131
.package(name: "CwlPreconditionTesting", url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", from: "2.1.0"),

Sources/MapboxCoreNavigation/EHorizon/RoadGraphEdgeMetadata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ extension RoadGraph.Edge {
160160
self.roadClasses = roadClasses
161161

162162
isBridge = native.isBridge
163-
names = native.names.map(RoadName.init)
163+
names = native.names.compactMap(RoadName.init)
164164
laneCount = native.laneCount as? UInt
165165
altitude = native.meanElevation as? Double
166166
curvature = UInt(native.curvature)
Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
import Foundation
22
import MapboxNavigationNative
33

4-
/**
5-
A human-readable name or route reference code that identifies a road.
6-
7-
- note: The Mapbox Electronic Horizon feature of the Mapbox Navigation SDK is in public beta and is subject to changes, including its pricing. Use of the feature is subject to the beta product restrictions in the Mapbox Terms of Service. Mapbox reserves the right to eliminate any free tier or free evaluation offers at any time and require customers to place an order to purchase the Mapbox Electronic Horizon feature, regardless of the level of use of the feature.
8-
*/
9-
public enum RoadName {
10-
/**
11-
A road name.
12-
13-
If you display a name to the user, you may need to abbreviate common words like “East” or “Boulevard” to ensure that it fits in the allotted space.
14-
*/
15-
case name(_ name: String)
16-
17-
/**
18-
A route reference code assigned to a road.
19-
20-
A route reference code commonly consists of an alphabetic network code, a space or hyphen, and a route number. You should not assume that the network code is globally unique: for example, a network code of “NH” may indicate a “National Highway” or “New Hampshire”. Moreover, a route number may not even uniquely identify a route within a given network.
21-
*/
22-
case code(_ code: String)
4+
/// Road information, like Route number, street name, shield information, etc.
5+
///
6+
/// - note: The Mapbox Electronic Horizon feature of the Mapbox Navigation SDK is in public beta
7+
/// and is subject to changes, including its pricing. Use of the feature is subject to the beta product restrictions
8+
/// in the Mapbox Terms of Service. Mapbox reserves the right to eliminate any free tier or free evaluation offers at
9+
/// any time and require customers to place an order to purchase the Mapbox Electronic Horizon feature, regardless of
10+
/// the level of use of the feature.
11+
public struct RoadName {
12+
/// The name of the road.
13+
///
14+
/// If you display a name to the user, you may need to abbreviate common words like “East” or “Boulevard” to ensure
15+
/// that it fits in the allotted space.
16+
public let text: String
2317

24-
init(_ native: MapboxNavigationNative.RoadName) {
25-
if native.isShielded {
26-
self = .code(native.name)
27-
} else {
28-
self = .name(native.name)
29-
}
18+
/// 2 letters language code or "Unspecified" or empty string
19+
public let language: String
20+
21+
/// Shield information of the road
22+
public let shield: RoadShield?
23+
24+
/// Creates a new `RoadName` instance.
25+
/// - Parameters:
26+
/// - text: The name of the road.
27+
/// - language: 2 letters language code or "Unspecified" or empty string
28+
/// - shield: Shield information of the road
29+
public init(text: String, language: String, shield: RoadShield? = nil) {
30+
self.text = text
31+
self.language = language
32+
self.shield = shield
33+
}
34+
35+
init?(_ native: MapboxNavigationNative.RoadName) {
36+
guard native.text != "/" else { return nil }
37+
38+
self.shield = native.shield.map(RoadShield.init)
39+
self.text = native.text
40+
self.language = native.language
3041
}
3142
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import MapboxNavigationNative
2+
3+
/// Describes a road shield information.
4+
///
5+
/// - note: The Mapbox Electronic Horizon feature of the Mapbox Navigation SDK is in public beta
6+
/// and is subject to changes, including its pricing. Use of the feature is subject to the beta product restrictions
7+
/// in the Mapbox Terms of Service. Mapbox reserves the right to eliminate any free tier or free evaluation offers at
8+
/// any time and require customers to place an order to purchase the Mapbox Electronic Horizon feature, regardless of
9+
/// the level of use of the feature.
10+
public struct RoadShield {
11+
/// The base url for a shield image.
12+
public let baseUrl: String
13+
14+
/// The shield display reference.
15+
public let displayRef: String
16+
17+
/// The shield text.
18+
public let name: String
19+
20+
/// The shield text color.
21+
public let textColor: String
22+
23+
/// Creates a new `Shield` instance.
24+
/// - Parameters:
25+
/// - baseUrl: The base url for a shield image.
26+
/// - displayRef: The shield display reference.
27+
/// - name: The shield text.
28+
/// - textColor: The shield text color.
29+
public init(baseUrl: String, displayRef: String, name: String, textColor: String) {
30+
self.baseUrl = baseUrl
31+
self.displayRef = displayRef
32+
self.name = name
33+
self.textColor = textColor
34+
}
35+
36+
init(_ native: MapboxNavigationNative.Shield) {
37+
self.baseUrl = native.baseUrl
38+
self.name = native.name
39+
self.displayRef = native.displayRef
40+
self.textColor = native.textColor
41+
}
42+
}

Sources/TestHelper/NavNative/TestNavigationStatusProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class TestNavigationStatusProvider {
1919
activeGuidanceInfo: ActiveGuidanceInfo? = nil) -> NavigationStatus {
2020
let fixLocation = FixLocation(location ?? CLLocation(latitude: 37.788443, longitude: -122.4020258))
2121
let shield = Shield(baseUrl: "shield_url", displayRef: "ref", name: "shield", textColor: "")
22-
let road = MapboxNavigationNative.Road(text: "name", imageBaseUrl: "base_image_url", shield: shield)
22+
let road = MapboxNavigationNative.RoadName(text: "name", language: "lang", imageBaseUrl: "base_image_url", shield: shield)
2323
let mapMatch = MapMatch(position: .init(edgeId: 0, percentAlong: 0), proba: 42)
2424
let mapMatcherOutput = MapMatcherOutput(matches: [mapMatch], isTeleport: false)
2525
return .init(routeState: routeState,

0 commit comments

Comments
 (0)