From 12bb15d27ed809f96f4888291ef8dc77f5a9f714 Mon Sep 17 00:00:00 2001
From: Adam Wulkiewicz
rtree<Value, Parameters, Translator = index::translator<Value>, Allocator> = std::allocator<Value> >-
Value - type of object which will be stored in the container,
Translator - index::translator<Value>
are defined as follows:
-Indexable = Point
| Box
@@ -116,7 +116,7 @@
A Translator is a type which knows how to handle Values.
It has two purposes:
-Value to a more suitable Indexable
type which is needed by most of operations,
@@ -134,7 +134,7 @@
If comparison of two Values is required, the default translator:
Point
and Box
diff --git a/doc/html/geometry_index/r_tree/introduction.html b/doc/html/geometry_index/r_tree/introduction.html
index 74f9022ec..8dc523bbc 100644
--- a/doc/html/geometry_index/r_tree/introduction.html
+++ b/doc/html/geometry_index/r_tree/introduction.html
@@ -3,7 +3,7 @@
R-tree is a tree data structure used for spatial searching. It was proposed - by Antonin Guttman in 1984 [1] as an expansion of B-tree for multi-dimensional data. It may + by Antonin Guttman in 1984 [1] as an expansion of B-tree for multi-dimensional data. It may be used to store points or volumetric data in order to perform a spatial query later. This query may return objects that are inside some area or are - close to some point in space [2]. + close to some point in space [2].
The R-tree structure is presented on the image below. Each R-tree's node @@ -51,7 +51,7 @@
The R-tree is a self-balanced data structure. The key part of balancing algorithm - is node splitting algorithm [3] [4]. Each algorithm produces different splits so the internal structure + is node splitting algorithm [3] [4]. Each algorithm produces different splits so the internal structure of a tree may be different for each one of them. In general more complex algorithms analyses elements better and produces less overlapping nodes. In the searching process less nodes must be traversed in order to find desired @@ -181,13 +181,13 @@
Key features of this implementation of the R-tree are:
-R-tree depends on Boost.Move, Boost.Container, Boost.Tuple, @@ -219,7 +219,7 @@
The spatial index was originally started by Federico J. Fernandez during @@ -227,7 +227,7 @@
@@ -235,20 +235,20 @@ J. Simonson for their support and ideas.
[1]
+
[1] Guttman, A. (1984). R-Trees: A Dynamic Index Structure for Spatial Searching
[2] +
[2] Cheung, K.; Fu, A. (1998). Enhanced Nearest Neighbour Search on the R-tree
[3] +
[3] Greene, D. (1989). An implementation and performance analysis of spatial data access methods
[4] +
[4] Beckmann, N.; Kriegel, H. P.; Schneider, R.; Seeger, B. (1990). The R*-tree: an efficient and robust access method for points and rectangles
Values which meets some predicates. Currently
supported are three types of predicates:
-For example queries may be used to retrieve Values:
-This is self-balancing spatial index capable to store various types of @@ -58,7 +58,7 @@
The user must pass a type defining the Parameters which will be used in @@ -68,7 +68,7 @@
Predefined algorithms with compile-time parameters are:
-boost::geometry::index::linear,
Predefined algorithms with run-time parameters are:
-boost::geometry::index::runtime::linear,
The Translator translates from Value to Indexable each time r-tree requires @@ -112,14 +112,14 @@
#include <boost/geometry/index/rtree.hpp>
template<typename Value,typename Parameters,@@ -132,7 +132,7 @@
If allocator default constructor throws. @@ -875,7 +875,7 @@
rtree(parameters_typeparameters,translator_typeconst &translator,@@ -883,7 +883,7 @@
If allocator copy constructor throws. @@ -981,7 +981,7 @@
template<typename Iterator>rtree(Iteratorfirst,@@ -992,7 +992,7 @@
template<typename Range>rtree(Range const &rng,@@ -1145,7 +1145,7 @@
@@ -1154,7 +1154,7 @@
~rtree()
Nothing. @@ -1302,20 +1302,20 @@
It uses parameters, translator and allocator from the source tree.
rtree(rtreeconst &src)
It uses Parameters and translator from the source tree.
rtree(rtreeconst &src,allocator_typeconst &allocator)
It uses parameters, translator and allocator from the source tree.
rtree(rtree&&src)
Nothing. @@ -1569,20 +1569,20 @@
It uses parameters and translator from the source tree.
rtree(rtree&&src,allocator_typeconst &allocator)
It uses parameters and translator from the source tree.
rtree&operator=(constrtree&src)
It uses parameters and translator from the source tree.
rtree&operator=(rtree&&src)
Only if allocators aren't equal.
-Parameters, translator and allocators are swapped as well.
voidswap(rtree&other)
If allocators swap throws. @@ -1920,13 +1920,13 @@
voidinsert(value_typeconst &value)
template<typename Iterator>voidinsert(Iteratorfirst,Iteratorlast)
template<typename Range>voidinsert(Range const &rng)
In contrast to the
@@ -2210,13 +2210,13 @@
std::set
size_typeremove(value_typeconst &value)
1 if the value was removed, 0 otherwise.
In contrast to the
@@ -2315,14 +2315,14 @@
std::set
template<typename Iterator>size_typeremove(Iteratorfirst,Iteratorlast)
The number of removed values.
In contrast to the
@@ -2438,14 +2438,14 @@
std::set
template<typename Range>size_typeremove(Range const &rng)
The number of removed values.
This query function performs spatial and k-nearest neighbor searches. @@ -2550,7 +2550,7 @@ are returned. More spatial predicates may be generated by one of the functions listed below:
-boost::geometry::index::covered_by(),
It is possible to negate spatial predicates:
-! boost::geometry::index::covered_by(),
@@ -2608,7 +2608,7 @@ iterator. Only one nearest predicate may be passed to the query. It may be generated by:
-@@ -2619,14 +2619,14 @@
template<typename Predicates,typename OutIter>size_typequery(Predicates const &predicates,OutIterout_it)
@@ -2635,7 +2635,7 @@
The number of values found.
@@ -2725,7 +2725,7 @@
If Value copy constructor or copy assignment throws. @@ -2750,13 +2750,13 @@
size_typesize()
@@ -2765,14 +2765,14 @@
The number of stored values.
Nothing. @@ -2787,13 +2787,13 @@
boolempty()
@@ -2802,14 +2802,14 @@
true if the container is empty.
Nothing. @@ -2824,13 +2824,13 @@
voidclear()
Nothing. @@ -2845,7 +2845,7 @@
Returns the box able to contain all values stored in the container. If @@ -2853,13 +2853,13 @@
bounds_typebounds()
@@ -2868,7 +2868,7 @@
The box able to contain all values stored in the container or an invalid @@ -2876,7 +2876,7 @@
Nothing. @@ -2892,7 +2892,7 @@
For indexable_type it returns the number of values which indexables equals @@ -2901,14 +2901,14 @@
template<typename ValueOrIndexable>size_typecount(ValueOrIndexable const &vori)
@@ -2917,7 +2917,7 @@
The number of values found.
Nothing. @@ -2985,13 +2985,13 @@
parameters_typeconst ¶meters()
@@ -3000,14 +3000,14 @@
The parameters object.
Nothing. @@ -3022,13 +3022,13 @@
translator_typeconst &translator()
@@ -3037,14 +3037,14 @@
The translator object.
Nothing. @@ -3059,13 +3059,13 @@
allocator_typeget_allocator()
@@ -3074,14 +3074,14 @@
The allocator.
If allocator copy constructor throws. @@ -3095,7 +3095,7 @@
1 if value was removed, 0 otherwise. @@ -3710,7 +3710,7 @@
Remove a range of values from the container. In contrast to the or std::set method it doesn't take iterators
@@ -3724,7 +3724,7 @@
std::map erase()
template<typename Value,typename Options,@@ -3737,7 +3737,7 @@
The number of removed values. @@ -3839,7 +3839,7 @@
Remove a range of values from the container. In contrast to the or std::set method it removes values
@@ -3852,7 +3852,7 @@
std::map erase()
template<typename Value,typename Options,@@ -3863,7 +3863,7 @@
The number of removed values. @@ -3950,7 +3950,7 @@
This query function performs spatial and k-nearest neighbor searches. @@ -3966,7 +3966,7 @@ are returned. More spatial predicates may be generated by one of the functions listed below:
-boost::geometry::index::covered_by(),
It is possible to negate spatial predicates:
-! boost::geometry::index::covered_by(),
@@ -4024,7 +4024,7 @@ iterator. Only one nearest predicate may be passed to the query. It may be generated by:
-@@ -4035,7 +4035,7 @@
template<typename Value,typename Options,@@ -4049,7 +4049,7 @@
The number of values found.
@@ -4161,7 +4161,7 @@
If Value copy constructor or copy assignment throws. @@ -4187,14 +4187,14 @@
It calls rtree::clear().
template<typename Value,typename Options,@@ -4204,7 +4204,7 @@
The number of values stored in the index. @@ -4346,14 +4346,14 @@
It calls rtree::empty().
template<typename Value,typename Options,@@ -4363,7 +4363,7 @@
true if there are no values in the index. @@ -4430,14 +4430,14 @@
It calls .
rtree::envelope()
template<typename Value,typename Options,@@ -4447,7 +4447,7 @@
The box containing all stored values or an invalid box. @@ -4513,14 +4513,14 @@
It calls rtree::swap().
template<typename Value,typename Options,@@ -4530,7 +4530,7 @@
@@ -6272,7 +6272,7 @@
The insert iterator inserting values to the container. diff --git a/doc/html/geometry_index/r_tree/rtree_examples.html b/doc/html/geometry_index/r_tree/rtree_examples.html index 1e565f1b6..e7e4a077e 100644 --- a/doc/html/geometry_index/r_tree/rtree_examples.html +++ b/doc/html/geometry_index/r_tree/rtree_examples.html @@ -3,7 +3,7 @@
+
+#include <boost/geometry.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/box.hpp> + +#include <boost/geometry/index/rtree.hpp> + +#include <cmath> +#include <vector> +#include <iostream> +#include <boost/foreach.hpp> +#include <boost/shared_ptr.hpp> + +namespace bg = boost::geometry; +namespace bgi = boost::geometry::index; + +namespace boost { namespace geometry { namespace index { + +template <typename Box> +struct translator< boost::shared_ptr<Box> > +{ + typedef boost::shared_ptr<Box> V; + + typedef Box const& result_type; + result_type operator()(V const& v) const { return *v; } + bool equals(V const& v1, V const& v2) const { return v1 == v2; } +}; + +}}} // namespace boost::geometry::index + +int main(void) +{ + typedef bg::model::point<float, 2, bg::cs::cartesian> point; + typedef bg::model::box<point> box; + typedef boost::shared_ptr<box> shp; + typedef shp value; + + // create the rtree using default constructor + bgi::rtree< value, bgi::linear<16, 4> > rtree; + + std::cout << "filling index with boxes shared pointers:" << std::endl; + + // create some polygons and fill the spatial index + for ( unsigned i = 0 ; i < 10 ; ++i ) + { + // create a box + shp b(new box(point(i, i), point(i+0.5f, i+0.5f))); + + // display new box + std::cout << bg::wkt<box>(*b) << std::endl; + + // insert new value + rtree.insert(b); + } + + // find values intersecting some area defined by a box + box query_box(point(0, 0), point(5, 5)); + std::vector<value> result_s; + rtree.query(query_box, std::back_inserter(result_s)); + + // find 5 nearest values to a point + std::vector<value> result_n; + rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n)); + + // display results + std::cout << "spatial query box:" << std::endl; + std::cout << bg::wkt<box>(query_box) << std::endl; + std::cout << "spatial query result:" << std::endl; + BOOST_FOREACH(value const& v, result_s) + std::cout << bg::wkt<box>(*v) << std::endl; + + std::cout << "knn query point:" << std::endl; + std::cout << bg::wkt<point>(point(0, 0)) << std::endl; + std::cout << "knn query result:" << std::endl; + BOOST_FOREACH(value const& v, result_n) + std::cout << bg::wkt<box>(*v) << std::endl; + + return 0; +} ++
+
++
+#include <boost/geometry.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/box.hpp> + +#include <boost/geometry/index/rtree.hpp> + +#include <cmath> +#include <vector> +#include <iostream> +#include <boost/foreach.hpp> + +namespace bg = boost::geometry; +namespace bgi = boost::geometry::index; + +template <typename Container> +class index_translator +{ + typedef typename Container::size_type size_t; + typedef typename Container::const_reference cref; + Container const& container; + +public: + typedef cref result_type; + explicit index_translator(Container const& c) : container(c) {} + result_type operator()(size_t i) const { return container[i]; } + bool equals(size_t i1, size_t i2) const { return i1 == i2; } +}; + +int main(void) +{ + typedef bg::model::point<float, 2, bg::cs::cartesian> point; + typedef bg::model::box<point> box; + typedef std::vector<box>::size_type value; + typedef bgi::rstar<16, 4> parameters; + typedef index_translator< std::vector<box> > translator; + + // boxes + std::vector<box> boxes; + + // create some boxes + for ( unsigned i = 0 ; i < 10 ; ++i ) + { + // add a box + boxes.push_back(box(point(i, i), point(i+0.5f, i+0.5f))); + } + + // display boxes + std::cout << "generated boxes:" << std::endl; + BOOST_FOREACH(box const& b, boxes) + std::cout << bg::wkt<box>(b) << std::endl; + + // create the rtree + parameters params; + translator tr(boxes); + bgi::rtree<value, parameters, translator> rtree(params, tr); + + // fill the spatial index + for ( size_t i = 0 ; i < boxes.size() ; ++i ) + rtree.insert(i); + + // find values intersecting some area defined by a box + box query_box(point(0, 0), point(5, 5)); + std::vector<value> result_s; + rtree.query(query_box, std::back_inserter(result_s)); + + // find 5 nearest values to a point + std::vector<value> result_n; + rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n)); + + // display results + std::cout << "spatial query box:" << std::endl; + std::cout << bg::wkt<box>(query_box) << std::endl; + std::cout << "spatial query result:" << std::endl; + BOOST_FOREACH(value i, result_s) + std::cout << bg::wkt<box>(boxes[i]) << std::endl; + + std::cout << "knn query point:" << std::endl; + std::cout << bg::wkt<point>(point(0, 0)) << std::endl; + std::cout << "knn query result:" << std::endl; + BOOST_FOREACH(value i, result_n) + std::cout << bg::wkt<box>(boxes[i]) << std::endl; + + return 0; +} ++
+
+More information about the R-tree implementation, other algorithms and queries diff --git a/doc/html/index.html b/doc/html/index.html index dff9d3363..42d405d7b 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -3,7 +3,7 @@
Last revised: February 24, 2013 at 03:27:27 GMT |
+Last revised: February 24, 2013 at 16:39:24 GMT |