Boost logo

Geometry :

Subject: Re: [geometry] geometry partition/spatial index
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2012-04-05 15:41:41

jeffpoly wrote:

> Hello Adam,
> Thanks for your reply. I looked at the example, they are all queried about
> points. Given a lot of geometry rings, is it possible to get all the rings
> within a bounding box? some portion of the rings may lie outside the box, as
> long as some portion of the ring lie inside the box.

I assume that you're using the version from the sandbox.

So you want to make an index of rings.

Objects which may be indexable by the Rtree are Points or Boxes. The
simplest way of connecting other types of objects (Rings in your case)
with indexables is passing std::pair of e.g. Box and ID of the Ring.


using namespace boost::geometry;

typedef std::pair<Box, size_t> Value;
index::rtree< Value, index::quadratic<32, 8> > rt;

// then for each Ring inserting a new Value

std::vector<Ring> rings;

   index::insert(rt, std::make_pair(make_envelope(rings[i]), i));

// and performing a query.

std::vector <Value> returned_values;

index::query(rt, index::within(box_region),

Additional info you may find in the docs:


Geometry list run by mateusz at