Skip to content
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

Remove Node Identifier Attribute #272

Merged
merged 4 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changes to the Mapbox Directions SDK for iOS

## master

* Removed `MBAttributeOpenStreetMapNodeIdentifier, as it is no longer being tracked by the API. This is a breaking change.
17 changes: 5 additions & 12 deletions MapboxDirections/MBAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,29 @@
/**
Attributes are metadata information for a route leg.

When most of the attributes are specified, the resulting route leg contains one attribute value for each segment in leg, where a segment is the straight line between two coordinates in the route leg’s full geometry. When the `MBAttributeOpenStreetMapNodeIdentifier` attribute is specified, the corresponding `RouteLeg` property contains one more value than each of the other attributes.
When any of the attributes are specified, the resulting route leg contains one attribute value for each segment in leg, where a segment is the straight line between two coordinates in the route leg’s full geometry.
*/
typedef NS_OPTIONS(NSUInteger, MBAttributeOptions) {
/**
[OpenStreetMap node identifier](https://wiki.openstreetmap.org/wiki/Node).

When this attribute is specified, the `RouteLeg.openStreetMapNodeIdentifiers` property contains one value for each coordinate in the leg’s full geometry.
*/
MBAttributeOpenStreetMapNodeIdentifier = (1 << 1),

/**
Distance (in meters) along the segment.

When this attribute is specified, the `RouteLeg.segmentDistances` property contains one value for each segment in the leg’s full geometry.
*/
MBAttributeDistance = (1 << 2),
MBAttributeDistance = (1 << 1),

/**
Expected travel time (in seconds) along the segment.

When this attribute is specified, the `RouteLeg.expectedSegmentTravelTimes` property contains one value for each segment in the leg’s full geometry.
*/
MBAttributeExpectedTravelTime = (1 << 3),
MBAttributeExpectedTravelTime = (1 << 2),

/**
Current average speed (in meters per second) along the segment.

When this attribute is specified, the `RouteLeg.segmentSpeeds` property contains one value for each segment in the leg’s full geometry.
*/
MBAttributeSpeed = (1 << 4),
MBAttributeSpeed = (1 << 3),

/**
Traffic congestion level along the segment.
Expand All @@ -41,5 +34,5 @@ typedef NS_OPTIONS(NSUInteger, MBAttributeOptions) {

This attribute requires `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`. Any other profile identifier produces `CongestionLevel.unknown` for each segment along the route.
*/
MBAttributeCongestionLevel = (1 << 5),
MBAttributeCongestionLevel = (1 << 4),
};
5 changes: 0 additions & 5 deletions MapboxDirections/MBAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ extension AttributeOptions: CustomStringConvertible {
var attributeOptions: AttributeOptions = []
for description in descriptions {
switch description {
case "nodes":
attributeOptions.update(with: .openStreetMapNodeIdentifier)
case "distance":
attributeOptions.update(with: .distance)
case "duration":
Expand All @@ -31,9 +29,6 @@ extension AttributeOptions: CustomStringConvertible {

public var description: String {
var descriptions: [String] = []
if contains(.openStreetMapNodeIdentifier) {
descriptions.append("nodes")
}
if contains(.distance) {
descriptions.append("distance")
}
Expand Down
13 changes: 0 additions & 13 deletions MapboxDirections/MBRouteLeg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ open class RouteLeg: NSObject, NSSecureCoding {
expectedTravelTime = json["duration"] as! Double
self.name = json["summary"] as! String

var openStreetMapNodeIdentifiers: [Int64]?
var segmentDistances: [CLLocationDistance]?
var expectedSegmentTravelTimes: [TimeInterval]?
var segmentSpeeds: [CLLocationSpeed]?
var congestionLevels: [CongestionLevel]?

if let jsonAttributes = json["annotation"] as? [String: Any] {
if let nodes = jsonAttributes["nodes"] {
openStreetMapNodeIdentifiers = nodes as? [Int64] ?? []
}
if let distance = jsonAttributes["distance"] {
segmentDistances = distance as? [CLLocationDistance]
}
Expand All @@ -45,7 +41,6 @@ open class RouteLeg: NSObject, NSSecureCoding {
}
}

self.openStreetMapNodeIdentifiers = openStreetMapNodeIdentifiers
self.segmentDistances = segmentDistances
self.expectedSegmentTravelTimes = expectedSegmentTravelTimes
self.segmentSpeeds = segmentSpeeds
Expand Down Expand Up @@ -95,7 +90,6 @@ open class RouteLeg: NSObject, NSSecureCoding {
}
profileIdentifier = MBDirectionsProfileIdentifier(rawValue: decodedProfileIdentifier)

openStreetMapNodeIdentifiers = decoder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: "openStreetMapNodeIdentifiers") as? [Int64]
segmentDistances = decoder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: "segmentDistances") as? [CLLocationDistance]
expectedSegmentTravelTimes = decoder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: "expectedSegmentTravelTimes") as? [TimeInterval]
segmentSpeeds = decoder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: "segmentSpeeds") as? [CLLocationSpeed]
Expand All @@ -112,7 +106,6 @@ open class RouteLeg: NSObject, NSSecureCoding {
coder.encode(distance, forKey: "distance")
coder.encode(expectedTravelTime, forKey: "expectedTravelTime")
coder.encode(profileIdentifier, forKey: "profileIdentifier")
coder.encode(openStreetMapNodeIdentifiers, forKey: "openStreetMapNodeIdentifiers")
coder.encode(segmentDistances, forKey: "segmentDistances")
coder.encode(expectedSegmentTravelTimes, forKey: "expectedSegmentTravelTimes")
coder.encode(segmentSpeeds, forKey: "segmentSpeeds")
Expand Down Expand Up @@ -144,12 +137,6 @@ open class RouteLeg: NSObject, NSSecureCoding {
*/
@objc open let steps: [RouteStep]

/**
An array containing [OpenStreetMap node identifiers](https://wiki.openstreetmap.org/wiki/Node), one for each coordinate along the route geometry.

This property is set if the `RouteOptions.attributeOptions` property contains `.openStreetMapNodeIdentifier`.
*/
@objc open let openStreetMapNodeIdentifiers: [Int64]?

/**
An array containing the distance (measured in meters) between each coordinate in the route leg geometry.
Expand Down
5 changes: 2 additions & 3 deletions MapboxDirectionsTests/AnnotationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AnnotationTests: XCTestCase {
"steps": "false",
"continue_straight": "true",
"access_token": BogusToken,
"annotations": "nodes,distance,duration,speed,congestion"
"annotations": "distance,duration,speed,congestion"
]

stub(condition: isHost("api.mapbox.com")
Expand All @@ -35,7 +35,7 @@ class AnnotationTests: XCTestCase {
options.includesSteps = false
options.includesAlternativeRoutes = false
options.routeShapeResolution = .full
options.attributeOptions = [.openStreetMapNodeIdentifier, .distance, .expectedTravelTime, .speed, .congestionLevel]
options.attributeOptions = [.distance, .expectedTravelTime, .speed, .congestionLevel]
var route: Route?
let task = Directions(accessToken: BogusToken).calculate(options) { (waypoints, routes, error) in
XCTAssertNil(error, "Error: \(error!.localizedDescription)")
Expand All @@ -59,7 +59,6 @@ class AnnotationTests: XCTestCase {
XCTAssertEqual(route!.routeIdentifier, "cj725hpi30yp2ztm2ehbcipmh")

let leg = route!.legs.first!
XCTAssertEqual(leg.openStreetMapNodeIdentifiers!.count, 99)
XCTAssertEqual(leg.segmentDistances!.count, 98)
XCTAssertEqual(leg.segmentSpeeds!.count, 98)
XCTAssertEqual(leg.expectedSegmentTravelTimes!.count, 98)
Expand Down
2 changes: 1 addition & 1 deletion MapboxDirectionsTests/Fixtures/v5/annotation.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"waypoints":[{"location":[-122.431373,37.780601],"name":"Turk Street"},{"location":[-122.404058,37.758859],"name":"Vermont Street"}],"routes":[{"legs":[{"steps":[],"weight":833.8,"distance":4677.3,"annotation":{"distance":[61.78911719499301,8.005870139027868,7.759236367491888,87.06478091987647,10.25848607823369,8.370665933525826,128.73742878884872,9.360982030495618,8.775293145188993,86.9549662825476,9.35196844032588,8.225903582330162,58.11644349519123,29.291784206824605,8.898748875402289,12.903543910114447,9.256506208135528,124.20757712175377,146.17597053784544,146.45354836356245,146.48844995792555,104.75249124259913,52.376257922720605,52.67850990738398,52.3902172886358,52.28042478496598,146.30214620727506,139.89328448914054,15.578350994103406,62.66067405076987,63.16452877652712,13.458181588365996,20.584701549024455,7.668703155380468,8.415860516914783,16.12766361289219,49.5640707594805,49.7085872073418,10.006926395740319,65.76737827104486,66.9331708737475,57.72591261839857,69.14191600033729,75.59927699731753,115.95449195416666,117.00316360696885,76.14672479759217,47.81610361112862,40.747077529085345,104.28833385320196,122.1491598381078,40.76337755157434,14.990850250898449,36.59437600283772,20.82925538207349,26.57837311899057,23.633026596769554,34.24820044233948,72.05868433805037,36.47298929861723,31.6646576147614,75.73201345870328,37.7275112208842,49.52899647660397,60.145710894703306,34.666841671386145,88.0057607189147,85.19171832302112,85.45465364596988,86.58596162510526,142.28452392043692,9.424483651329783,123.9367810487205,9.325528541113664,7.699257912414974,135.08070973534097,141.66418155243468,84.65444720167741,46.08468915479624,2.2675599932459636,2.1220692450736567,1.6744149593511495,1.708699266951245,7.683223619704564,1.84658454260673,1.6180500371443371,1.689121948623264,1.4486133063155147,1.5670682617916714,1.4698163191713105,1.5067116313275537,1.5910952866295878,1.559693966970531,6.717659629902365,1.5572084802655337,1.7573463934158997,1.411314740137675,1.7050692236693632],"nodes":[4784302686,4784302682,65365172,4784302680,4784302660,65308302,4784302659,4784302664,258759749,4784302662,4784302644,258759746,4784302639,4181974624,4784302633,258759744,65287225,4784302632,65287218,65287216,65287213,65287211,65329084,65324339,65325374,65329081,65329079,65350740,65354072,258758040,4177104998,1723739045,4178230431,4061762663,1723738895,4061762655,2884715022,65318308,65306958,65306940,65351748,65319555,65325208,65306838,65351751,65317570,65351753,65317752,539990269,4186457681,65283764,3999577857,65351755,65358372,4761685555,4761685554,295219504,65303897,3999566849,3999561016,65308764,3999511206,3999495551,65308767,3999497936,3999501315,65308770,65317356,65310197,65317350,65317347,65290931,65328390,65328395,65324922,1264273809,65293503,65328397,65340082,1264273796,4045366517,266903666,4045366511,4045366526,4045366501,728867935,4045366503,65340086,4045366531,1264296832,4045366522,65340090,4045366513,65340092,65340096,4045366532,728863237,4045366515,1264296819],"speed":[6.1,1,1.9,1.9,0.8,8.4,9.5,1.8,8.8,9.2,3.1,7.5,7.5,7.5,1,3.1,8.4,8.1,7.3,6.9,4.4,7.4,3.6,4.2,6.1,3.4,4.4,5.4,3.7,6.1,6.1,3.1,5.9,5.1,7,5.8,6.7,6.6,7.1,4.8,10.6,10.9,7.6,8.3,7.3,11.1,7.1,8.4,8.3,7.2,6.7,6.7,3.6,7.8,7.7,4.2,4,10.7,10.8,6.8,4.2,4.2,3.4,7.2,7.2,2.8,10,5.8,5.5,3.5,6.9,5.9,5.8,5.8,7,6.9,6.5,4.4,5.3,2.8,2.7,2.8,2.8,2.7,2.6,2.7,2.8,2.9,2.6,2.9,3,2.7,2.6,2.8,2.6,2.9,2.8,2.8],"duration":[10.1,8.3,4,44.8,12.6,1,13.6,5.1,1,9.5,3,1.1,7.7,3.9,8.5,4.1,1.1,15.4,20.1,21.1,33.4,14.2,14.5,12.5,8.6,15.5,33,26,4.2,10.3,10.3,4.3,3.5,1.5,1.2,2.8,7.4,7.5,1.4,13.8,6.3,5.3,9.1,9.1,15.9,10.5,10.8,5.7,4.9,14.5,18.3,6.1,4.2,4.7,2.7,6.4,5.9,3.2,6.7,5.4,7.6,18.2,11.1,6.9,8.3,12.2,8.8,14.6,15.4,24.4,20.5,1.6,21.2,1.6,1.1,19.5,21.7,19.3,8.7,0.8,0.8,0.6,0.6,2.8,0.7,0.6,0.6,0.5,0.6,0.5,0.5,0.6,0.6,2.4,0.6,0.6,0.5,0.6],"congestion":["moderate","severe","moderate","moderate","heavy","low","low","heavy","low","low","heavy","low","low","low","severe","heavy","low","low","low","low","low","low","heavy","heavy","moderate","heavy","low","low","heavy","low","low","moderate","low","low","low","moderate","moderate","moderate","low","low","low","low","moderate","low","moderate","low","low","moderate","moderate","moderate","low","low","heavy","low","low","moderate","moderate","low","low","moderate","heavy","heavy","heavy","low","low","heavy","low","moderate","low","moderate","low","low","low","low","low","low","low","moderate","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low"]},"summary":"","duration":835.8}],"weight_name":"routability","geometry":"w_reF`kgjVPjC@PLCxC]PCAQc@aHCUNAxC_@NANCdBSr@KNAC]ASc@wGg@gIi@gIi@iIxDe@zAQ|AQ|ASzAQi@gIg@{HCa@QkCOmCA_@Dm@?QHMN]`AmA~@mAJOrAiBtAkBfA{AxAmB~AyBrCyDtCyD~AyB|@kAr@_AfCcDxCgEp@aATUp@s@`@Wj@Wh@Cz@E`CK`AEv@CfCMbAEvAIjBI|@EKgEK_EKaEIcE|FWNC~EUN@L@pFW|FWJ~DpAGBAB?@A@ALG@A@?BA@?B?@@@@@B?@BN?@@BB?@@","weight":833.8,"distance":4677.3,"duration":835.8}],"code":"Ok","uuid":"cj725hpi30yp2ztm2ehbcipmh"}
{"waypoints":[{"location":[-122.431373,37.780601],"name":"Turk Street"},{"location":[-122.404058,37.758859],"name":"Vermont Street"}],"routes":[{"legs":[{"steps":[],"weight":833.8,"distance":4677.3,"annotation":{"distance":[61.78911719499301,8.005870139027868,7.759236367491888,87.06478091987647,10.25848607823369,8.370665933525826,128.73742878884872,9.360982030495618,8.775293145188993,86.9549662825476,9.35196844032588,8.225903582330162,58.11644349519123,29.291784206824605,8.898748875402289,12.903543910114447,9.256506208135528,124.20757712175377,146.17597053784544,146.45354836356245,146.48844995792555,104.75249124259913,52.376257922720605,52.67850990738398,52.3902172886358,52.28042478496598,146.30214620727506,139.89328448914054,15.578350994103406,62.66067405076987,63.16452877652712,13.458181588365996,20.584701549024455,7.668703155380468,8.415860516914783,16.12766361289219,49.5640707594805,49.7085872073418,10.006926395740319,65.76737827104486,66.9331708737475,57.72591261839857,69.14191600033729,75.59927699731753,115.95449195416666,117.00316360696885,76.14672479759217,47.81610361112862,40.747077529085345,104.28833385320196,122.1491598381078,40.76337755157434,14.990850250898449,36.59437600283772,20.82925538207349,26.57837311899057,23.633026596769554,34.24820044233948,72.05868433805037,36.47298929861723,31.6646576147614,75.73201345870328,37.7275112208842,49.52899647660397,60.145710894703306,34.666841671386145,88.0057607189147,85.19171832302112,85.45465364596988,86.58596162510526,142.28452392043692,9.424483651329783,123.9367810487205,9.325528541113664,7.699257912414974,135.08070973534097,141.66418155243468,84.65444720167741,46.08468915479624,2.2675599932459636,2.1220692450736567,1.6744149593511495,1.708699266951245,7.683223619704564,1.84658454260673,1.6180500371443371,1.689121948623264,1.4486133063155147,1.5670682617916714,1.4698163191713105,1.5067116313275537,1.5910952866295878,1.559693966970531,6.717659629902365,1.5572084802655337,1.7573463934158997,1.411314740137675,1.7050692236693632],"speed":[6.1,1,1.9,1.9,0.8,8.4,9.5,1.8,8.8,9.2,3.1,7.5,7.5,7.5,1,3.1,8.4,8.1,7.3,6.9,4.4,7.4,3.6,4.2,6.1,3.4,4.4,5.4,3.7,6.1,6.1,3.1,5.9,5.1,7,5.8,6.7,6.6,7.1,4.8,10.6,10.9,7.6,8.3,7.3,11.1,7.1,8.4,8.3,7.2,6.7,6.7,3.6,7.8,7.7,4.2,4,10.7,10.8,6.8,4.2,4.2,3.4,7.2,7.2,2.8,10,5.8,5.5,3.5,6.9,5.9,5.8,5.8,7,6.9,6.5,4.4,5.3,2.8,2.7,2.8,2.8,2.7,2.6,2.7,2.8,2.9,2.6,2.9,3,2.7,2.6,2.8,2.6,2.9,2.8,2.8],"duration":[10.1,8.3,4,44.8,12.6,1,13.6,5.1,1,9.5,3,1.1,7.7,3.9,8.5,4.1,1.1,15.4,20.1,21.1,33.4,14.2,14.5,12.5,8.6,15.5,33,26,4.2,10.3,10.3,4.3,3.5,1.5,1.2,2.8,7.4,7.5,1.4,13.8,6.3,5.3,9.1,9.1,15.9,10.5,10.8,5.7,4.9,14.5,18.3,6.1,4.2,4.7,2.7,6.4,5.9,3.2,6.7,5.4,7.6,18.2,11.1,6.9,8.3,12.2,8.8,14.6,15.4,24.4,20.5,1.6,21.2,1.6,1.1,19.5,21.7,19.3,8.7,0.8,0.8,0.6,0.6,2.8,0.7,0.6,0.6,0.5,0.6,0.5,0.5,0.6,0.6,2.4,0.6,0.6,0.5,0.6],"congestion":["moderate","severe","moderate","moderate","heavy","low","low","heavy","low","low","heavy","low","low","low","severe","heavy","low","low","low","low","low","low","heavy","heavy","moderate","heavy","low","low","heavy","low","low","moderate","low","low","low","moderate","moderate","moderate","low","low","low","low","moderate","low","moderate","low","low","moderate","moderate","moderate","low","low","heavy","low","low","moderate","moderate","low","low","moderate","heavy","heavy","heavy","low","low","heavy","low","moderate","low","moderate","low","low","low","low","low","low","low","moderate","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low","low"]},"summary":"","duration":835.8}],"weight_name":"routability","geometry":"w_reF`kgjVPjC@PLCxC]PCAQc@aHCUNAxC_@NANCdBSr@KNAC]ASc@wGg@gIi@gIi@iIxDe@zAQ|AQ|ASzAQi@gIg@{HCa@QkCOmCA_@Dm@?QHMN]`AmA~@mAJOrAiBtAkBfA{AxAmB~AyBrCyDtCyD~AyB|@kAr@_AfCcDxCgEp@aATUp@s@`@Wj@Wh@Cz@E`CK`AEv@CfCMbAEvAIjBI|@EKgEK_EKaEIcE|FWNC~EUN@L@pFW|FWJ~DpAGBAB?@A@ALG@A@?BA@?B?@@@@@B?@BN?@@BB?@@","weight":833.8,"distance":4677.3,"duration":835.8}],"code":"Ok","uuid":"cj725hpi30yp2ztm2ehbcipmh"}