Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may also check out the rtree variants provided by the Boost.Geometry library:</p> <p><a href="http://www.boost.org/doc/libs/release/libs/geometry/doc/html/geometry/spatial_indexes.html" rel="noreferrer">http://www.boost.org/doc/libs/release/libs/geometry/doc/html/geometry/spatial_indexes.html</a></p> <p>Boost.Geometry rtree implementation allows storing values of arbitrary type in the spatial index and performing complex queries. Parameters like maximum node elements may be passed as compile- or run-time parameters. It supports C++11 move semantics also emulated on pre-C++11 compilers thanks to Boost.Move. It also supports stateful allocators which allows e.g. to store the rtree in a shared memory using Boost.Interprocess. And it's fast.</p> <p>On the down-side, currently persistent storage isn't yet supported so if you need more than in-memory spatial index you should probably check one of the other mentioned libraries.</p> <p><strong>Quick example:</strong></p> <p>Probably the most common use case is when you store some geometric objects in a container and their bounding boxes with some ids in the spatial index. In case of Boost.Geometry rtree this could look like this:</p> <pre><code>#include &lt;boost/geometry.hpp&gt; #include &lt;boost/geometry/index/rtree.hpp&gt; #include &lt;vector&gt; namespace bg = boost::geometry; namespace bgi = boost::geometry::index; /* The definition of my_object type goes here */ int main() { typedef bg::model::point&lt;float, 2, bg::cs::cartesian&gt; point; typedef bg::model::box&lt;point&gt; box; typedef std::pair&lt;box, size_t&gt; value; std::vector&lt;my_object&gt; objects; /* Fill objects */ // create the R* variant of the rtree bgi::rtree&lt; value, bgi::rstar&lt;16&gt; &gt; rtree; // insert some values to the rtree for ( size_t i = 0 ; i &lt; objects.size() ; ++i ) { // create a box box b = objects[i].calculate_bounding_box(); // insert new value rtree.insert(std::make_pair(b, i)); } // find values intersecting some area defined by a box box query_box(point(0, 0), point(5, 5)); std::vector&lt;value&gt; result_s; rtree.query(bgi::intersects(query_box), std::back_inserter(result_s)); // find 5 nearest values to a point std::vector&lt;value&gt; result_n; rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n)); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload