-
Notifications
You must be signed in to change notification settings - Fork 318
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
Add ability to override congestion levels for specific road classes. #2741
Conversation
11eb7e3
to
ceb649e
Compare
OfflineRoutingTests is failing because of a decoding error that would probably be fixed by mapbox/mapbox-directions-swift#485:
|
Yep, I've seen that. Since current PR already depends on |
c512422
to
cbc2f49
Compare
@1ec5, can you please take a look at this PR once more? |
func streetsRoadClasses(_ leg: RouteLeg) -> [MapboxStreetsRoadClass?] { | ||
// Pick only valid segment indices for specific `Intersection` in `RouteStep`. | ||
// Array of segment indexes can look like this: [0, 3, 24, 28, 48, 50, 51, 53]. | ||
let segmentIndices = leg.steps.compactMap({ $0.segmentIndicesByIntersection?.compactMap({ $0 }) }).reduce([], +) |
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 think RouteLeg.segmentRangesByStep
may simplify this computation.
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.
Seems that segmentRangesByStep
is not detailed enough, as it stores only lower and upper bounds. segmentIndicesByIntersection
is more precise in this case, as it stores segment indices for Intersection
.
91a5c64
to
02aaeb0
Compare
let streetsRoadClasses = segmentIndices.enumerated().map({ segmentIndices.indices.contains($0.offset + 1) && streetsRoadClassesInLeg.indices.contains($0.offset) ? | ||
Array(repeating: streetsRoadClassesInLeg[$0.offset], count: segmentIndices[$0.offset + 1] - segmentIndices[$0.offset]) : [] }).reduce([], +) |
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.
At a glance, it seems like this calculation would be simplified by zip
ping segmentIndices
, but it’s hard to be sure. I’m a bit wary of the manual index arithmetic, but I trust you’ve already tested the multi-leg route edge case. I can’t think of any other edge cases at the moment.
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.
Just tried several approaches with zipping and striding, but seems that it doesn't help to make this code more elegant and simple. I propose to move on with landing this PR so that we can start testing and I can follow-up with any better solutions in future PRs.
…emove unused `trafficAlternateLow` property. Remove unused `.gitignore` file.
…denCongestionLevels`.
b87b6df
to
bf436db
Compare
Description
This PR implements the ability to override congestion levels for specific road classes.
Implementation
Since implementation is using Mapbox Directions property
RouteStep.segmentIndicesByIntersection
it depends on branchvk/478-intersection-geometry
. Dependency will be updated after dependent branch is merged tomain
.Since Android implementation is using road classes from
mapbox_streets_v8
there is slight difference between congestion segments. After iOS is done with implementing same functionality current implementation should re-tested and revised once more.Update: Most recent version was updated and is currently using
MapboxStreetsRoadClass
which matches Android implementation.Screenshots or Gifs
Screenshots show congestion consistency comparison between iOS and Android. In this example
.unknown
congestion level for.motorway
road class is replaced to.low
(blue color). Currently there is slight shift of color because of gradient which is used on iOS.