|
Geometry : |
Subject: [ggl] spacial index construction interface
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-02-06 21:22:41
Barend Gehrels wrote:
>> I'd like to propose slightly different implementation. The main idea
>> is to provide a translator object which translates from Values to Box
>> or Point. Our index now stores a translator and our Values. Internally
>> Values are stored and algorithms for Boxes and Points are choosen in
>> compile time. It would look like this:
>>
>> template <typename Value, typename Translator = vtr::default<Value> >
>> (...)
>
>> What do you think?
>
> In short, I think the translator is a very good idea!
I propose that default translator should handle:
- regular variables,
- pointers,
- iterators defined as a class with typedefs: value_type,
iterator_category, reference, pointer, difference_type and operator* in
the future (after release of has_operator_xxx),
- smart pointers as a class with element_type typedef and operator* in
the future.
This gives us an intermediate type which may be regular variable
implementing geometry::point or geometry::box concept or std::pair. Pair
should be able to store object of a class implementing one of concepts
as a first or second type. The reason why it should handle the second
pair's type is that we may have std::pair<Key, Point> from std::map.
It works as follows:
// P is some point, B is some box
// Examples of default translator types:
translator::def< P >
translator::def< P* >
translator::def< std::pair<int, P>* >
translator::def< boost::shared_ptr<P> >
translator::def< std::vector<P>::iterator >
translator::def< std::map<int, P>::iterator >
translator::def< std::pair<P, size_t> >
translator::def< boost::shared_ptr< std::pair<int, P> > >
translator::def< boost::shared_ptr< std::pair<P, int> > >
translator::def< boost::scoped_ptr< std::pair<P, int> > >
translator::def< boost::scoped_ptr< std::pair<int, P> > >
translator::def< std::pair<model::polygon<P>, B> >
translator::def< std::pair<B, model::polygon<P> > >
Translator has:
typedef ... bounding_object_type; // P or B
bounding_object_type const& operator()(Value const&);
We should be able to write:
rtree<Point> rt(...);
rtree<Point*> rt(...);
rtree<std::pair<Box, SomeData> > rt(...); // only this is currently
implemented
rtree<boost::shared_ptr<std::pair<Box, Polygon> > > rt(...);
etc.
Another type of translator is index translator. Here one must pass the
reference to the container:
std::vector<Point> vect;
rtree <
size_t,
translator::index<std::vector<Point> > >
rt(
...,
translator::index<std::vector<Point> >(vect));
Regards,
Adam
Geometry list run by mateusz at loskot.net