-
Notifications
You must be signed in to change notification settings - Fork 88
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
Expose road classes in route steps #154
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
56c6ed3
Add way classes
66cf87e
add test
566b033
Update
647e4ec
update
2c2a537
Doc
be4a70c
update
85dce9c
english
e1f8f1c
More detailed documentation on road classes
1ec5 0d2ea6a
Typo
1ec5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
/** | ||
Attributes are metadata information for a route leg. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
/** | ||
Option set that contains attributes of a road segment. | ||
*/ | ||
typedef NS_OPTIONS(NSUInteger, MBRoadClasses) { | ||
|
||
/** | ||
The road segment is [tolled](https://wiki.openstreetmap.org/wiki/Key:toll). | ||
*/ | ||
MBRoadClassesToll = (1 << 1), | ||
|
||
/** | ||
The road segment has access restrictions. | ||
|
||
A road segment may have this class if there are [general access restrictions](https://wiki.openstreetmap.org/wiki/Key:access) or a [high-occupancy vehicle](https://wiki.openstreetmap.org/wiki/Key:hov) restriction. | ||
*/ | ||
MBRoadClassesRestricted = (1 << 2), | ||
|
||
/** | ||
The road segment is a [freeway](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway) or [freeway ramp](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway_link). | ||
|
||
It may be desirable to suppress the name of the freeway when giving instructions and give instructions at fixed distances before an exit (such as 1 mile or 1 kilometer ahead). | ||
*/ | ||
MBRoadClassesMotorway = (1 << 3), | ||
|
||
/** | ||
The user must travel this segment of the route by ferry. | ||
|
||
The user should verify that the ferry is in operation. For driving and cycling directions, the user should also verify that his or her vehicle is permitted onboard the ferry. | ||
|
||
In general, the transport type of the step containing the road segment is also `TransportType.ferry`. | ||
*/ | ||
MBRoadClassesFerry = (1 << 4), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Foundation | ||
|
||
public typealias RoadClasses = MBRoadClasses | ||
|
||
extension RoadClasses: CustomStringConvertible { | ||
|
||
/** | ||
Creates a `RoadClasses` given an array of strings. | ||
*/ | ||
public init?(descriptions: [String]) { | ||
var roadClasses: RoadClasses = [] | ||
for description in descriptions { | ||
switch description { | ||
case "toll": | ||
roadClasses.insert(.toll) | ||
case "restricted": | ||
roadClasses.insert(.restricted) | ||
case "motorway": | ||
roadClasses.insert(.motorway) | ||
case "ferry": | ||
roadClasses.insert(.ferry) | ||
case "none": | ||
break | ||
default: | ||
return nil | ||
} | ||
} | ||
self.init(rawValue: roadClasses.rawValue) | ||
} | ||
|
||
public var description: String { | ||
if isEmpty { | ||
return "" | ||
} | ||
|
||
var descriptions: [String] = [] | ||
if contains(.toll) { | ||
descriptions.append("toll") | ||
} | ||
if contains(.restricted) { | ||
descriptions.append("restricted") | ||
} | ||
if contains(.motorway) { | ||
descriptions.append("motorway") | ||
} | ||
if contains(.ferry) { | ||
descriptions.append("ferry") | ||
} | ||
return descriptions.joined(separator: ",") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
2 changes: 1 addition & 1 deletion
2
MapboxDirectionsTests/Fixtures/v5/v5_driving_dc_geojson.json
100644 → 100755
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
MapboxDirectionsTests/Fixtures/v5/v5_driving_dc_polyline.json
100644 → 100755
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All Objective-C files need to import headers for the types they use. This header uses
NSUInteger
, which is part of Foundation, so import Foundation.h. (This also applies to MBAttribute.h and MBLaneIndication.h.)