Skip to content

Commit

Permalink
Add MBDirectionsPriority to SPM flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Jun 3, 2019
1 parent e8269bb commit f571388
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
5 changes: 4 additions & 1 deletion MapboxDirections.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
35828C9F217A003F00ED546E /* OfflineDirections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35828C9D217A003F00ED546E /* OfflineDirections.swift */; };
35828CA0217A003F00ED546E /* OfflineDirections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35828C9D217A003F00ED546E /* OfflineDirections.swift */; };
35828CA1217A003F00ED546E /* OfflineDirections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35828C9D217A003F00ED546E /* OfflineDirections.swift */; };
35AF332022A54D1E002066DE /* Compat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35AF331F22A54D1E002066DE /* Compat.swift */; };
35C0D78F22563B2B005E05A5 /* MBRoadClasses.h in Headers */ = {isa = PBXBuildFile; fileRef = 35C0D78A22563B2A005E05A5 /* MBRoadClasses.h */; settings = {ATTRIBUTES = (Public, ); }; };
35C0D79022563B2B005E05A5 /* MBRoadClasses.h in Headers */ = {isa = PBXBuildFile; fileRef = 35C0D78A22563B2A005E05A5 /* MBRoadClasses.h */; settings = {ATTRIBUTES = (Public, ); }; };
35C0D79122563B2B005E05A5 /* MBRoadClasses.h in Headers */ = {isa = PBXBuildFile; fileRef = 35C0D78A22563B2A005E05A5 /* MBRoadClasses.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -322,12 +323,12 @@
3556CE9C22649CF3009397B5 /* BridgingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BridgingTests.m; path = ../objc/BridgingTests.m; sourceTree = "<group>"; };
356CBE52225CE73500048087 /* CoreLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreLocation.swift; sourceTree = "<group>"; };
35828C9D217A003F00ED546E /* OfflineDirections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineDirections.swift; sourceTree = "<group>"; };
35AF331F22A54D1E002066DE /* Compat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Compat.swift; sourceTree = "<group>"; };
35C0D78A22563B2A005E05A5 /* MBRoadClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBRoadClasses.h; path = Sources/objc/MBRoadClasses.h; sourceTree = SOURCE_ROOT; };
35C0D78B22563B2A005E05A5 /* MBRouteOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBRouteOptions.h; path = Sources/objc/MBRouteOptions.h; sourceTree = SOURCE_ROOT; };
35C0D78C22563B2B005E05A5 /* MBLaneIndication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBLaneIndication.h; path = Sources/objc/MBLaneIndication.h; sourceTree = SOURCE_ROOT; };
35C0D78D22563B2B005E05A5 /* MBRouteOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBRouteOptions.m; path = Sources/objc/MBRouteOptions.m; sourceTree = SOURCE_ROOT; };
35C0D78E22563B2B005E05A5 /* MBAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBAttribute.h; path = Sources/objc/MBAttribute.h; sourceTree = SOURCE_ROOT; };
358D48851E2EAB4500F32A65 /* MBRouteOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBRouteOptions.m; sourceTree = "<group>"; };
35CC310A2285739700EA1966 /* WalkingOptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalkingOptionsTests.swift; sourceTree = "<group>"; };
35D92FEF218203AA000C78CB /* 2018-10-16-Liechtenstein.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = "2018-10-16-Liechtenstein.tar"; sourceTree = "<group>"; };
35DBF004217DF0D90009D2AE /* MBCoordinateBounds.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MBCoordinateBounds.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -514,6 +515,7 @@
children = (
352FFA1122565F25007E7C40 /* LaneIndication.swift */,
356CBE52225CE73500048087 /* CoreLocation.swift */,
35AF331F22A54D1E002066DE /* Compat.swift */,
);
path = SPM;
sourceTree = "<group>";
Expand Down Expand Up @@ -1496,6 +1498,7 @@
C59094B5203B5C7F00EB2417 /* MBDrawingView.swift in Sources */,
DADD27B81E5AAAD800D31FAD /* AppDelegate.swift in Sources */,
356CBE53225CE73500048087 /* CoreLocation.swift in Sources */,
35AF332022A54D1E002066DE /* Compat.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 3 additions & 3 deletions Sources/MapboxDirections/MBRouteOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ open class RouteOptions: DirectionsOptions {
The value of this property must be at least `MBDirectionsPriority.low` and at most `MBDirectionsPriority.high`. The default value of `MBDirectionsPriority.default` neither prefers nor avoids alleys, while a negative value between `MBDirectionsPriority.low` and `MBDirectionsPriority.default` avoids alleys, and a positive value between `MBDirectionsPriority.default` and `MBDirectionsPriority.high` prefers alleys. A value of 0.9 is suitable for pedestrians who are comfortable with walking down alleys.
*/
@objc open var alleyPriority: MBDirectionsPriority = .default
open var alleyPriority: MBDirectionsPriority = .default

/**
A number that influences whether the route should prefer or avoid roads or paths that are set aside for pedestrian-only use (walkways or footpaths).
Expand All @@ -163,7 +163,7 @@ open class RouteOptions: DirectionsOptions {
The value of this property must be at least `MBDirectionsPriority.low` and at most `MBDirectionsPriority.high`. The default value of `MBDirectionsPriority.default` neither prefers nor avoids walkways, while a negative value between `MBDirectionsPriority.low` and `MBDirectionsPriority.default` avoids walkways, and a positive value between `MBDirectionsPriority.default` and `MBDirectionsPriority.high` prefers walkways. A value of −0.1 results in less verbose routes in cities where sidewalks and crosswalks are generally mapped as separate footpaths.
*/
@objc open var walkwayPriority: MBDirectionsPriority = .default
open var walkwayPriority: MBDirectionsPriority = .default

/**
The expected uniform travel speed measured in meters per second.
Expand All @@ -172,7 +172,7 @@ open class RouteOptions: DirectionsOptions {
The value of this property must be at least `MBMinimumWalkingSpeed` and at most `MBMaximumWalkingSpeed`. The default value is `MBDefaultWalkingSpeed`.
*/
@objc open var speed: CLLocationSpeed = MBDefaultWalkingSpeed
open var speed: CLLocationSpeed = MBDefaultWalkingSpeed

override open var urlQueryItems: [URLQueryItem] {
var queryItems = super.urlQueryItems
Expand Down
40 changes: 40 additions & 0 deletions Sources/MapboxDirections/SPM/Compat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Foundation


public enum MBDirectionsPriority {
public typealias RawValue = Double
case low
case `default`
case high
case custom(Double)
}

extension MBDirectionsPriority: RawRepresentable {
public init(rawValue: Double) {
switch rawValue {
case MBDirectionsPriority.low.rawValue:
self = .low
case MBDirectionsPriority.default.rawValue:
self = .default
case MBDirectionsPriority.high.rawValue:
self = .high
case MBDirectionsPriority.custom(rawValue).rawValue:
self = .custom(rawValue)
default:
self = .default
}
}

public var rawValue: Double {
switch self {
case .low:
return -1.0
case .default:
return 0
case .high:
return 1.0
case .custom(let val):
return val
}
}
}

0 comments on commit f571388

Please sign in to comment.