I am using Boost's r-tree implementation in my code. I have a list of objects with coordinates (say cities on a map, if it matters), which I wish to index in the r-tree, to perform fast NN search, etc. I have followed their iterative query example, in which trees are storing boost::geometry::model::point
objects.
My question: is there anyway to store objects (i.e. the cities themselves) instead of just their coordinates in the tree? One solution I thought about is to use indexing of my own. If this is indeed what I should do - is there anyway to find the index of the objects by the order in which they were inserted to the tree?
So, for example, when I look for the KNNs of some cities - I would like to extract not only their coordinates (or distances), like they do in the example:
for ( rtree_t::const_query_iterator
it = rtree.qbegin(bgi::nearest(pt, N));
it != rtree.qend() ;
++it ) {
std::cout << bg::wkt(*it) << ", distance= " << bg::distance(pt, *it) << std::endl;
}
But also the order at which they were inserted into the tree, so I could access them e.g. from a vector that contains the objects by order of insertion.