Skip to content
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

map matching lazy shape and disallowed edge fix #1884

Merged
merged 4 commits into from
Jul 15, 2019
Merged

Conversation

kevinkreiser
Copy link
Member

@kevinkreiser kevinkreiser commented Jul 15, 2019

there are two things going on here. the first thing is that during candidate search we use lazy_shape instead of shape to save allocations when doing edge snapping in meili now. this is a mirror of what we do in loki and has a nice performance benefit.

the more important thing here is that we fixed a pretty big bug. when we did the refactor to use the regular Allowed method on the costing we had to worry about case of the first edge where we didnt have a predecessor. To work around that we apparently just said its allowed if it doesnt have a predecessor. That sucks because it leads to a situation where you can go the wrong way down a one way road if the match starts on that road. So now we use the edge filter on the first edge to remove edges that cant possibly be used by the routing algorithm.

// project a onto b where b is the origin vector representing this segment
// and a is the origin vector to the point we are projecting, (a.b/b.b)*b
const auto& u = shape[i];
const auto& v = shape[i + 1];
auto v = shape.pop();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we decode one point at a time and completely avoid any allocations for shape decoding this gives decent speed up in loki and should do here as well (especially where we do many more checks with lots more input)

@@ -162,7 +162,8 @@ inline bool IsEdgeAllowed(const baldr::DirectedEdge* edge,
const sif::cost_ptr_t& costing,
const Label& pred_edgelabel,
const baldr::GraphTile* tile) {
return !pred_edgelabel.edgeid().Is_Valid() || edgeid == pred_edgelabel.edgeid() ||
return (!pred_edgelabel.edgeid().Is_Valid() && costing->GetEdgeFilter()(edge) != 0.f) ||
Copy link
Member Author

@kevinkreiser kevinkreiser Jul 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the important bug fix, previously this said, whatever edge the routing sees, its allowed so long as its at the beginning of the route. this allowed the route to actually start and end on an inaccesable edge and give a route the wrong way on a one way. now if we dont have a predecessor then we'll grab the edge filter and make sure the edge is at least allowed regardless of predecessor.

ivovandongen
ivovandongen previously approved these changes Jul 15, 2019
Copy link
Member

@ivovandongen ivovandongen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kevinkreiser kevinkreiser merged commit dcb2cb0 into master Jul 15, 2019
@ivovandongen ivovandongen deleted the kk_mmhardening branch July 15, 2019 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants