Boost logo

Geometry :

Subject: AW: [ggl] Re: rtree ?
From: Adam Wulkiewicz (adam.wulkiewicz)
Date: 2011-12-02 16:39:35

2011/12/2 Bernhard <Bernhard.Schmitz_at_[hidden]>:
> Adam Wulkiewicz wrote
>> Purpose of the translator is to translate Value into Indexable, not to
>> convert it and store both.
>> In the new design you explicitly define the type of object stored
>> inside the rtree by passing Value type.
>> If there were Indexables always stored in the rtree we would have the
>> previous design with std::pair&lt;Box, T&gt; as Value types. Storing of
>> objects which are Indexables (adapted to Box or Point concept) or has
>> Indexable inside would result in duplicating data.
>> It is possible to implement a rtree which stores types containing
>> indexable as they are and other types as std::pair&lt;Indexable, T&gt; but
>> it complicates things. Furthermore, it's not necessary because current
>> rtree desing makes it possible but you must explicitly say that you
>> want it.
>> Other thing is that it probably should be better described in the
>> documentation.
>> Regards,
>> Adam
> I can now see the rationale behind the current design.
> However, I'm not convinced it is a good design idea for a library, as it
> forces the user to use the library in different ways depending on the type
> of object that he wants to store, due to of the inner implementation of the
> library. It is as if std::list would have a different interface depending on
> whether one wants to store pointers or objects.
> For me, it's not a problem, I will go back to simply indexing my object
> container, so this is just as a general Feedback.

Btw, thank you for reporting an error.

Yes, interpretation of Value type is different for both designs.

The problem appears if you think about non-geometry types. Which types
should be stored as they are and which should be stored with their
Indexable? Previous implementation don't distinguish between those
cases. There is allways a key-value pair stored.

The rtree is closer to std::map or std::set than std::list. What is
more, it is something between. You may pass key-value pair, like in
std::map or a single value which is also a key, line in std::set. You
may also use any other type but you must define what is the key. Only
one requirement is that the key, which in our case is the Indexable,
must be a Point or a Box.

1. std::set<KeyT>
2. std::map<Key, T>

1. index::rtree<IndexableT>
2. index::rtree<std::pair<Indexable, T>>

std::set<KeyT> query returns Iterator<KeyT>,
index::rtree<IndexableT> query returns a copy of KeyT

std::map<Key, T> query returns Iterator<std::pair<Key, T>>
index::rtree<std::pair<Indexable, T>> query returns a copy of std::pair<Key, T>

Of course with rtree you may use other types as well.

What do all of you think about it? Is it a good approach?


Geometry list run by mateusz at