|
1 | 1 | import Foundation |
2 | 2 | import MapboxNavigationNative |
3 | 3 |
|
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 |
23 | 17 |
|
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 |
30 | 41 | } |
31 | 42 | } |
0 commit comments