2 #include <boost/geometry/algorithms/buffer.hpp>
3 #include <boost/geometry/algorithms/distance.hpp>
13 template <
typename LayerT,
typename GeometryT>
14 auto findWithin2d(LayerT& layer,
const GeometryT& geometry,
double maxDist)
15 -> std::vector<std::pair<double, traits::LayerPrimitiveType<LayerT>>> {
17 "Call this function with a 2d type as geometry!");
18 using RetT = std::vector<std::pair<double, traits::LayerPrimitiveType<LayerT>>>;
22 boost::geometry::buffer(boundingBox, boundingBox, maxDist);
24 const auto bboxApproximation = layer.search(boundingBox);
26 auto withinVec = utils::createReserved<RetT>(bboxApproximation.size());
27 for (
auto const& elem : bboxApproximation) {
28 const double dist =
distance2d(geometry, elem);
29 if (dist <= maxDist) {
30 withinVec.push_back(std::make_pair(dist, elem));
33 std::sort(withinVec.begin(), withinVec.end(), [](
auto& v1,
auto& v2) { return v1.first < v2.first; });
37 template <
typename LayerT,
typename GeometryT>
38 auto findWithin3d(LayerT& layer,
const GeometryT& geometry,
double maxDist)
39 -> std::vector<std::pair<double, traits::LayerPrimitiveType<LayerT>>> {
40 using RetT = std::vector<std::pair<double, traits::LayerPrimitiveType<LayerT>>>;
44 boost::geometry::buffer(boundingBox, boundingBox, maxDist);
46 const auto bboxApproximation = layer.search(boundingBox);
48 auto withinVec = utils::createReserved<RetT>(bboxApproximation.size());
49 for (
auto const& elem : bboxApproximation) {
50 const double dist =
distance3d(geometry, elem);
51 if (dist <= maxDist) {
52 withinVec.push_back(std::make_pair(dist, elem));
55 std::sort(withinVec.begin(), withinVec.end(), [](
auto& v1,
auto& v2) { return v1.first < v2.first; });