-
Notifications
You must be signed in to change notification settings - Fork 699
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
Implement depth-first-search to match way_ids with edge_ids #2848
Conversation
{"type", "restriction"}, | ||
{"restriction", "no_left_turn"}, | ||
}}, | ||
}; |
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.
So we have FECB
restriction and ABCD
edges have the same way_id
.
Let's say we're starting with the B
node and trying to match [3, 2, 1]
way_ids.
- Step 1: we go towards node
A
asway_id(BA) == 3
. But this is wrong direction so we fallback to nodeB
- Step 2: we go towards node
D
asway_id(BCD) == 3
. BUt this is wrong direction as well. - Step 3: The
GetGraphIds
function returnno match found
but it must returnBCEF
I built tiles with
|
7fe0d9b
to
ce9d64d
Compare
Uffff... I came across another bug: we don't look at the access mode while matching way_ids with graph_ids |
@merkispavel is this ready for review or will you address the other issue you found |
src/mjolnir/restrictionbuilder.cc
Outdated
bool found; | ||
|
||
// expand with the next way_id | ||
found = ExpandFromNode(reader, lock, last_node, edge_ids, way_ids, way_id_index + 1, tile, |
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.
Calling ExpandFromNode(..., way_id_index + 1, ...)
before ExpandFromNode(..., way_id_index, ...)
let us not to worry about multiple edges with the last way id. So we need not remove duplicated way_ids in the prefix only
@@ -489,7 +424,7 @@ void build(const std::string& complex_restriction_from_file, | |||
res_way_ids.push_back(restriction_to.to()); | |||
|
|||
// walk in the forward direction (reverse in relation to the restriction) | |||
std::deque<GraphId> tmp_ids = GetGraphIds(currentNode, reader, lock, res_way_ids); | |||
std::vector<GraphId> tmp_ids = GetGraphIds(currentNode, reader, lock, res_way_ids); |
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 just don't see sense in using deque here. It just confused me. But I can easily revert it if there's some profit
throw std::invalid_argument("Osm way id has already been used"); | ||
} | ||
way_id = id; | ||
way_id = std::stoull(found->second); |
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.
So I needed a gurka test when multiple edges have the same way id. And this exception used to be thrown. Let me know if there's a better way to get such gurka test(in case you want to revert this piece of code)
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.
@merkispavel we have added exception tests for the path and eta like this here But, it you don't think it will be useful for more tests in the future, I am fine how it is now.
@gknisely This PR doesn't break existing restrictions. What about the new restrictions - some of them are valid and some of them are not. But it's caused by another(unrelated to the current PR) bug (#2849) |
@merkispavel have you RAD tested this? If yes, were there any diffs? |
This looks good, but can you send me a sample restriction for the above PR? #2849 I assume you saw it in the FL data set. You should be able to dump out the osmid for the restriction relation. Wondering if we really should be tossing relations if the access/modes on the ways don't match the access/modes on the relations for the restriction. |
|
not yet @mandeepsandhu. I'll let you know RAD test status when i run it |
Tested master vs PR diff in restrictions: lgtm List of restrictions that are added correctly now(or just added) And noticed one buggy restriction https://www.openstreetmap.org/relation/9689483. I guess it should lane-specific restriction Waiting for the rad results and we are good |
Rad tested the changes. Looks good |
Issue
This implementation handles the case when you might choose wrong direction more than once while matching way_ids with graph_ids. See the gurka test for better understanding
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?