Boost logo

Geometry :

Subject: Re: [geometry] Rtree bulk loading
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2015-06-17 09:47:22


Hi Hussein,

Hussein Almashouq wrote:
> Hi again , I'm looking for an example code the show how to bulk load
> using packing.

To create an rtree using packing algorithm you just have to pass a Range
into the rtree constructor:

namespace bgi = boost::geometry::index;
typedef std::pair<Box, int> Value;
typedef bgi::rtree< Value, bgi::linear<32> > RTree;

std::vector<Value> values;
/*fill the values container*/

RTree rt;
rt.insert(values.begin(), values.end());

To avoid the creation of an intermediate container of values you can use
Boost.Range adaptors to create a Range and pass it directly into the
rtree constructor.

See also:
http://www.boost.org/doc/libs/1_58_0/libs/geometry/doc/html/geometry/spatial_indexes/creation_and_modification.html#geometry.spatial_indexes.creation_and_modification.additional_interface
http://www.boost.org/doc/libs/1_58_0/libs/geometry/doc/html/geometry/spatial_indexes/rtree_examples/range_adaptors.html
http://www.boost.org/doc/libs/1_58_0/libs/geometry/doc/html/geometry/reference/spatial_indexes/boost__geometry__index__rtree/rtree_iterator__iterator_.html
http://www.boost.org/doc/libs/1_58_0/libs/geometry/doc/html/geometry/reference/spatial_indexes/boost__geometry__index__rtree/rtree_range_const___.html

Regards,
Adam


Geometry list run by mateusz at loskot.net