From 672f654aaa57bb19e1e63d5f342794f4f47166b3 Mon Sep 17 00:00:00 2001
From: Adam Wulkiewicz Copyright © 2008 Federico J. Fernandez Copyright © 2011 Adam Wulkiewicz Use, modification and distribution is subject to the Boost
+ Use, modification and distribution is subject to the Boost
Software License, Version 1.0. (See accompanying file
R-tree is a self-balancing search tree with nodes stored with their axis aligned
@@ -42,7 +42,7 @@ which may be stored inside the node are user defined.
R-tree has 4 parameters:
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-
Value - type of object which will be stored in the container.
Parameters - compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers.
Translator - type of object translating Value objects to Indexable objects (Point or Box) which R-tree can handle.
Allocator - the allocator.
-In order to create a R-tree object storing values of type std::pair<Box, int> one may use the following code
+In order to create a R-tree object storing values of type std::pair<Box, int> one may use the following code
using namespace boost::geometry; @@ -80,33 +80,34 @@ index::rtree< Value, index::quadratic<32, 8> > rt;R-tree may store Values of any type as long as there is passed the Translator which knows how to interpret those Values and extract an object understandable by the R-tree. Those objects are called Indexables and they are simply of type adapted to Point or Box concept. Default translator -index::translator::def<Value> is able to handle Points, Boxes, std::pairs, pointers and iterators. +
index::translator::def<Value>is able to handlePoint,Box, +std::pair<...>, pointer, iterator or smart pointer.-
- Indexable = Point | Box
-- BasicValue = Indexable | std::pair<Indexable, T> | std::pair<T, Indexable>
-- Value = BasicValue | BasicValue* | Iterator<BasicValue>
+- +
Indexable = Point | Box- +
BasicValue = Indexable | std::pair<Indexable, T> | std::pair<T, Indexable>Value = BasicValue | BasicValue* | Iterator<BasicValue> | SmartPtr<BasicValue>Examples of Value types:
-
- geometry::model::point<...>
-- geometry::model::point_xy<...>
-- geometry::model::box<...>
-- std::pair≤geometry::model::box<...>, size_t>
+- +
geometry::model::point<...>- +
geometry::model::point_xy<...>- +
geometry::model::box<...>std::pair<geometry::model::box<...>, size_t>
Values may be inserted to the R-tree in many various ways. Final structure of nodes depends on algorithms used in the process, especially nodes' splitting algorithm. Currently, three @@ -137,7 +138,7 @@ index::rtree< Value, index::rstar<32, 8> > rt;
Create
@@ -150,22 +151,24 @@ index::rtree< Value, index::quadratic<32, 8> > rt; Insert and remove by method call-rt.insert(std::make_pair(Box(...), 0)); -rt.remove(std::make_pair(Box(...), 0)); +Value v = std::make_pair(Box(...), 0); +rt.insert(v); +rt.remove(v);or by function call
-index::insert(rt, std::make_pair(Box(...), 0)); -index::remove(rt, std::make_pair(Box(...), 0)); +Value v = std::make_pair(Box(...), 0); +index::insert(rt, v); +index::remove(rt, v);
There are three ways to perform a spatial query. Following queries returns Values intersecting some box_region. @@ -188,7 +191,7 @@ index::query(rt, box_region, std::back_inserter(returned_values));
operator | (as with ranges)
Box box_region(...); BOOST_FOREACH(Value &v, rt | index::query_filtered(box_region)) @@ -201,7 +204,7 @@ BOOST_FOREACH(Value &v, rt | index::query_filtered(box_region))It is possible to define other relations between queried Values and region/regions of interest. Names of predicates corresponds to names of Boost.Geometry algorithms. @@ -225,7 +228,7 @@ rt.query(!index::intersects(box), std::back_inserter(result)); rt.query(index::disjoint(box), std::back_inserter(result));
-It's possible to use some number of predicates by passing std::pair<P1, P2>
+It's possible to use some number of predicates by passing std::pair<Pred1, Pred2>
rt.query( @@ -233,7 +236,7 @@ rt.query( , std::back_inserter(result));
-or boost::tuple<P1, P2, P3, ...>
+or boost::tuple<Pred1, Pred2, Pred3, ...>
rt.query( @@ -241,7 +244,7 @@ rt.query( , std::back_inserter(result));
-There is special predicate index::value taking user-defined function/functor
+There is special predicate index::value(Fun) taking user-defined function/functor
which checks if Value should be returned by the query.
@@ -261,7 +264,7 @@ rt.query( TODO diff --git a/doc/index.xml b/doc/index.xml index 440fa90df..720454e6a 100644 --- a/doc/index.xml +++ b/doc/index.xml @@ -65,21 +65,21 @@ rtree<Value, Parameters, Translator, Allocator>-Value - type of object which will be stored in the container. + Value- type of object which will be stored in the container.-Parameters - compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers. + Parameters- compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers.-Translator - type of object translating Value objects to Indexable objects (Point or Box) which R-tree can handle. + Translator- type of object translating Value objects to Indexable objects (PointorBox) which R-tree can handle.-Allocator - the allocator. + Allocator- the allocator.-In order to create a R-tree object storing values of type std::pair<Box, int> one may use the following code +In order to create a R-tree object storing values of type @@ -150,13 +151,15 @@ index::rtree< Value, index::quadratic<32, 8> > rt; Insert and remove by method callstd::pair<Box, int>one may use the following codeusing namespace boost::geometry; typedef std::pair<Box, int> Value; @@ -94,18 +94,19 @@ index::rtree< Value, index::quadratic<32, 8> > rt; R-tree may store Values of any type as long as there is passed the Translator which knows how to interpret those Values and extract an object understandable by the R-tree. Those objects are called Indexables and they are simply of type adapted to Point or Box concept. Default translator -index::translator::def<Value> is able to handle Points, Boxes, std::pairs, pointers and iterators. + index::translator::def<Value>is able to handlePoint,Box, +std::pair<...>, pointer, iterator or smart pointer.- Examples of Value types:Indexable = Point | Box -BasicValue = Indexable | std::pair<Indexable, T> | std::pair<T, Indexable> -Value = BasicValue | BasicValue* | Iterator<BasicValue> ++ Indexable = Point | Box+ BasicValue = Indexable | std::pair<Indexable, T> | std::pair<T, Indexable>Value = BasicValue | BasicValue* | Iterator<BasicValue> | SmartPtr<BasicValue>- geometry::model::point<...> -geometry::model::point_xy<...> -geometry::model::box<...> -std::pair≤geometry::model::box<...>, size_t> ++ geometry::model::point<...>+ geometry::model::point_xy<...>+ geometry::model::box<...>std::pair<geometry::model::box<...>, size_t>-rt.insert(std::make_pair(Box(...), 0)); -rt.remove(std::make_pair(Box(...), 0)); +Value v = std::make_pair(Box(...), 0); +rt.insert(v); +rt.remove(v); or by function call-index::insert(rt, std::make_pair(Box(...), 0)); -index::remove(rt, std::make_pair(Box(...), 0)); +Value v = std::make_pair(Box(...), 0); +index::insert(rt, v); +index::remove(rt, v); @@ -184,7 +187,7 @@ index::query(rt, box_region, std::back_inserter(returned_values));-Use of operator | (as with ranges) +Use of operator |(as with ranges)Box box_region(...); BOOST_FOREACH(Value &v, rt | index::query_filtered(box_region)) @@ -216,19 +219,19 @@ rt.query(!index::intersects(box), std::back_inserter(result)); // the same as rt.query(index::disjoint(box), std::back_inserter(result)); -It's possible to use some number of predicates by passing std::pair<P1, P2> +It's possible to use some number of predicates by passingstd::pair<Pred1, Pred2>rt.query( std::make_pair(index::intersects(box1), !index::within(box2)) , std::back_inserter(result)); -or boost::tuple<P1, P2, P3, ...> +orboost::tuple<Pred1, Pred2, Pred3, ...>rt.query( boost::make_tuple(index::intersects(box1), !index::within(box2), index::overlaps(box3)) , std::back_inserter(result)); -There is special predicate index::value taking user-defined function/functor +There is special predicateindex::value(Fun)taking user-defined function/functor which checks if Value should be returned by the query.bool fun(Value const& v)