diff --git a/doc/html/geometry_index/r_tree/creation_and_modification.html b/doc/html/geometry_index/r_tree/creation_and_modification.html
index 50c29f984..8725a9e0f 100644
--- a/doc/html/geometry_index/r_tree/creation_and_modification.html
+++ b/doc/html/geometry_index/r_tree/creation_and_modification.html
@@ -83,11 +83,10 @@
Indexables. Each type adapted to Point
or Box
concept is an Indexable. Default Translator
- index::translator::def<Value>
- is able to handle Point,
- Box,
- std::pair<...>,
- pointer, iterator or smart pointer.
+ index::translator::def<Value> is able to handle Point,
+ Box
+ or std::pair<...>
+ Values.
BasicValue =
- Indexable |
- std::pair<Indexable, T> | std::pair<T, Indexable>
- Value = BasicValue
- | BasicValue* | Iterator<BasicValue>
- | SmartPtr<BasicValue>
+ Value = Indexable
+ | std::pair<Indexable,
+ T>
+ If comparison of two Values is required, the default translator
+ compares both components of the std::pair<...>. If the second one is a Geometry, geometry::equals() function is used. For other types it
+ uses operator==().
+
Examples of Value types:
Value.
CoordinateType.
+ Exception-safe copy constructor of the CoordinateType
+ used in the Indexable.
+ Translator.
|
- nothrow (default) or strong - [a] + nothrow |
@@ -139,8 +142,7 @@
- nothrow (default) or strong - [b] + nothrow |
@@ -153,7 +155,19 @@
+ | + +
|
+
+ |
+
+ + nothrow |
- nothrow + nothrow or strong + [b] |
@@ -336,22 +351,12 @@
|
[a]
- nothrow - if [b]
- nothrow - if [c]
- nothrow - if allocators are equal and | |
- R-tree is a self-balancing search tree. Each tree's node store a box descring - the space occupied by children nodes. At the bottom of the structure, there - are leaf-nodes which contains values (geometric objects representations). - Minimal and maximal numbers of values/children which may be stored inside - each node are user defined. + 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 + 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.
++ The R-tree structure is presented on the image below. Each R-tree's node + store a box descring the space occupied by its children nodes. At the bottom + of the structure, there are leaf-nodes which contains values (geometric objects + representations). +
+
+
+
+ The number of maximum and mininimum node's elements must be specified by + the user. If the number of elements reaches it's maximum the new node is + created and elements are split between nodes. If the number of elements in + node is too small, the node is deleted and elements are reinserted into the + tree. +
++ The R-tree is a self-balanced data structure. The key part of balancing algorithm + is node splitting algorithm [2] [3]. Each algorithm would produce 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. This is a "better" split because later, in the searching + process less nodes must be traversed in order to find desired obejcts. On + the other hand more complex analysis takes more time. In general faster inserting + will result in slower searching and vice versa. Example structures of trees + created by use of three different algorithms and operations time are presented + below. +
+| + | +
+ + linear algorithm + + |
+
+ + quadratic algorithm + + |
+
+ + R*-tree + + |
+
|---|---|---|---|
|
+ + Structure + + |
+
+
+ |
+
+
+ |
+
+
+ |
+
|
+ + 1M Values inserts + + |
+
+ + 1.85s + + |
+
+ + 3.10s + + |
+
+ + 24.52s + + |
+
|
+ + 1M spatial queries + + |
+
+ + 8.60s + + |
+
+ + 2.74s + + |
+
+ + 1.31s + + |
+
|
+ + 100k knn queries + + |
+
+ + 3.49s + + |
+
+ + 1.59s + + |
+
+ + 0.84s + + |
+
+ Key features of this implementation of the R-tree are: +
+[1] + Guttman, A. (1984). R-Trees: A Dynamic Index Structure for Spatial + Searching +
[2] + Greene, D. (1989). An implementation and performance analysis + of spatial data access methods +
[3] + Beckmann, N.; Kriegel, H. P.; Schneider, R.; Seeger, B. (1990). The + R*-tree: an efficient and robust access method for points and rectangles +
| diff --git a/doc/html/geometry_index/r_tree/nearest_neighbours_queries.html b/doc/html/geometry_index/r_tree/nearest_neighbours_queries.html index 6a2482203..497577ccc 100644 --- a/doc/html/geometry_index/r_tree/nearest_neighbours_queries.html +++ b/doc/html/geometry_index/r_tree/nearest_neighbours_queries.html @@ -37,6 +37,55 @@ |
|
+ + Basic knn query + + |
+
+ + knn in a ring (Value's furthest point) + + |
+
+ + knn in a ring (Value's closest point) + + |
+
|---|---|---|
|
+
+ |
+
+
+ |
+
+
+ |
+
-
#include <vector> - -#include <boost/geometry.hpp> +#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/box.hpp> #include <boost/geometry/extensions/index/rtree/rtree.hpp> +// to store queries results +#include <vector> + +// just for output +#include <iostream> +#include <boost/foreach.hpp> + namespace bg = boost::geometry; namespace bgi = boost::geometry::index;
- It is possible to store user-defined types in the R-tree. To keep it simple - we will use predefined Point - and Box. + Typically you'll store e.g.
std::pair<Box, MyGeometryId>in the R-tree.MyGeometryId+ will be some indentifier of a complexGeometry+ stored in other container, e.g. index type of aPolygon+ stored in the vector or an iterator of list ofRings. + To keep it simple to defineValue+ we will use predefined Box + and unsigned int.@@ -62,48 +71,80 @@
- R-tree may be created using various algorithm and parameters. In this example - we will use quadratic algorithm. Maximum number of elements in nodes are - set to 32, minimum to 8. + R-tree may be created using various algorithm and parameters. You should + choose the algorithm you'll find the best for your purpose. In this example + we will use quadratic algorithm. Parameters are passed as template parameters. + Maximum number of elements in nodes are set to 32, minimum to 8.
-
bgi::rtree< value, bgi::quadratic<32, 8> > rtree; +// create the rtree using default constructor +bgi::rtree< value, bgi::quadratic<32, 8> > rtree;
- Inserting values into the R-tree may be done by calling insert() method. + Typically
Values will be + generated in a loop from e.g.Polygons + stored in some other container. In this caseBox+ objects will probably be created withgeometry::make_envelope()function. But to keep it simple lets just + generate some boxes manually and insert them into the R-tree by usinginsert()+ method.-
// create some box -// this typically will be an envelope of some geometry -box b(point(0, 0), point(10, 10)); -// insert new value -rtree.insert(std::make_pair(b, 0)); +// create some values +for ( unsigned i = 0 ; i < 10 ; ++i ) +{ + // create a box + box b(point(i, i), point(i + 0.5f, i + 0.5f)); + // insert new value + rtree.insert(std::make_pair(b, i)); +}
There are various types of spatial queries that may be performed, they can - be even combined together in one call. For simplicity, default one is used. + be even combined together in one call. For simplicity, we use the default + one. The following query return values intersecting a box. The sequence of +
Valuesin the result is not + specified.-
// find values intersecting a box -std::vector<value> result; -rtree.spatial_query(b, std::back_inserter(result)); +// find values intersecting some area defined by a box +box query_box(point(0, 0), point(5, 5)); +std::vector<value> result_s; +rtree.spatial_query(query_box, std::back_inserter(result_s));
- Default k-nearest neighbors query may be performed as follows. + Other type of query is k-nearest neighbor search. It returns some number + of values nearest to some point in space. The default knn query may be performed + as follows. The sequence of
Values+ in the result is not specified.
// find 5 nearest values to a point -rtree.nearest_query(point(0, 0), 5, std::back_inserter(result)); +std::vector<value> result_n; +rtree.nearest_query(point(0, 0), 5, std::back_inserter(result_n)); +++
++ At the end we'll print results. +
++
+std::cout << "spatial query result:" << std::endl; +BOOST_FOREACH(value const& v, result_s) + std::cout << bg::wkt<box>(v.first) << " - " << v.second << std::endl; +std::cout << "knn query result:" << std::endl; +BOOST_FOREACH(value const& v, result_n) + std::cout << bg::wkt<box>(v.first) << " - " << v.second << std::endl;diff --git a/doc/html/geometry_index/r_tree/spatial_queries.html b/doc/html/geometry_index/r_tree/spatial_queries.html index 910bf2c5b..7076a9506 100644 --- a/doc/html/geometry_index/r_tree/spatial_queries.html +++ b/doc/html/geometry_index/r_tree/spatial_queries.html @@ -32,6 +32,76 @@
+ Spatial queries returns Values
+ which meets some predicates. For instance it may be used to retrieve Values
+ intersecting some area or are within some other area. The examples of some
+ basic queries may be found in the table below. The query region and result
+ Values are orange.
+
|
+ + intersects (default) + + |
+
+ + covered_by + + |
+
+ + disjoint + + |
+
+ + overlaps + + |
+
+ + within + + |
+
|---|---|---|---|---|
|
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
Last revised: November 21, 2012 at 16:05:59 GMT |
+Last revised: November 25, 2012 at 21:34:09 GMT |
::apply(), 1, 3); - test_copy_assignment_move(tree, qbox); + test_copy_assignment_swap_move(tree, qbox); test_remove(tree, qbox); @@ -651,7 +669,7 @@ void test_rtree_by_value(Parameters const& parameters) test_nearest_query(empty_tree, empty_input, pt); test_nearest_query_k(empty_tree, empty_input, pt, 10); test_nearest_query_not_found(empty_tree, generate_outside_point
::apply(), 1, 3);
- test_copy_assignment_move(empty_tree, qbox);
+ test_copy_assignment_swap_move(empty_tree, qbox);
}
// run all tests for one Algorithm for some number of rtrees
diff --git a/tests/additional_glut_vis.cpp b/tests/additional_glut_vis.cpp
index cd8eb5cc7..647b72b6b 100644
--- a/tests/additional_glut_vis.cpp
+++ b/tests/additional_glut_vis.cpp
@@ -9,6 +9,8 @@
#include