From c4c6ab24946be8355ffc7ea528dce537b88ab8c6 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Thu, 14 May 2015 22:24:07 +0200 Subject: [PATCH] Use distance based search radius This limits the nearest neighbour search to a maximum distance of 1000 meters, but will also work in dense areas. --- data_structures/static_rtree.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/data_structures/static_rtree.hpp b/data_structures/static_rtree.hpp index f219a6475..929ceb8bd 100644 --- a/data_structures/static_rtree.hpp +++ b/data_structures/static_rtree.hpp @@ -646,7 +646,7 @@ class StaticRTree const FixedPointCoordinate &input_coordinate, std::vector &result_phantom_node_vector, const unsigned max_number_of_phantom_nodes, - const unsigned max_checked_elements = 4 * LEAF_NODE_SIZE) + const float max_distance = 1000) { unsigned inspected_elements = 0; unsigned number_of_elements_from_big_cc = 0; @@ -669,6 +669,10 @@ class StaticRTree while (!traversal_queue.empty()) { const IncrementalQueryCandidate current_query_node = traversal_queue.top(); + if (current_query_node.min_dist > max_distance) + { + break; + } traversal_queue.pop(); if (current_query_node.node.template is()) @@ -771,9 +775,8 @@ class StaticRTree } // stop the search by flushing the queue - if ((result_phantom_node_vector.size() >= max_number_of_phantom_nodes && - number_of_elements_from_big_cc > 0) || - inspected_elements >= max_checked_elements) + if (result_phantom_node_vector.size() >= max_number_of_phantom_nodes && + number_of_elements_from_big_cc > 0) { traversal_queue = std::priority_queue{}; }