
Geometry : 
Subject: [ggl] spacial index construction interface
From: Barend Gehrels (barend)
Date: 20110223 07:04:06
Hi Adam,
On 1822011 2:44, Adam Wulkiewicz wrote:
>
>
> The interface is slightly different (I didn't added methods templates).
>
> There are 3 template parameters:
>
> rtree<Value, Translator, Box>
Agreed.
>
> The Translator is an object that translates Value const& to some
> Point/Box const&. I've also added method:
>
> bool equals(Value const&, Value const&) const
>
> but I don't know if it's the best place for it.
Yes, I see what you mean. Can either stay there or become a free
function. If existing structures are adapted etc, a free function would
be better. But this is not so probable here.
Bruno, any preference?
> Default translator
>
> translator::def<Value> translates from:
>
> 1. SomePoint/SomeBox;
> 2. std::pair<T1, T2>  One of the types must be SomePoint or SomeBox;
> 3. iterator holding 1. or 2.;
> 4. smart pointer pointing on 1. or 2.;
> 5. pointer pointing on 1. or 2.;
>
> There is also a translator::index which handles indexed geometries in
> some container.
>
> The Box is the box type used by the rtree which by default is SomeBox
> or geometry::model::box<SomePoint>.
>
> There are a few examples in tests/rtree_native.cpp.
I really like this new interface! Just added (to play with it) two
functions of a combination which was not there (pair of point/int):
template <typename R>
void print_point_pair_range(R const& r)
{
BOOST_FOREACH(typename boost::range_value<R const>::type const&
item, r)
{
std::cout << item.second << ": " <<
boost::geometry::dsv(item.first) << std::endl;
}
std::cout << std::endl;
}
void test_point_pair()
{
typedef boost::geometry::model::point<double, 2,
boost::geometry::cs::cartesian> P;
boost::geometry::index::rtree< std::pair<P, int> > index(3, 0);
index.insert(std::make_pair(P(0, 0), 0));
index.insert(std::make_pair(P(2, 2), 1));
index.insert(std::make_pair(P(4, 4), 2));
index.insert(std::make_pair(P(6, 6), 3));
print_point_pair_range(index 
boost::geometry::index::filters::spatially_filtered(
boost::geometry::model::box<P>(P(2.5, 2.5), P(4.5, 4.5))));
}
And it is working and looking good like this.
Thanks, Barend
Geometry list run by mateusz at loskot.net