|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84216 - in trunk/libs/geometry: doc/index/rtree index/test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-05-09 19:42:42
Author: awulkiew
Date: 2013-05-09 19:42:42 EDT (Thu, 09 May 2013)
New Revision: 84216
URL: http://svn.boost.org/trac/boost/changeset/84216
Log:
geometry.index doc, test: added test for !satisfies(), queries docs updated.
Text files modified:
trunk/libs/geometry/doc/index/rtree/query.qbk | 31 +++++++++++++++++++++++--------
trunk/libs/geometry/index/test/rtree/test_rtree.hpp | 13 ++++++++++++-
2 files changed, 35 insertions(+), 9 deletions(-)
Modified: trunk/libs/geometry/doc/index/rtree/query.qbk
==============================================================================
--- trunk/libs/geometry/doc/index/rtree/query.qbk (original)
+++ trunk/libs/geometry/doc/index/rtree/query.qbk 2013-05-09 19:42:42 EDT (Thu, 09 May 2013)
@@ -12,8 +12,8 @@
Queries returns `__value__`s which meets some predicates. Currently supported are three types of predicates:
-* spatial predicates - defining relationship between stored Values and some Geometry,
-* nearest predicate - defining relationship between stored Values and some Point,
+* spatial predicates - spatial conditions that must be met by stored Value and some Geometry,
+* distance predicates - distance conditions that must be met by stored Value and some Geometry,
* user-defined unary predicate - function, function object or lambda expression checking user-defined condition.
For example queries may be used to retrieve Values:
@@ -47,14 +47,14 @@
[endsect]
-[section Spatial queries]
+[section Spatial predicates]
-Spatial query returns `__value__`s which are related somehow to some Geometry - box, polygon, etc.
-Names of spatial predicates corresponds to names of __boost_geometry__ algorithms. Examples of some
+Queries using spatial predicates returns `__value__`s which are related somehow to some Geometry - box, polygon, etc.
+Names of spatial predicates correspond to names of __boost_geometry__ algorithms. Examples of some
basic queries may be found in tables below. The query region and result `Value`s are orange.
[table
-[[intersects(Box) - default] [covered_by(Box)] [disjoint(Box)] [overlaps(Box)] [within(Box)]]
+[[intersects(Box)] [covered_by(Box)] [disjoint(Box)] [overlaps(Box)] [within(Box)]]
[[[$img/index/rtree/intersects.png]] [[$img/index/rtree/within.png]] [[$img/index/rtree/disjoint.png]] [[$img/index/rtree/overlaps.png]] [[$img/index/rtree/within.png]]]
]
@@ -71,7 +71,7 @@
rt.query(index::overlaps(box), std::back_inserter(result));
rt.query(index::within(box), std::back_inserter(result));
-All predicates may be negated, e.g.:
+All spatial predicates may be negated, e.g.:
rt.query(!index::intersects(box), std::back_inserter(result));
// the same as
@@ -79,7 +79,9 @@
[endsect]
-[section Nearest neighbours queries]
+[section Distance predicates]
+
+[heading Nearest neighbours queries]
Nearest neighbours queries returns `__value__`s which are closest to some point in space.
Additionally it is possible to define how the distance to the `Value` should be calculated.
@@ -146,6 +148,19 @@
std::back_inserter(result));
#endif
+`satisfies()` may be negated, e.g.:
+
+ bool is_red(__value__ const& v) { return v.is_red(); }
+ bool is_not_red(__value__ const& v) { return !v.is_red(); }
+
+ // ...
+
+ rt.query(index::intersects(box) && index::satisfies(is_red),
+ std::back_inserter(result));
+ // the same as
+ rt.query(index::intersects(box) && !index::satisfies(is_not_red),
+ std::back_inserter(result));
+
[endsect]
[section Passing a set of predicates]
Modified: trunk/libs/geometry/index/test/rtree/test_rtree.hpp
==============================================================================
--- trunk/libs/geometry/index/test/rtree/test_rtree.hpp (original)
+++ trunk/libs/geometry/index/test/rtree/test_rtree.hpp 2013-05-09 19:42:42 EDT (Thu, 09 May 2013)
@@ -999,16 +999,27 @@
template <typename Rtree, typename Value>
void satisfies(Rtree const& rtree, std::vector<Value> const& input)
{
- std::vector<Value> result;
+ std::vector<Value> result;
rtree.query(bgi::satisfies(satisfies_obj()), std::back_inserter(result));
BOOST_CHECK(result.size() == input.size());
result.clear();
+ rtree.query(!bgi::satisfies(satisfies_obj()), std::back_inserter(result));
+ BOOST_CHECK(result.size() == 0);
+
+ result.clear();
rtree.query(bgi::satisfies(satisfies_fun<Value>), std::back_inserter(result));
BOOST_CHECK(result.size() == input.size());
+ result.clear();
+ rtree.query(!bgi::satisfies(satisfies_fun<Value>), std::back_inserter(result));
+ BOOST_CHECK(result.size() == 0);
+
#ifndef BOOST_NO_CXX11_LAMBDAS
result.clear();
rtree.query(bgi::satisfies([](Value const&){ return true; }), std::back_inserter(result));
BOOST_CHECK(result.size() == input.size());
+ result.clear();
+ rtree.query(!bgi::satisfies([](Value const&){ return true; }), std::back_inserter(result));
+ BOOST_CHECK(result.size() == 0);
#endif
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk