Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75713 - in sandbox-branches/geometry/index/doc: . html html/index
From: adam.wulkiewicz_at_[hidden]
Date: 2011-11-28 10:43:14


Author: awulkiew
Date: 2011-11-28 10:43:13 EST (Mon, 28 Nov 2011)
New Revision: 75713
URL: http://svn.boost.org/trac/boost/changeset/75713

Log:
knn queries description added to doc
Text files modified:
   sandbox-branches/geometry/index/doc/html/index.html | 16 +-
   sandbox-branches/geometry/index/doc/html/index/rtree.html | 213 ++++++++++++++++++++++++++++++++++-----
   sandbox-branches/geometry/index/doc/index.xml | 175 ++++++++++++++++++++++++++++++--
   3 files changed, 353 insertions(+), 51 deletions(-)

Modified: sandbox-branches/geometry/index/doc/html/index.html
==============================================================================
--- sandbox-branches/geometry/index/doc/html/index.html (original)
+++ sandbox-branches/geometry/index/doc/html/index.html 2011-11-28 10:43:13 EST (Mon, 28 Nov 2011)
@@ -31,7 +31,7 @@
 <div><p class="copyright">Copyright &#169; 2008 Federico J. Fernandez</p></div>
 <div><p class="copyright">Copyright &#169; 2011 Adam Wulkiewicz</p></div>
 <div><div class="legalnotice">
