-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bobby Sudekum
authored
Apr 10, 2017
1 parent
603d243
commit a962094
Showing
8 changed files
with
255 additions
and
2 deletions.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
Attributes are metadata information for a given route. The number of attributes returned will be a direct 1-1 relationship with the route's full geometry. The `.distance`, `.expectedTravelTime`, and `.speed` attributes have one fewer value than the `.openStreetMapNodeIdentifier` attribute. | ||
*/ | ||
typedef NS_OPTIONS(NSUInteger, MBAttributeOptions) { | ||
|
||
/// Segment distance. Distances are measured in meters. | ||
MBAttributeDistance = (1 << 1), | ||
|
||
// Segment expected travel time in seconds. | ||
MBAttributeExpectedTravelTime = (1 << 2), | ||
|
||
// Segment current speed. Speeds are measured in meters per second. | ||
MBAttributeSpeed = (1 << 3), | ||
|
||
// [OpenStreetMap node identifier](https://wiki.openstreetmap.org/wiki/Node). | ||
MBAttributeOpenStreetMapNodeIdentifier = (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,42 @@ | ||
import Foundation | ||
|
||
public typealias AttributeOptions = MBAttributeOptions | ||
|
||
extension AttributeOptions: CustomStringConvertible { | ||
/** | ||
Creates an AttributeOptions from the given description strings. | ||
*/ | ||
public init?(description: String) { | ||
var scope: AttributeOptions = [] | ||
switch description { | ||
case "distance": | ||
scope.update(with: .distance) | ||
case "expectedTravelTime": | ||
scope.update(with: .expectedTravelTime) | ||
case "openStreetMapNodeIdentifier": | ||
scope.update(with: .openStreetMapNodeIdentifier) | ||
case "speed": | ||
scope.update(with: .speed) | ||
default: | ||
return nil | ||
} | ||
self.init(rawValue: scope.rawValue) | ||
} | ||
|
||
public var description: String { | ||
var descriptions: [String] = [] | ||
if contains(.distance) { | ||
descriptions.append("distance") | ||
} | ||
if contains(.expectedTravelTime) { | ||
descriptions.append("duration") | ||
} | ||
if contains(.openStreetMapNodeIdentifier) { | ||
descriptions.append("nodes") | ||
} | ||
if contains(.speed) { | ||
descriptions.append("speed") | ||
} | ||
return descriptions.joined(separator: ",") | ||
} | ||
} |
Oops, something went wrong.