0

I want to create rtree with dynamic_quadratic and give it a range at contractor that it will use packing algorithm. Here my code for doing it with regular quadratic.

namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;

typedef bg::model::point<double , 3, bg::cs::cartesian> BoostPoint;
typedef std::pair<BoostPoint, unsigned> PointValue;

std::vector<PointValue> points;
for(...)
{
//fill in the points vector
}

bgi::rtree< PointValue, bgi::quadratic<16> > rtree_points(points);

How I can do it with:
bgi::rtree< PointValue, bgi::dynamic_quadratic > rtree_points(points);?

Alredy look at this example:
packing algorithm in rtree in boost

Community
  • 1
  • 1
Tal
  • 1,145
  • 2
  • 14
  • 32

1 Answers1

1

When I post the answer, I search a little bit in the internet, and doesn't find a good answer. Then I realize I need to give a second parameter about the dynamic size i want to create the tree. So that how I did It.

bgi::rtree<PointValue, bgi::dynamic_quadratic> rtree_points(points, points.size());
Tal
  • 1,145
  • 2
  • 14
  • 32
  • 1
    You have to pass `bgi::dynamic_quadratic` object as the second constructor parameter but the constructor of `bgi::dynamic_quadratic` takes max number of elements of a node of the rtree (this corresponds to `bgi::quadratic` template parameters). In your example the size of points `std::vector` is implicitly converted to `bgi::dynamic_quadratic` (this probably shouldn't be allowed at all) so you create rtree having only one huge node containing all of the elements. This rtree won't speed anything up. You should pass bgi::dynamic_quadratic(16) as the second parameter instead. – Adam Wulkiewicz Mar 02 '17 at 17:03