Optimise R-tree queries in the case if there is no need to limit maximum number of results
This commit is contained in:
parent
1d17ff2fb5
commit
717407e470
@ -87,7 +87,15 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
: std::make_pair(true, true));
|
: std::make_pair(true, true));
|
||||||
return valid;
|
return valid;
|
||||||
});
|
});
|
||||||
return MakePhantomNodes(input_coordinate, results);
|
auto phantom_nodes = MakePhantomNodes(input_coordinate, results);
|
||||||
|
// there is no guarantee that `SearchInRange` will return results sorted by distance,
|
||||||
|
// but we may rely on it somewhere
|
||||||
|
std::sort(phantom_nodes.begin(), phantom_nodes.end(), [](const auto &lhs,
|
||||||
|
const auto &rhs)
|
||||||
|
{
|
||||||
|
return lhs.distance < rhs.distance;
|
||||||
|
});
|
||||||
|
return phantom_nodes;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,11 +346,6 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
|||||||
distance_and_phantoms.begin(),
|
distance_and_phantoms.begin(),
|
||||||
[this, &input_coordinate](const CandidateSegment &segment)
|
[this, &input_coordinate](const CandidateSegment &segment)
|
||||||
{ return MakePhantomNode(input_coordinate, segment.data); });
|
{ return MakePhantomNode(input_coordinate, segment.data); });
|
||||||
std::sort(distance_and_phantoms.begin(), distance_and_phantoms.end(), [](const auto &lhs,
|
|
||||||
const auto &rhs)
|
|
||||||
{
|
|
||||||
return lhs.distance < rhs.distance;
|
|
||||||
});
|
|
||||||
return distance_and_phantoms;
|
return distance_and_phantoms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user