-
Notifications
You must be signed in to change notification settings - Fork 704
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
Bug: bidirerctionalastar ignores complex restriction #2781
Conversation
|
||
try { | ||
auto result = gurka::route(map, "D", "E", "auto"); | ||
gurka::assert::raw::expect_path(result, {"Unexpected path found"}); |
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.
It returns DC-CB-BE
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.
From my view the bug is around this line
valhalla/src/thor/bidirectional_astar.cc
Line 764 in ff25b11
if (rev_pred.on_complex_rest()) { |
rev_pred
== DC
and rev_pred.on_complex_restr()
returns false
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 guess the problem is in restrictionbuilder.cc.
Let's say we have a restriction A -> B -> C
. So we take the edge AB
and it's marked as start_restriction
. We go forward and reach the node C
. We go backwards and finally have the edges {CB, BA}
. After that we add reverse restriction using the BA
edge as from. BUT we add it to the tile of the AB
edge.
tldr: if nodes A
and B
belong to different tiles (Houston) we got a problem
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.
the good news is this should be incredibly rare! but also wow, good find, what a needle in a haystack. i suppose we have to detect when restrictions cross tile boundaries in the restrictions builder and patch it to handle that 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.
the good news is this should be incredibly rare
agreed!
fb1b19c
to
5636538
Compare
@@ -331,8 +329,7 @@ void build(const std::string& complex_restriction_from_file, | |||
if (restriction.type() < RestrictionType::kOnlyRightTurn || | |||
restriction.type() > RestrictionType::kOnlyStraightOn) { | |||
|
|||
GraphId currentNode = GraphId(tile->id().tileid(), tile->id().level(), i); | |||
GraphId tileid = tile->id(); | |||
GraphId currentNode = directededge.endnode(); |
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.
Turned out that both forward and it's opposite edge are marked with start_restriction
flag.
So let's say we have a restriction A - B - C
. Both AB
& BA
are start_restriction
-s.
Before this change:
- algorithm starts with the node A and succeeds when
directededge == AB
After this change
- algorithm starts with the node A and succeeds when
directededge == BA
so the PR doesn't breaks anything
Going to build large enough area to compare the number of restrictions against master to make sure the data is static |
Did a test with UPD: the mismatched restriction https://www.openstreetmap.org/relation/7680229#map=18/25.74885/-80.21806 master
this branch
|
|
||
if (tmp_ids.size()) { | ||
if (tmp_ids.size() && tmp_ids.back().Tile_Base() == tile_id) { |
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.
it happens if we split an osmway into a few edges and not all edges go to the same tile
E.g. if you have a restriction "from ABC to CD"
A -- B -- C
|
D
there are cases that A-B-C has the same osmway property. And if the edges AB
and BC
are from the different tiles then master code produces redundant restrictions: they are harmless but useless: both AB & BC edges are marked as start restrictions but finally you'll get the only restriction "from (BC) to (CD)"
Everything's fine. The master code used to loose a restriction. This PR fixes it. Ready for review |
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.
LGTM
CHANGELOG.md
Outdated
@@ -130,6 +130,7 @@ | |||
* FIXED: Remove redundant return statements [#2776](https://github.com/valhalla/valhalla/pull/2776) | |||
* FIXED: Add support for geos-3.9 c++ api [#2739](https://github.com/valhalla/valhalla/issues/2739) | |||
* FIXED: Fix check for live speed validness [#2797](https://github.com/valhalla/valhalla/pull/2797) | |||
* FIXED: Store restrictions in the right tile [#2781](https://github.com/valhalla/valhalla/pull/2781) |
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.
we made a release please move this to the correct section above
Issue
Bug details: #2781 (comment)
the PR has both a gurka test which fails on master and the suggested fix
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?