-<a name="id798351"></a><p>Use, modification and distribution is subject to the Boost
+<a name="id789613"></a><p>Use, modification and distribution is subject to the Boost
     Software License, Version 1.0. (See accompanying file
     <code class="filename">LICENSE_1_0.txt</code> or copy at http://www.boost.org/LICENSE_1_0.txt)</p>
 </div></div>
@@ -42,13 +42,13 @@
 <dt><span class="section">Introduction</span></dt>
 <dt><span class="section">R-tree</span></dt>
 <dd><dl>
-<dt><span class="section">R-tree creation</span></dt>
-<dt><span class="section">Values, Indexables and default Translator</span></dt>
-<dt><span class="section">Inserting and splitting algorithms</span></dt>
-<dt><span class="section">Inserting and removing Values</span></dt>
-<dt><span class="section">Spatial queries</span></dt>
-<dt><span class="section">Spatial predicates</span></dt>
-<dt><span class="section">Nearest neighbor queries</span></dt>
+<dt><span class="section">R-tree creation</span></dt>
+<dt><span class="section">Values, Indexables and default Translator</span></dt>
+<dt><span class="section">Inserting and splitting algorithms</span></dt>
+<dt><span class="section">Inserting and removing Values</span></dt>
+<dt><span class="section">Spatial queries</span></dt>
+<dt><span class="section">Spatial predicates</span></dt>
+<dt><span class="section">Nearest neighbors queries</span></dt>
 </dl></dd>
 </dl>
 </div>

Modified: sandbox-branches/geometry/index/doc/html/index/rtree.html
==============================================================================
--- sandbox-branches/geometry/index/doc/html/index/rtree.html (original)
+++ sandbox-branches/geometry/index/doc/html/index/rtree.html 2011-11-28 10:43:13 EST (Mon, 28 Nov 2011)
@@ -25,13 +25,13 @@
 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
 <a name="index.rtree"></a>R-tree</h2></div></div></div>
 <div class="toc"><dl>
-<dt><span class="section">R-tree creation</span></dt>
-<dt><span class="section">Values, Indexables and default Translator</span></dt>
-<dt><span class="section">Inserting and splitting algorithms</span></dt>
-<dt><span class="section">Inserting and removing Values</span></dt>
-<dt><span class="section">Spatial queries</span></dt>
-<dt><span class="section">Spatial predicates</span></dt>
-<dt><span class="section">Nearest neighbor queries</span></dt>
+<dt><span class="section">R-tree creation</span></dt>
+<dt><span class="section">Values, Indexables and default Translator</span></dt>
+<dt><span class="section">Inserting and splitting algorithms</span></dt>
+<dt><span class="section">Inserting and removing Values</span></dt>
+<dt><span class="section">Spatial queries</span></dt>
+<dt><span class="section">Spatial predicates</span></dt>
+<dt><span class="section">Nearest neighbors queries</span></dt>
 </dl></div>
 <p>
 R-tree is a self-balancing search tree with nodes stored with their axis aligned
@@ -42,7 +42,7 @@
 </p>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798399"></a>R-tree creation</h3></div></div></div>
+<a name="id789661"></a>R-tree creation</h3></div></div></div>
 <p>
 R-tree has 4 parameters:
 </p>
@@ -56,10 +56,13 @@
 <code class="computeroutput">Value</code> - type of object which will be stored in the container.
 </li>
 <li class="listitem">
-<code class="computeroutput">Parameters</code> - compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers.
+<code class="computeroutput">Parameters</code> - compile-time parameters, e.g. inserting/splitting
+algorithm with min and max nodes' elements numbers.
 </li>
 <li class="listitem">
-<code class="computeroutput">Translator</code> - type of object translating Value objects to Indexable objects (<code class="computeroutput">Point</code> or <code class="computeroutput">Box</code>) which R-tree can handle.
+<code class="computeroutput">Translator</code> - type of object translating <code class="computeroutput">Value</code> objects
+to <code class="computeroutput">Indexable</code> objects (<code class="computeroutput">Point</code> or <code class="computeroutput">Box</code>) which
+R-tree can handle.
 </li>
 <li class="listitem">
 <code class="computeroutput">Allocator</code> - the allocator.
@@ -68,7 +71,8 @@
 <p>
 </p>
 <p>
-In order to create a R-tree object storing values of type <code class="computeroutput">std::pair&lt;Box, int&gt;</code> one may use the following code
+In order to create a R-tree object storing values of type
+<code class="computeroutput">std::pair&lt;Box, int&gt;</code> one may use the following code
 </p>
 <pre class="programlisting">
 using namespace boost::geometry;
@@ -80,13 +84,15 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798477"></a>Values, Indexables and default Translator</h3></div></div></div>
+<a name="id789748"></a>Values, Indexables and default Translator</h3></div></div></div>
 <p>
-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
-<code class="computeroutput">index::translator::def&lt;Value&gt;</code> is able to handle <code class="computeroutput">Point</code>, <code class="computeroutput">Box</code>,
-<code class="computeroutput">std::pair&lt;...&gt;</code>, pointer, iterator or smart pointer.
+R-tree may store <code class="computeroutput">Value</code>s of any type as long as there is passed
+the <code class="computeroutput">Translator</code> which knows how to interpret those <code class="computeroutput">Value</code>s
+and extract an object understandable by the R-tree. Those objects are called
+<code class="computeroutput">Indexables</code> and they are simply of type adapted to <code class="computeroutput">Point</code>
+or <code class="computeroutput">Box</code> concept. Default translator <code class="computeroutput">index::translator::def&lt;Value&gt;</code>
+is able to handle <code class="computeroutput">Point</code>, <code class="computeroutput">Box</code>, <code class="computeroutput">std::pair&lt;...&gt;</code>,
+pointer, iterator or smart pointer.
 </p>
 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
 <li class="listitem"><code class="computeroutput">Indexable = Point | Box</code></li>
@@ -94,7 +100,7 @@
 <li class="listitem"><code class="computeroutput">Value = BasicValue | BasicValue* | Iterator&lt;BasicValue&gt; | SmartPtr&lt;BasicValue&gt;</code></li>
 </ul></div>
 <p>
-Examples of Value types:
+Examples of <code class="computeroutput">Value</code> types:
 </p>
 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
 <li class="listitem"><code class="computeroutput">geometry::model::point&lt;...&gt;</code></li>
@@ -107,9 +113,9 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798556"></a>Inserting and splitting algorithms</h3></div></div></div>
+<a name="id789861"></a>Inserting and splitting algorithms</h3></div></div></div>
 <p>
-Values may be inserted to the R-tree in many various ways. Final structure of nodes depends
+<code class="computeroutput">Value</code>s 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
 well-known types of R-trees may be created.
 </p>
@@ -138,7 +144,7 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798596"></a>Inserting and removing Values</h3></div></div></div>
+<a name="id789906"></a>Inserting and removing Values</h3></div></div></div>
 <p>
 Create
 </p>
@@ -168,10 +174,10 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798621"></a>Spatial queries</h3></div></div></div>
+<a name="id789931"></a>Spatial queries</h3></div></div></div>
 <p>
 There are three ways to perform a spatial query. Following queries returns
-Values intersecting some box_region.
+<code class="computeroutput">Value</code>s intersecting some box_region.
 </p>
 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
 <li class="listitem">
@@ -204,9 +210,9 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798665"></a>Spatial predicates</h3></div></div></div>
+<a name="id789980"></a>Spatial predicates</h3></div></div></div>
 <p>
-It is possible to define other relations between queried Values and region/regions
+It is possible to define other relations between queried <code class="computeroutput">Value</code>s and region/regions
 of interest. Names of predicates corresponds to names of Boost.Geometry algorithms.
 </p>
 <pre class="programlisting">
@@ -245,7 +251,7 @@
 </pre>
 <p>
 There is special predicate <code class="computeroutput">index::value(Fun)</code> taking user-defined function/functor
-which checks if Value should be returned by the query.
+which checks if <code class="computeroutput">Value</code> should be returned by the query.
 </p>
 <pre class="programlisting">
 bool fun(Value const&amp; v)
@@ -264,8 +270,159 @@
 </div>
 <div class="section">
 <div class="titlepage"><div><div><h3 class="title">
-<a name="id798716"></a>Nearest neighbor queries</h3></div></div></div>
-TODO
+<a name="id790041"></a>Nearest neighbors queries</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section">k nearest neighbors</span></dt>
+<dt><span class="section">One nearest neighbor</span></dt>
+<dt><span class="section">Distances predicates</span></dt>
+<dt><span class="section">Using spatial predicates</span></dt>
+</dl></div>
+<div class="section">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="id790047"></a>k nearest neighbors</h4></div></div></div>
+<p>
+There are three ways of performing knn queries. Following queries returns
+k <code class="computeroutput">Value</code>s closest to some point in space. For <code class="computeroutput">Box</code>es
+<code class="computeroutput">Indexable</code>s closest point of a <code class="computeroutput">Box</code> is taken into
+account by default.
+</p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+Method call
+<pre class="programlisting">
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+rt.nearest(pt, k, std::back_inserter(returned_values));
+</pre>
+</li>
+<li class="listitem">
+Function call
+<pre class="programlisting">
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+index::nearest(rt, pt, k, std::back_inserter(returned_values));
+</pre>
+</li>
+<li class="listitem">
+Use of <code class="computeroutput">operator |</code><pre class="programlisting">
+Point pt(...);
+BOOST_FOREACH(Value &amp;v, rt | index::nearest_filtered(pt, k))
+ ;// do something with v
+</pre>
+</li>
+</ul></div>
+<p>
+</p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="id797757"></a>One nearest neighbor</h4></div></div></div>
+<p>
+Another type of nearest neighbor query is searching for the one closest <code class="computeroutput">Value</code>.
+If it is found, 1 is returned by the method or function. This kind of query
+has only two forms.
+</p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+Method call
+<pre class="programlisting">
+Value returned_value;
+Point pt(...);
+size_t n = rt.nearest(pt, returned_value);
+</pre>
+</li>
+<li class="listitem">
+Function call
+<pre class="programlisting">
+Value returned_value;
+Point pt(...);
+size_t n = index::nearest(rt, pt, returned_value);
+</pre>
+</li>
+</ul></div>
+<p>
+</p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="id797793"></a>Distances predicates</h4></div></div></div>
+<p>
+It is possible to define if calculated distance between query point and <code class="computeroutput">Value</code> should be
+greater, lesser or between some other distances. Those are called <code class="computeroutput">DistancesPredicate</code>s and
+may be defined as follows.
+</p>
+<pre class="programlisting">
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+
+/* default - without bounds */
+index::nearest(rt, pt, k, std::back_inserter(returned_values));
+
+/* same as default */
+index::nearest(rt, index::unbounded(pt), k, std::back_inserter(returned_values));
+
+/* distance must be greater than or equal to 10 */
+index::nearest(rt, index::min_bounded(pt, 10), k, std::back_inserter(returned_values));
+
+/* distance must be lesser than or equal to 500 */
+index::nearest(rt, index::max_bounded(pt, 500), k, std::back_inserter(returned_values));
+
+/* distance must be between 10 and 500 */
+index::nearest(rt, index::bounded(pt, 10, 500), k, std::back_inserter(returned_values));
+
+</pre>
+<p>
+</p>
+<p>
+Furthermore, it's possible to define if the closest, furthest or centroidal point of the
+non-point <code class="computeroutput">Indexable</code> should be taken into account in the routine calculating distance.
+</p>
+<pre class="programlisting">
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+
+/* default - distance between Indexable's closest point and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, 10), k, std::back_inserter(returned_values));
+
+/* same as default - distance between Indexable's closest point and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, index::near(10)), k, std::back_inserter(returned_values));
+
+/* distance between Indexable's furthest point and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, index::far(10)), k, std::back_inserter(returned_values));
+
+/* distance between Indexable's centroid and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, index::centroid(10)), k, std::back_inserter(returned_values));
+</pre>
+<p>
+</p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="id797832"></a>Using spatial predicates</h4></div></div></div>
+<p>
+It is possible to use spatial predicates described before in knn queries.
+</p>
+<pre class="programlisting">
+Value returned_value;
+std::vector&lt;Value&gt; returned_values;
+
+Point pt(...);
+Box b(...);
+
+size_t n1 = rt.nearest(index::bounded(pt, index::far(1), 10), index::intersects(b), returned_value);
+
+size_t n2 = index::nearest(rt, pt, k, index::within(b), std::back_inserter(returned_values));
+
+BOOST_FOREACH(Value &amp;v, rt | index::nearest_filtered(pt, k, index::covered_by(b)))
+ ;// do something with v
+</pre>
+<p>
+</p>
+</div>
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

Modified: sandbox-branches/geometry/index/doc/index.xml
==============================================================================
--- sandbox-branches/geometry/index/doc/index.xml (original)
+++ sandbox-branches/geometry/index/doc/index.xml 2011-11-28 10:43:13 EST (Mon, 28 Nov 2011)
@@ -68,10 +68,13 @@
 <code>Value</code> - type of object which will be stored in the container.
 </listitem>
 <listitem>
-<code>Parameters</code> - compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers.
+<code>Parameters</code> - compile-time parameters, e.g. inserting/splitting
+algorithm with min and max nodes' elements numbers.
 </listitem>
 <listitem>
-<code>Translator</code> - type of object translating Value objects to Indexable objects (<code>Point</code> or <code>Box</code>) which R-tree can handle.
+<code>Translator</code> - type of object translating <code>Value</code> objects
+to <code>Indexable</code> objects (<code>Point</code> or <code>Box</code>) which
+R-tree can handle.
 </listitem>
 <listitem>
 <code>Allocator</code> - the allocator.
@@ -79,7 +82,8 @@
 </itemizedlist>
 </para>
 <para>
-In order to create a R-tree object storing values of type <code>std::pair&lt;Box, int&gt;</code> one may use the following code
+In order to create a R-tree object storing values of type
+<code>std::pair&lt;Box, int&gt;</code> one may use the following code
 <programlisting>
 using namespace boost::geometry;
 typedef std::pair&lt;Box, int&gt; Value;
@@ -91,17 +95,19 @@
 <section>
 <title>Values, Indexables and default Translator</title>
 <para>
-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
-<code>index::translator::def&lt;Value&gt;</code> is able to handle <code>Point</code>, <code>Box</code>,
-<code>std::pair&lt;...&gt;</code>, pointer, iterator or smart pointer.
+R-tree may store <code>Value</code>s of any type as long as there is passed
+the <code>Translator</code> which knows how to interpret those <code>Value</code>s
+and extract an object understandable by the R-tree. Those objects are called
+<code>Indexables</code> and they are simply of type adapted to <code>Point</code>
+or <code>Box</code> concept. Default translator <code>index::translator::def&lt;Value&gt;</code>
+is able to handle <code>Point</code>, <code>Box</code>, <code>std::pair&lt;...&gt;</code>,
+pointer, iterator or smart pointer.
 <itemizedlist>
 <listitem><code>Indexable = Point | Box</code></listitem>
 <listitem><code>BasicValue = Indexable | std::pair&lt;Indexable, T&gt; | std::pair&lt;T, Indexable&gt;</code></listitem>
 <listitem><code>Value = BasicValue | BasicValue* | Iterator&lt;BasicValue&gt; | SmartPtr&lt;BasicValue&gt;</code></listitem>
 </itemizedlist>
-Examples of Value types:
+Examples of <code>Value</code> types:
 <itemizedlist>
 <listitem><code>geometry::model::point&lt;...&gt;</code></listitem>
 <listitem><code>geometry::model::point_xy&lt;...&gt;</code></listitem>
@@ -114,7 +120,7 @@
 <section>
 <title>Inserting and splitting algorithms</title>
 <para>
-Values may be inserted to the R-tree in many various ways. Final structure of nodes depends
+<code>Value</code>s 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
 well-known types of R-trees may be created.
 <itemizedlist>
@@ -168,7 +174,7 @@
 <title>Spatial queries</title>
 <para>
 There are three ways to perform a spatial query. Following queries returns
-Values intersecting some box_region.
+<code>Value</code>s intersecting some box_region.
 <itemizedlist>
 <listitem>
 Method call
@@ -201,7 +207,7 @@
 <section>
 <title>Spatial predicates</title>
 <para>
-It is possible to define other relations between queried Values and region/regions
+It is possible to define other relations between queried <code>Value</code>s and region/regions
 of interest. Names of predicates corresponds to names of Boost.Geometry algorithms.
 <programlisting>
 rt.query(box, std::back_inserter(result)); // default case - intersects
@@ -232,7 +238,7 @@
   , std::back_inserter(result));
 </programlisting>
 There is special predicate <code>index::value(Fun)</code> taking user-defined function/functor
-which checks if Value should be returned by the query.
+which checks if <code>Value</code> should be returned by the query.
 <programlisting>
 bool fun(Value const&amp; v)
 {
@@ -249,8 +255,147 @@
 </section>
 
 <section>
-<title>Nearest neighbor queries</title>
-TODO
+<title>Nearest neighbors queries</title>
+
+<section>
+<title>k nearest neighbors</title>
+<para>
+There are three ways of performing knn queries. Following queries returns
+k <code>Value</code>s closest to some point in space. For <code>Box</code>es
+<code>Indexable</code>s closest point of a <code>Box</code> is taken into
+account by default.
+<itemizedlist>
+<listitem>
+Method call
+<programlisting>
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+rt.nearest(pt, k, std::back_inserter(returned_values));
+</programlisting>
+</listitem>
+<listitem>
+Function call
+<programlisting>
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+index::nearest(rt, pt, k, std::back_inserter(returned_values));
+</programlisting>
+</listitem>
+<listitem>
+Use of <code>operator |</code>
+<programlisting>
+Point pt(...);
+BOOST_FOREACH(Value &amp;v, rt | index::nearest_filtered(pt, k))
+ ;// do something with v
+</programlisting>
+</listitem>
+</itemizedlist>
+</para>
+</section>
+
+<section>
+<title>One nearest neighbor</title>
+<para>
+Another type of nearest neighbor query is searching for the one closest <code>Value</code>.
+If it is found, 1 is returned by the method or function. This kind of query
+has only two forms.
+<itemizedlist>
+<listitem>
+Method call
+<programlisting>
+Value returned_value;
+Point pt(...);
+size_t n = rt.nearest(pt, returned_value);
+</programlisting>
+</listitem>
+<listitem>
+Function call
+<programlisting>
+Value returned_value;
+Point pt(...);
+size_t n = index::nearest(rt, pt, returned_value);
+</programlisting>
+</listitem>
+</itemizedlist>
+</para>
+</section>
+
+<section>
+<title>Distances predicates</title>
+<para>
+It is possible to define if calculated distance between query point and <code>Value</code> should be
+greater, lesser or between some other distances. Those are called <code>DistancesPredicate</code>s and
+may be defined as follows.
+<programlisting>
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+
+/* default - without bounds */
+index::nearest(rt, pt, k, std::back_inserter(returned_values));
+
+/* same as default */
+index::nearest(rt, index::unbounded(pt), k, std::back_inserter(returned_values));
+
+/* distance must be greater than or equal to 10 */
+index::nearest(rt, index::min_bounded(pt, 10), k, std::back_inserter(returned_values));
+
+/* distance must be lesser than or equal to 500 */
+index::nearest(rt, index::max_bounded(pt, 500), k, std::back_inserter(returned_values));
+
+/* distance must be between 10 and 500 */
+index::nearest(rt, index::bounded(pt, 10, 500), k, std::back_inserter(returned_values));
+
+</programlisting>
+</para>
+
+<para>
+Furthermore, it's possible to define if the closest, furthest or centroidal point of the
+non-point <code>Indexable</code> should be taken into account in the routine calculating distance.
+<programlisting>
+std::vector&lt;Value&gt; returned_values;
+Point pt(...);
+
+/* default - distance between Indexable's closest point and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, 10), k, std::back_inserter(returned_values));
+
+/* same as default - distance between Indexable's closest point and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, index::near(10)), k, std::back_inserter(returned_values));
+
+/* distance between Indexable's furthest point and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, index::far(10)), k, std::back_inserter(returned_values));
+
+/* distance between Indexable's centroid and a query point
+must be greater than 10 */
+index::nearest(rt, index::min_bounded(pt, index::centroid(10)), k, std::back_inserter(returned_values));
+</programlisting>
+</para>
+
+</section>
+
+<section>
+<title>Using spatial predicates</title>
+<para>
+It is possible to use spatial predicates described before in knn queries.
+<programlisting>
+Value returned_value;
+std::vector&lt;Value&gt; returned_values;
+
+Point pt(...);
+Box b(...);
+
+size_t n1 = rt.nearest(index::bounded(pt, index::far(1), 10), index::intersects(b), returned_value);
+
+size_t n2 = index::nearest(rt, pt, k, index::within(b), std::back_inserter(returned_values));
+
+BOOST_FOREACH(Value &amp;v, rt | index::nearest_filtered(pt, k, index::covered_by(b)))
+ ;// do something with v
+</programlisting>
+</para>
+</section>
+
 </section>
 
 </section>


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