Boost logo

Geometry :

Subject: [ggl] spatial indexes - design
From: Barend Gehrels (barend.gehrels)
Date: 2011-01-12 17:13:57


hi Adam, List,

Sorry to start a new thread about this (working from another computer
now). I asked today how the interface would look like and after that
remembered that it was once long ago discussed in a private e-mail.
Anyway, now that Boost.Range adaptors are within Boost, I think that
range adaptors might be the perfect interface for usages of spatial indices.

See the page http://bit.ly/f1Zmu2

With, for example: boost::count( rng | boost::adaptors::filtered(pred),
out );

So our spatial index might be queried using:

// "my_polygon_type", a polygon type somewhere
// "polygon_collection", a collection of polygons defined somewhere
// "my_box_type", a box type somewhere
// "my_spatial_indexe", a spatial index defined somewhere, and filled
with the polygon collection

BOOST_FOREACH(my_polygon_type const& p, polygon_collection |
boost::geometry::adaptors::spatial_filter(my_box_type(my_spatial_index,
5, 5, 10, 10)))
{
   // do something with this polygon p, guaranteed intersecting the
specified box
}

That (or slightly adapted) will probably only work if "my_polygon_type"
has some identifier stored in the spatial index, together with the
bounding box of that polygon. This identifier might be defined by a
traits class defining how the identier (e.g. an integer) is accessed
from the polygon. In some cases (point set) the identifier might be the
point itself (so then the spatial index stores points).

So this is how it might be from user perspective. Seems workable? I
realize I omitted the filling but that is probably more straightforward.

Regards, Barend


Geometry list run by mateusz at loskot.net