From f2fc96d024428b0255208a28358277b795c36213 Mon Sep 17 00:00:00 2001 From: Fredrik Karlsson Date: Tue, 17 Jan 2017 20:52:45 +0100 Subject: [PATCH] Profile identifiers now bridges to Objective-C --- MapboxDirections.xcodeproj/project.pbxproj | 20 +++++++++ MapboxDirections/MBRoute.swift | 10 ++--- MapboxDirections/MBRouteLeg.swift | 10 ++--- MapboxDirections/MBRouteOptions.h | 38 ++++++++++++++++ MapboxDirections/MBRouteOptions.m | 7 +++ MapboxDirections/MBRouteOptions.swift | 50 ++++------------------ MapboxDirections/MapboxDirections.h | 1 + 7 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 MapboxDirections/MBRouteOptions.h create mode 100644 MapboxDirections/MBRouteOptions.m diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index 8b3410d62..b12492870 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -7,6 +7,14 @@ objects = { /* Begin PBXBuildFile section */ + 358D48811E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 358D48821E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 358D48831E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 358D48841E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 358D48861E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; }; + 358D48871E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; }; + 358D48881E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; }; + 358D48891E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; }; C547EC691DB59F8F009817F3 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; }; C547EC6A1DB59F90009817F3 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; }; C547EC6B1DB59F91009817F3 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; }; @@ -116,6 +124,8 @@ C57B2E951DB8171300E9123A /* MBLaneIndication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBLaneIndication.h; sourceTree = ""; }; C57D55001DB5669600B94B74 /* MBIntersection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBIntersection.swift; sourceTree = ""; }; C57D55071DB58C0200B94B74 /* MBLane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBLane.swift; sourceTree = ""; }; + 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBRouteOptions.h; sourceTree = ""; }; + 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBRouteOptions.m; sourceTree = ""; }; DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MapboxDirections.framework; sourceTree = BUILT_PRODUCTS_DIR; }; DA1A10B81D00F8FF009F82FA /* MapboxDirectionsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapboxDirectionsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; DA1A10D51D0101ED009F82FA /* MapboxDirections.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MapboxDirections.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -227,6 +237,8 @@ DD6254731AE70CB700017857 /* MBDirections.swift */, DAC05F171CFC075300FA0071 /* MBRoute.swift */, DAC05F191CFC077C00FA0071 /* MBRouteLeg.swift */, + 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */, + 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */, DA2E03EA1CB0E13D00D1269A /* MBRouteOptions.swift */, DA2E03E81CB0E0B000D1269A /* MBRouteStep.swift */, C57D55001DB5669600B94B74 /* MBIntersection.swift */, @@ -333,6 +345,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 358D48821E2EAB2500F32A65 /* MBRouteOptions.h in Headers */, DA1A10C61D00F969009F82FA /* MapboxDirections.h in Headers */, C57B2E971DB8171300E9123A /* MBLaneIndication.h in Headers */, ); @@ -342,6 +355,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 358D48831E2EAB2500F32A65 /* MBRouteOptions.h in Headers */, DA1A10EC1D010247009F82FA /* MapboxDirections.h in Headers */, C57B2E981DB8171300E9123A /* MBLaneIndication.h in Headers */, ); @@ -351,6 +365,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 358D48841E2EAB2500F32A65 /* MBRouteOptions.h in Headers */, DA1A11031D0103A3009F82FA /* MapboxDirections.h in Headers */, C57B2E991DB8171300E9123A /* MBLaneIndication.h in Headers */, ); @@ -360,6 +375,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 358D48811E2EAB2500F32A65 /* MBRouteOptions.h in Headers */, DA6C9D8B1CAE442B00094FBC /* MapboxDirections.h in Headers */, C57B2E961DB8171300E9123A /* MBLaneIndication.h in Headers */, ); @@ -629,6 +645,7 @@ buildActionMask = 2147483647; files = ( DA1A10C91D00F969009F82FA /* MBRouteLeg.swift in Sources */, + 358D48871E2EAB4500F32A65 /* MBRouteOptions.m in Sources */, DA1A10CC1D00F969009F82FA /* MBWaypoint.swift in Sources */, DA1A10CA1D00F969009F82FA /* MBRouteOptions.swift in Sources */, DA1A10C81D00F969009F82FA /* MBRoute.swift in Sources */, @@ -657,6 +674,7 @@ buildActionMask = 2147483647; files = ( DA1A10EF1D010247009F82FA /* MBRouteLeg.swift in Sources */, + 358D48881E2EAB4500F32A65 /* MBRouteOptions.m in Sources */, DA1A10F21D010247009F82FA /* MBWaypoint.swift in Sources */, DA1A10F01D010247009F82FA /* MBRouteOptions.swift in Sources */, DA1A10EE1D010247009F82FA /* MBRoute.swift in Sources */, @@ -685,6 +703,7 @@ buildActionMask = 2147483647; files = ( DA1A11061D0103A3009F82FA /* MBRouteLeg.swift in Sources */, + 358D48891E2EAB4500F32A65 /* MBRouteOptions.m in Sources */, DA1A11091D0103A3009F82FA /* MBWaypoint.swift in Sources */, DA1A11071D0103A3009F82FA /* MBRouteOptions.swift in Sources */, DA1A11051D0103A3009F82FA /* MBRoute.swift in Sources */, @@ -701,6 +720,7 @@ buildActionMask = 2147483647; files = ( DA2E03EB1CB0E13D00D1269A /* MBRouteOptions.swift in Sources */, + 358D48861E2EAB4500F32A65 /* MBRouteOptions.m in Sources */, DAC05F161CFBFAC400FA0071 /* MBWaypoint.swift in Sources */, C57D55081DB58C0200B94B74 /* MBLane.swift in Sources */, DAC05F181CFC075300FA0071 /* MBRoute.swift in Sources */, diff --git a/MapboxDirections/MBRoute.swift b/MapboxDirections/MBRoute.swift index d950f1523..cb4d3f6b7 100644 --- a/MapboxDirections/MBRoute.swift +++ b/MapboxDirections/MBRoute.swift @@ -9,7 +9,7 @@ import Polyline open class Route: NSObject, NSSecureCoding { // MARK: Creating a Route - internal init(profileIdentifier: String, legs: [RouteLeg], distance: CLLocationDistance, expectedTravelTime: TimeInterval, coordinates: [CLLocationCoordinate2D]?) { + internal init(profileIdentifier: MBDirectionsProfileIdentifier, legs: [RouteLeg], distance: CLLocationDistance, expectedTravelTime: TimeInterval, coordinates: [CLLocationCoordinate2D]?) { self.profileIdentifier = profileIdentifier self.legs = legs self.distance = distance @@ -26,7 +26,7 @@ open class Route: NSObject, NSSecureCoding { - parameter waypoints: An array of waypoints that the route visits in chronological order. - parameter profileIdentifier: The profile identifier used to request the routes. */ - public convenience init(json: [String: Any], waypoints: [Waypoint], profileIdentifier: String) { + public convenience init(json: [String: Any], waypoints: [Waypoint], profileIdentifier: MBDirectionsProfileIdentifier) { // Associate each leg JSON with a source and destination. The sequence of destinations is offset by one from the sequence of sources. let legInfo = zip(zip(waypoints.prefix(upTo: waypoints.endIndex - 1), waypoints.suffix(from: 1)), json["legs"] as? [JSONDictionary] ?? []) @@ -67,7 +67,7 @@ open class Route: NSObject, NSSecureCoding { guard let decodedProfileIdentifier = decoder.decodeObject(of: NSString.self, forKey: "profileIdentifier") as String? else { return nil } - profileIdentifier = decodedProfileIdentifier + profileIdentifier = MBDirectionsProfileIdentifier(rawValue: decodedProfileIdentifier) } open static var supportsSecureCoding = true @@ -160,13 +160,13 @@ open class Route: NSObject, NSSecureCoding { The value of this property is `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`, depending on the `profileIdentifier` property of the original `RouteOptions` object. This property reflects the primary mode of transportation used for the route. Individual steps along the route might use different modes of transportation as necessary. */ - open let profileIdentifier: String + open let profileIdentifier: MBDirectionsProfileIdentifier } // MARK: Support for Directions API v4 internal class RouteV4: Route { - convenience init(json: JSONDictionary, waypoints: [Waypoint], profileIdentifier: String) { + convenience init(json: JSONDictionary, waypoints: [Waypoint], profileIdentifier: MBDirectionsProfileIdentifier) { let leg = RouteLegV4(json: json, source: waypoints.first!, destination: waypoints.last!, profileIdentifier: profileIdentifier) let distance = json["distance"] as! Double let expectedTravelTime = json["duration"] as! Double diff --git a/MapboxDirections/MBRouteLeg.swift b/MapboxDirections/MBRouteLeg.swift index b6480fab1..9c599973f 100644 --- a/MapboxDirections/MBRouteLeg.swift +++ b/MapboxDirections/MBRouteLeg.swift @@ -9,7 +9,7 @@ import Polyline open class RouteLeg: NSObject, NSSecureCoding { // MARK: Creating a Leg - internal init(steps: [RouteStep], json: JSONDictionary, source: Waypoint, destination: Waypoint, profileIdentifier: String) { + internal init(steps: [RouteStep], json: JSONDictionary, source: Waypoint, destination: Waypoint, profileIdentifier: MBDirectionsProfileIdentifier) { self.source = source self.destination = destination self.profileIdentifier = profileIdentifier @@ -29,7 +29,7 @@ open class RouteLeg: NSObject, NSSecureCoding { - parameter destination: The waypoint at the end of the leg. - parameter profileIdentifier: The profile identifier used to request the routes. */ - public convenience init(json: [String: Any], source: Waypoint, destination: Waypoint, profileIdentifier: String) { + public convenience init(json: [String: Any], source: Waypoint, destination: Waypoint, profileIdentifier: MBDirectionsProfileIdentifier) { let steps = (json["steps"] as? [JSONDictionary] ?? []).map { RouteStep(json: $0) } self.init(steps: steps, json: json, source: source, destination: destination, profileIdentifier: profileIdentifier) } @@ -58,7 +58,7 @@ open class RouteLeg: NSObject, NSSecureCoding { guard let decodedProfileIdentifier = decoder.decodeObject(of: NSString.self, forKey: "profileIdentifier") as String? else { return nil } - profileIdentifier = decodedProfileIdentifier + profileIdentifier = MBDirectionsProfileIdentifier(rawValue: decodedProfileIdentifier) } open static var supportsSecureCoding = true @@ -132,13 +132,13 @@ open class RouteLeg: NSObject, NSSecureCoding { The value of this property is `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`, depending on the `profileIdentifier` property of the original `RouteOptions` object. This property reflects the primary mode of transportation used for the route leg. Individual steps along the route leg might use different modes of transportation as necessary. */ - open let profileIdentifier: String + open let profileIdentifier: MBDirectionsProfileIdentifier } // MARK: Support for Directions API v4 internal class RouteLegV4: RouteLeg { - internal convenience init(json: JSONDictionary, source: Waypoint, destination: Waypoint, profileIdentifier: String) { + internal convenience init(json: JSONDictionary, source: Waypoint, destination: Waypoint, profileIdentifier: MBDirectionsProfileIdentifier) { let steps = (json["steps"] as? [JSONDictionary] ?? []).map { RouteStepV4(json: $0) } self.init(steps: steps, json: json, source: source, destination: destination, profileIdentifier: profileIdentifier) } diff --git a/MapboxDirections/MBRouteOptions.h b/MapboxDirections/MBRouteOptions.h new file mode 100644 index 000000000..b4fb7a615 --- /dev/null +++ b/MapboxDirections/MBRouteOptions.h @@ -0,0 +1,38 @@ +#import + +#pragma mark - Specifying the Routing Profile + +/** + Options determining the primary mode of transportation for the routes. + */ +typedef NSString * MBDirectionsProfileIdentifier NS_EXTENSIBLE_STRING_ENUM; + +/** + The returned directions are appropriate for driving or riding a car, truck, or motorcycle. + + This profile prioritizes fast routes by preferring high-speed roads like highways. A driving route may use a ferry where necessary. + */ +extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobile; + +/** + The returned directions are appropriate for driving or riding a car, truck, or motorcycle. + + This profile avoids traffic congestion based on current traffic data. A driving route may use a ferry where necessary. + + - experiment: This profile is experimental. Where traffic data is absent, this profile prefers high-speed roads like highways, similar to `MBDirectionsProfileIdentifierAutomobile`. + */ +extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobileAvoidingTraffic; + +/** + The returned directions are appropriate for riding a bicycle. + + This profile prioritizes short, safe routes by avoiding highways and preferring cycling infrastructure, such as bike lanes on surface streets. A cycling route may, where necessary, use other modes of transportation, such as ferries or trains, or require dismounting the bicycle for a distance. + */ +extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierCycling; + +/** + The returned directions are appropriate for walking or hiking. + + This profile prioritizes short routes, making use of sidewalks and trails where available. A walking route may use other modes of transportation, such as ferries or trains, where necessary. + */ +extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierWalking; diff --git a/MapboxDirections/MBRouteOptions.m b/MapboxDirections/MBRouteOptions.m new file mode 100644 index 000000000..51cf33965 --- /dev/null +++ b/MapboxDirections/MBRouteOptions.m @@ -0,0 +1,7 @@ +#import "MBRouteOptions.h" + + +MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobile = @"mapbox/driving"; +MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobileAvoidingTraffic = @"mapbox/driving-traffic"; +MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierCycling = @"mapbox/cycling"; +MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierWalking = @"mapbox/walking"; diff --git a/MapboxDirections/MBRouteOptions.swift b/MapboxDirections/MBRouteOptions.swift index 3cf722392..060438369 100644 --- a/MapboxDirections/MBRouteOptions.swift +++ b/MapboxDirections/MBRouteOptions.swift @@ -1,37 +1,3 @@ -// MARK: Specifying the Routing Profile - -/** - The returned directions are appropriate for driving or riding a car, truck, or motorcycle. - - This profile prioritizes fast routes by preferring high-speed roads like highways. A driving route may use a ferry where necessary. - */ -public let MBDirectionsProfileIdentifierAutomobile = "mapbox/driving" - -/** - The returned directions are appropriate for driving or riding a car, truck, or motorcycle. - - This profile avoids traffic congestion based on current traffic data. A driving route may use a ferry where necessary. - - - experiment: This profile is experimental. Where traffic data is absent, this profile prefers high-speed roads like highways, similar to `MBDirectionsProfileIdentifierAutomobile`. - */ -public let MBDirectionsProfileIdentifierAutomobileAvoidingTraffic = "mapbox/driving-traffic" - -/** - The returned directions are appropriate for riding a bicycle. - - This profile prioritizes short, safe routes by avoiding highways and preferring cycling infrastructure, such as bike lanes on surface streets. A cycling route may, where necessary, use other modes of transportation, such as ferries or trains, or require dismounting the bicycle for a distance. - */ -public let MBDirectionsProfileIdentifierCycling = "mapbox/cycling" - -/** - The returned directions are appropriate for walking or hiking. - - This profile prioritizes short routes, making use of sidewalks and trails where available. A walking route may use other modes of transportation, such as ferries or trains, where necessary. - */ -public let MBDirectionsProfileIdentifierWalking = "mapbox/walking" - -// MARK: - - /** A `RouteShapeFormat` indicates the format of a route’s shape in the raw HTTP response. */ @@ -139,13 +105,13 @@ open class RouteOptions: NSObject { - parameter waypoints: An array of `Waypoint` objects representing locations that the route should visit in chronological order. The array should contain at least two waypoints (the source and destination) and at most 25 waypoints. - parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. This parameter, if set, should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. `MBDirectionsProfileIdentifierAutomobile` is used by default. */ - public init(waypoints: [Waypoint], profileIdentifier: String? = nil) { + public init(waypoints: [Waypoint], profileIdentifier: MBDirectionsProfileIdentifier? = nil) { assert(waypoints.count >= 2, "A route requires at least a source and destination.") assert(waypoints.count <= 25, "A route may not have more than 25 waypoints.") self.waypoints = waypoints - self.profileIdentifier = profileIdentifier ?? MBDirectionsProfileIdentifierAutomobile - self.allowsUTurnAtWaypoint = ![MBDirectionsProfileIdentifierAutomobile, MBDirectionsProfileIdentifierAutomobileAvoidingTraffic].contains(self.profileIdentifier) + self.profileIdentifier = profileIdentifier ?? .automobile + self.allowsUTurnAtWaypoint = ![MBDirectionsProfileIdentifier.automobile.rawValue, MBDirectionsProfileIdentifier.automobileAvoidingTraffic.rawValue].contains(self.profileIdentifier.rawValue) } /** @@ -156,7 +122,7 @@ open class RouteOptions: NSObject { - parameter locations: An array of `CLLocation` objects representing locations that the route should visit in chronological order. The array should contain at least two locations (the source and destination) and at most 25 locations. Each location object is converted into a `Waypoint` object. This class respects the `CLLocation` class’s `coordinate` and `horizontalAccuracy` properties, converting them into the `Waypoint` class’s `coordinate` and `coordinateAccuracy` properties, respectively. - parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. This parameter, if set, should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. `MBDirectionsProfileIdentifierAutomobile` is used by default. */ - public convenience init(locations: [CLLocation], profileIdentifier: String? = nil) { + public convenience init(locations: [CLLocation], profileIdentifier: MBDirectionsProfileIdentifier? = nil) { let waypoints = locations.map { Waypoint(location: $0) } self.init(waypoints: waypoints, profileIdentifier: profileIdentifier) } @@ -167,7 +133,7 @@ open class RouteOptions: NSObject { - parameter coordinates: An array of geographic coordinates representing locations that the route should visit in chronological order. The array should contain at least two locations (the source and destination) and at most 25 locations. Each coordinate is converted into a `Waypoint` object. - parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. This parameter, if set, should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. `MBDirectionsProfileIdentifierAutomobile` is used by default. */ - public convenience init(coordinates: [CLLocationCoordinate2D], profileIdentifier: String? = nil) { + public convenience init(coordinates: [CLLocationCoordinate2D], profileIdentifier: MBDirectionsProfileIdentifier? = nil) { let waypoints = coordinates.map { Waypoint(coordinate: $0) } self.init(waypoints: waypoints, profileIdentifier: profileIdentifier) } @@ -201,7 +167,7 @@ open class RouteOptions: NSObject { This property should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. The default value of this property is `MBDirectionsProfileIdentifierAutomobile`, which specifies driving directions. */ - open var profileIdentifier: String + open var profileIdentifier: MBDirectionsProfileIdentifier // MARK: Specifying the Response Format @@ -254,7 +220,7 @@ open class RouteOptions: NSObject { assert(!queries.isEmpty, "No query") let queryComponent = queries.joined(separator: ";") - return "directions/v5/\(profileIdentifier)/\(queryComponent).json" + return "directions/v5/\(profileIdentifier.rawValue)/\(queryComponent).json" } /** @@ -381,7 +347,7 @@ open class RouteOptionsV4: RouteOptions { override var path: String { assert(!queries.isEmpty, "No query") - let profileIdentifier = self.profileIdentifier.replacingOccurrences(of: "/", with: ".") + let profileIdentifier = self.profileIdentifier.rawValue.replacingOccurrences(of: "/", with: ".") let queryComponent = queries.joined(separator: ";") return "v4/directions/\(profileIdentifier)/\(queryComponent).json" } diff --git a/MapboxDirections/MapboxDirections.h b/MapboxDirections/MapboxDirections.h index f5f8fe405..0272398ba 100644 --- a/MapboxDirections/MapboxDirections.h +++ b/MapboxDirections/MapboxDirections.h @@ -8,3 +8,4 @@ FOUNDATION_EXPORT double MapboxDirectionsVersionNumber; FOUNDATION_EXPORT const unsigned char MapboxDirectionsVersionString[]; #import "MBLaneIndication.h" +#import "MBRouteOptions.h"