Boost logo

Geometry :

From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2020-03-06 18:28:01


Hi Dinos,

W dniu 05.03.2020 o 17:21, Dinos Lampropoulos via Geometry pisze:
> Dear all,
>
> I am trying to use nsphere to query an rtree with a circle with a
> standard radius. First of all, I was unable to import nsphere. I
> looked at the directory where boost is installed and I couldn't find a
> folder named "extensions". How can I use nsphere? Is there another way
> to achieve my goal without using nsphere?

I answered this question already at GitHub but for people reading the
mailing list I'm pasting the answer here too.

Extensions only exist in the develop branch of Boost.Geometry so you
either has to clone the git repo or copy the code from the develop
branch and make sure it works well with your version of Boost.

A workaround would be to create a box enclosing the circle and use
bgi::satisfies to filter out the elements that are outside of it while
performing the query, so something like:

 Â Â Â  template <typename T> inline T sqr(T const& v) { return v * v; }

 Â Â Â  // ...

 Â Â Â  box_type box{{center_x - r, center_y - r}, {center_x + r, center_y
+ r}};
 Â Â Â  double r_sqr = sqr(r);
 Â Â Â  rtree.query(bgi::intersects(box) && bgi::satisfies([](auto const&
pt_elem) {
 Â Â Â      return sqr(bg::get<0>(pt_elem) - center_x) +
sqr(bg::get<1>(pt_elem) - center_y) <= r_sqr;
 Â Â Â  }), std::back_inserter(result));

Adam


Geometry list run by mateusz at loskot.net