-
Notifications
You must be signed in to change notification settings - Fork 92
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
Structured road names, codes, destinations #91
Changes from all commits
d46b1da
4192690
09b6300
7c4491a
1ff4054
ce32527
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ class V5Tests: XCTestCase { | |
XCTAssertNil(error, "Error: \(error)") | ||
|
||
XCTAssertNotNil(routes) | ||
XCTAssertEqual(routes!.count, 1) | ||
XCTAssertEqual(routes!.count, 2) | ||
route = routes!.first! | ||
|
||
expectation.fulfill() | ||
|
@@ -54,7 +54,7 @@ class V5Tests: XCTestCase { | |
|
||
XCTAssertNotNil(route) | ||
XCTAssertNotNil(route!.coordinates) | ||
XCTAssertEqual(route!.coordinates!.count, 842) | ||
XCTAssertEqual(route!.coordinates!.count, 28_442) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the semantics of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// confirming actual decoded values is important because the Directions API | ||
// uses an atypical precision level for polyline encoding | ||
|
@@ -63,40 +63,58 @@ class V5Tests: XCTestCase { | |
XCTAssertEqual(route!.legs.count, 1) | ||
|
||
let leg = route!.legs.first! | ||
XCTAssertEqual(leg.name, "CA 24, Camino Tassajara") | ||
XCTAssertEqual(leg.steps.count, 22) | ||
XCTAssertEqual(leg.name, "I 80, I 80;US 30") | ||
XCTAssertEqual(leg.steps.count, 59) | ||
|
||
let step = leg.steps[16] | ||
XCTAssertEqual(round(step.distance), 166) | ||
XCTAssertEqual(round(step.expectedTravelTime), 13) | ||
XCTAssertEqual(step.instructions, "Take the ramp on the right") | ||
let step = leg.steps[43] | ||
XCTAssertEqual(round(step.distance), 688) | ||
XCTAssertEqual(round(step.expectedTravelTime), 30) | ||
XCTAssertEqual(step.instructions, "Take the ramp on the right towards Washington") | ||
|
||
XCTAssertEqual(step.name, "") | ||
XCTAssertEqual(step.destinations, "Sycamore Valley Road") | ||
XCTAssertNil(step.names) | ||
XCTAssertNotNil(step.destinations) | ||
XCTAssertEqual(step.destinations ?? [], ["Washington"]) | ||
XCTAssertEqual(step.maneuverType, ManeuverType.TakeOffRamp) | ||
XCTAssertEqual(step.maneuverDirection, ManeuverDirection.SlightRight) | ||
XCTAssertEqual(step.initialHeading, 182) | ||
XCTAssertEqual(step.finalHeading, 196) | ||
XCTAssertEqual(step.initialHeading, 90) | ||
XCTAssertEqual(step.finalHeading, 96) | ||
|
||
XCTAssertNotNil(step.coordinates) | ||
XCTAssertEqual(step.coordinates!.count, 5) | ||
XCTAssertEqual(step.coordinates!.count, 17) | ||
XCTAssertEqual(step.coordinates!.count, Int(step.coordinateCount)) | ||
let coordinate = step.coordinates!.first! | ||
XCTAssertEqual(round(coordinate.latitude), 38) | ||
XCTAssertEqual(round(coordinate.longitude), -122) | ||
XCTAssertEqual(round(coordinate.latitude), 39) | ||
XCTAssertEqual(round(coordinate.longitude), -77) | ||
|
||
XCTAssertEqual(leg.steps[18].name, "Sycamore Valley Road West") | ||
XCTAssertNil(leg.steps[28].names) | ||
XCTAssertEqual(leg.steps[28].codes ?? [], ["I 80"]) | ||
XCTAssertEqual(leg.steps[28].destinationCodes ?? [], ["I 80 East", "I 90"]) | ||
XCTAssertEqual(leg.steps[28].destinations ?? [], ["Toll Road"]) | ||
|
||
let intersection = step.intersections!.first! | ||
XCTAssertEqual(intersection.outletIndexes, NSIndexSet(indexesInRange: NSRange(location: 1, length: 2))) | ||
XCTAssertEqual(intersection.approachIndex, 0) | ||
XCTAssertEqual(intersection.outletIndex, 2) | ||
XCTAssertEqual(intersection.headings, [0, 180, 195]) | ||
XCTAssertNotNil(intersection.location.latitude) | ||
XCTAssertNotNil(intersection.location.longitude) | ||
XCTAssertEqual(intersection.usableApproachLanes, NSIndexSet(indexesInRange: NSRange(location: 0, length: 2))) | ||
XCTAssertEqual(leg.steps[30].names ?? [], ["Ohio Turnpike"]) | ||
XCTAssertEqual(leg.steps[30].codes ?? [], ["I 80", "I 90"]) | ||
XCTAssertNil(leg.steps[30].destinationCodes) | ||
XCTAssertNil(leg.steps[30].destinations) | ||
|
||
let lane = intersection.approachLanes?.first | ||
let intersections = leg.steps[40].intersections | ||
XCTAssertNotNil(intersections) | ||
XCTAssertEqual(intersections?.count, 7) | ||
let intersection = intersections?[2] | ||
XCTAssertEqual(intersection?.outletIndexes.containsIndex(0), true) | ||
XCTAssertEqual(intersection?.outletIndexes.containsIndexesInRange(NSRange(location: 2, length: 2)), true) | ||
XCTAssertEqual(intersection?.approachIndex, 1) | ||
XCTAssertEqual(intersection?.outletIndex, 3) | ||
XCTAssertEqual(intersection?.headings ?? [], [15, 90, 195, 270]) | ||
XCTAssertNotNil(intersection?.location.latitude) | ||
XCTAssertNotNil(intersection?.location.longitude) | ||
XCTAssertEqual(intersection?.usableApproachLanes ?? [], NSIndexSet(indexesInRange: NSRange(location: 1, length: 3))) | ||
|
||
XCTAssertEqual(leg.steps[57].names ?? [], ["Logan Circle Northwest"]) | ||
XCTAssertNil(leg.steps[57].codes) | ||
XCTAssertNil(leg.steps[57].destinationCodes) | ||
XCTAssertNil(leg.steps[57].destinations) | ||
|
||
let lane = intersection?.approachLanes?.first | ||
let indications = lane?.indications | ||
XCTAssertNotNil(indications) | ||
XCTAssertTrue(indications!.contains(.Left)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might make sense to add a test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test for this case. |
||
|
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.
I assume these are properties on
self.
? Either these should be set that way, or below assignments should not haveself.=
either (likeself.intersections =
->intersections =
)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.
I’ll remove
self.
fromself.intersections
, since there isn’t a conflict with a local variable namedintersections
.