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

Fix search_cutoff check in loki correlate_node #2023

Merged
merged 4 commits into from Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,8 @@
* **Bug Fix**
* FIXED: Changed reachability computation to consider both directions of travel wrt candidate edges [#1965](https://github.com/valhalla/valhalla/pull/1965)
* FIXED: toss ways where access=private and highway=service and service != driveway. [#1960](https://github.com/valhalla/valhalla/pull/1960)

* FIXED: Fix search_cutoff check in loki correlate_node. [#2023](https://github.com/valhalla/valhalla/pull/2023)

* **Enhancement**
* ADDED: Establish pinpoint test pattern [#1969](https://github.com/valhalla/valhalla/pull/1969)
* ADDED: Suppress relative direction in ramp/exit instructions if it matches driving side of street [#1990](https://github.com/valhalla/valhalla/pull/1990)
Expand Down
6 changes: 3 additions & 3 deletions src/loki/search.cc
Expand Up @@ -243,6 +243,9 @@ struct bin_handler_t {
const candidate_t& candidate,
PathLocation& correlated,
std::vector<PathLocation::PathEdge>& filtered) {
// the search cutoff is a hard filter so skip any outside of that
if (candidate.point.Distance(location.latlng_) > location.search_cutoff_)
return;
// we need this because we might need to go to different levels
float distance = std::numeric_limits<float>::lowest();
std::function<void(const GraphId& node_id, bool transition)> crawl;
Expand All @@ -259,9 +262,6 @@ struct bin_handler_t {
// cache the distance
if (distance == std::numeric_limits<float>::lowest())
distance = node_ll.Distance(location.latlng_);
// the search cutoff is a hard filter so skip any outside of that
if (distance > location.search_cutoff_)
return;
Copy link
Member

Choose a reason for hiding this comment

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

this was my screw up back when we added search_cutoff. should have thought about that a little harder at the time. apologies!

// add edges entering/leaving this node
for (const auto* edge = start_edge; edge < end_edge; ++edge) {
// get some info about this edge and the opposing
Expand Down
12 changes: 12 additions & 0 deletions test/search.cc
Expand Up @@ -230,6 +230,18 @@ void test_edge_search() {
PE{{t, l, 0}, 1, d.second, 0, S::NONE}, PE{{t, l, 3}, 1, d.second, 0, S::NONE},
PE{{t, l, 6}, 1, d.second, 0, S::NONE} // arriving edges
});

// regression test for #2023, displace the point beyond search_cutoff but within node_snap_tolerance
Location near_node{a.second};
near_node.latlng_.second += 0.00001; // 1.11 meters
near_node.search_cutoff_ = 1.0;
near_node.node_snap_tolerance_ = 2.0;
search(near_node, true, a.second,
{PE{{t, l, 2}, 0, a.second, 0, S::NONE}, PE{{t, l, 3}, 0, a.second, 0, S::NONE},
PE{{t, l, 4}, 0, a.second, 0, S::NONE}, PE{{t, l, 1}, 1, a.second, 0, S::NONE},
PE{{t, l, 8}, 1, a.second, 0, S::NONE}, PE{{t, l, 5}, 1, a.second, 0, S::NONE}},
true);

// snap to node as through location should be all edges
Location x{a.second, Location::StopType::THROUGH};
search(x, true, a.second,
Expand Down