-
Notifications
You must be signed in to change notification settings - Fork 313
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
Integrated new directions API fields with the tertiary instruction and lane indications #1514
Changes from 11 commits
352f70b
c73c2a3
f7e88a1
61287aa
18be61f
e3d839d
3a3fc0d
966ec8a
4f450cb
409e2fa
37018f8
d8a0234
7892bff
fa9f08b
fa1b32c
bff3b2f
560c8ba
0bf61ed
6c8806e
f074bdd
2ebd13b
fb56051
6dc222c
67f0ab5
a1d71e4
b00f946
bdebc16
abdb380
8b13242
8f36366
a241dbb
5e3c16d
d555b9a
5dcc682
d755726
f08eb8e
63af724
1dd33da
76cb369
a2c45ab
6b1be17
291ef60
6af14a8
0e25212
ba701e6
b6fdc38
436889c
4ada71c
890f28f
feaf4d9
13f2d71
27f91a2
901e229
11902ca
6461783
a117366
00e211a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ class InstructionPresenter { | |
typealias AttributedInstructionComponents = (components: [VisualInstructionComponent], attributedStrings: [NSAttributedString]) | ||
|
||
func attributedPairs(for instruction: VisualInstruction, dataSource: DataSource, imageRepository: ImageRepository, onImageDownload: @escaping ImageDownloadCompletion) -> AttributedInstructionComponents { | ||
let components = instruction.textComponents | ||
let components = instruction.components.compactMap { $0 as? VisualInstructionComponent } | ||
var strings: [NSAttributedString] = [] | ||
var processedComponents: [VisualInstructionComponent] = [] | ||
|
||
|
@@ -166,7 +166,10 @@ class InstructionPresenter { | |
} | ||
|
||
private func instructionHasDownloadedAllShields() -> Bool { | ||
for component in instruction.textComponents { | ||
let textComponents = instruction.components.compactMap { $0 as? VisualInstructionComponent } | ||
guard !textComponents.isEmpty else { return false } | ||
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. This can be written more succinctly as: guard let _ = instruction.components.contains(where: { $0 is VisualInstructionComponent }) else { return false } 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.
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. |
||
|
||
for component in textComponents { | ||
guard let key = component.cacheKey else { | ||
continue | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,30 +67,28 @@ open class LanesView: UIView { | |
} | ||
|
||
func update(for currentLegProgress: RouteLegProgress) { | ||
guard let step = currentLegProgress.upComingStep else { return } | ||
guard !currentLegProgress.userHasArrivedAtWaypoint else { return } | ||
let durationRemaining = currentLegProgress.currentStepProgress.durationRemaining | ||
|
||
clearLaneViews() | ||
|
||
if let allLanes = step.intersections?.first?.approachLanes, | ||
let usableLanes = step.intersections?.first?.usableApproachLanes, | ||
durationRemaining < RouteControllerMediumAlertInterval { | ||
|
||
for (i, lane) in allLanes.enumerated() { | ||
let laneView = laneArrowView() | ||
laneView.lane = lane | ||
laneView.maneuverDirection = step.maneuverDirection | ||
laneView.isValid = usableLanes.contains(i as Int) | ||
stackView.addArrangedSubview(laneView) | ||
} | ||
let step = currentLegProgress.currentStep | ||
let spokenInstructionIndex = currentLegProgress.currentStepProgress.spokenInstructionIndex | ||
guard let visualInstructions = step.instructionsDisplayedAlongStep, spokenInstructionIndex < visualInstructions.count else { | ||
hide() | ||
return | ||
} | ||
|
||
if stackView.arrangedSubviews.count > 0 { | ||
show() | ||
} else { | ||
hide() | ||
let currentInstruction = visualInstructions[spokenInstructionIndex] | ||
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 looks like we're still using |
||
guard let lanes: [LaneIndicationComponent] = currentInstruction.tertiaryInstruction?.components.compactMap({ component in | ||
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. Want to pull this out into an optional variable? I think it would make this guard easier to read. 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. Sure! |
||
guard let lane = component as? LaneIndicationComponent else { return nil } | ||
return lane | ||
}), !lanes.isEmpty | ||
else { | ||
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. nit, move this up a line. 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. @bsudekum what do you mean? Move it up a line... can you be more explicit? 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. @vincethecoder Move the |
||
hide() | ||
return | ||
} | ||
|
||
let subviews = lanes.map { LaneView(component: $0, direction: step.maneuverDirection) } | ||
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. Why do we need to init new LaneView's? Shouldn't we already have these objects? 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. Oh I see. 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. Yeah, we are given the |
||
stackView.addArrangedSubviews(subviews) | ||
show() | ||
} | ||
|
||
public func show(animated: Bool = true) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"waypoints":[{"name":"16th Street Northwest","location":[-77.036548,38.901166]},{"name":"H Street Northwest","location":[-77.033792,38.900206]}],"routes":[{"legs":[{"steps":[{"intersections":[{"out":1,"in":0,"lanes":[{"valid":true,"indications":["right"]},{"valid":true,"indications":["right"]}],"entry":[false,true,false],"location":[-77.036554,38.900201],"bearings":[0,90,270]},{"out":1,"in":2,"entry":[true,true,false],"location":[-77.035129,38.900202],"bearings":[30,90,270]}],"geometry":{"coordinates":[[-77.036554,38.900201]],"type":"LineString"},"duration":41.3,"distance":239.1,"name":"H Street Northwest","weight":45.3,"mode":"driving","driving_side":"right","maneuver":{"bearing_after":88,"location":[-77.036554,38.900201],"type":"turn","bearing_before":180,"modifier":"left","instruction":"Turn left onto H Street Northwest"}},{"intersections":[{"out":1,"in":0,"lanes":[{"valid":true,"indications":["right"]},{"valid":true,"indications":["none"]}],"entry":[false,true,false],"location":[-77.036554,38.900201],"bearings":[0,90,270]},{"out":1,"in":2,"entry":[true,true,false],"location":[-77.035129,38.900202],"bearings":[30,90,270]}],"geometry":{"coordinates":[[-77.036554,38.900201]],"type":"LineString"},"duration":41.3,"distance":239.1,"name":"H Street Northwest","weight":45.3,"mode":"driving","driving_side":"right","maneuver":{"bearing_after":88,"location":[-77.036554,38.900201],"type":"turn","bearing_before":180,"modifier":"left","instruction":"Turn left onto H Street Northwest"}}],"weight":196.3,"distance":346.4,"summary":"16th Street Northwest, H Street Northwest","duration":177.5}],"weight_name":"routability","geometry":{"coordinates":[[-77.036548,38.901166],[-77.036551,38.900663],[-77.036554,38.900201],[-77.03643,38.900201],[-77.035534,38.900202],[-77.035388,38.900202],[-77.035276,38.900203],[-77.035204,38.900203],[-77.035129,38.900202],[-77.034948,38.900206],[-77.034433,38.900204],[-77.033792,38.900206]],"type":"LineString"},"weight":196.3,"distance":346.4,"duration":177.5}],"code":"Ok"} | ||
{"routes":[{"geometry":"k~ymFd~|bOIdBcD~AmRh@gBZmDtAeBPiE?","legs":[{"summary":"Marshall Avenue, Central Parkway","weight":89.5,"duration":63.4,"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[275],"location":[-84.531074,39.132063]}],"driving_side":"right","geometry":"k~ymFd~|bOARCp@C^","mode":"driving","maneuver":{"bearing_after":275,"bearing_before":0,"location":[-84.531074,39.132063],"type":"depart","instruction":"Head west on Marshall Avenue"},"weight":24.7,"duration":10.9,"name":"Marshall Avenue","distance":44.1,"bannerInstructions":[{"distanceAlongGeometry":44.1,"primary":{"text":"Central Parkway","components":[{"text":"Central Parkway","type":"text","abbr":"Central Pky","abbr_priority":0}],"type":"turn","modifier":"right"},"secondary":{"text":"US 127 / I-75 Alt North / US 27 / US 52","components":[{"text":"US 127","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/us-127"},{"text":"/","type":"delimiter","delimiter":true},{"text":"I-75","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/i-75"},{"text":"Alt","type":"text"},{"text":"North","type":"text","abbr":"N","abbr_priority":0},{"text":"/","type":"delimiter","delimiter":true},{"text":"US 27","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/us-27"},{"text":"/","type":"delimiter","delimiter":true},{"text":"US 52","type":"icon","imageBaseURL":"https://s3.amazonaws.com/mapbox/shields/v3/us-52"}],"type":"turn","modifier":"right"},"sub":{"text":"","components":[{"text":"","type":"lane","active":false,"directions":["straight"]},{"text":"","type":"lane","active":true,"directions":["right"]}]}}]},{"intersections":[{"lanes":[{"valid":false,"indications":["straight"]},{"valid":true,"indications":["right"]}],"out":3,"in":0,"entry":[false,false,true,true],"bearings":[90,150,270,330],"location":[-84.531582,39.132105]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[0,75,180],"location":[-84.532938,39.138135]}],"driving_side":"right","geometry":"u~ymFja}bOcAn@a@TOFKDMDSD[DuAH{NXaALe@L_@Po@^c@NSDe@L]DSBUB]Bg@@aDA","mode":"driving","maneuver":{"bearing_after":331,"bearing_before":275,"location":[-84.531582,39.132105],"modifier":"right","type":"turn","instruction":"Turn right onto Central Parkway (US 127)"},"ref":"US 127; I-75 Alt North; US 27; US 52","weight":64.8,"duration":52.5,"name":"Central Parkway (US 127; I-75 Alt North; US 27; US 52)","distance":780.5,"bannerInstructions":[{"distanceAlongGeometry":780.5,"primary":{"text":"You will arrive","components":[{"text":"You will arrive","type":"text"}],"type":"arrive","modifier":"straight"},"secondary":null,"sub":{"text":"","components":[{"text":"","type":"lane","active":true,"directions":["right"]},{"text":"","type":"lane","active":true,"directions":["right"]}]}},{"distanceAlongGeometry":148.7,"primary":{"text":"You have arrived","components":[{"text":"You have arrived","type":"text"}],"type":"arrive","modifier":"straight"},"secondary":null}]},{"intersections":[{"in":0,"entry":[true],"bearings":[180],"location":[-84.532934,39.138953]}],"driving_side":"right","geometry":"mi{mFxi}bO","mode":"driving","maneuver":{"bearing_after":0,"bearing_before":0,"location":[-84.532934,39.138953],"type":"arrive","instruction":"You have arrived at your destination"},"ref":"US 127; I-75 Alt North","weight":0,"duration":0,"name":"Central Parkway (US 127; I-75 Alt North)","distance":0,"bannerInstructions":[]}],"distance":824.6}],"weight_name":"routability","weight":89.5,"duration":63.4,"distance":824.6}],"waypoints":[{"name":"Marshall Avenue","location":[-84.531074,39.132063]},{"name":"Central Parkway","location":[-84.532934,39.138953]}],"code":"Ok"} |
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.
Unfortunately, something like this does not work. Only published pods are able to be pulled in as deps here.
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.
😞