mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-15 01:02:09 +00:00
docs added
[SVN r75702]
This commit is contained in:
20
doc/Jamfile.v2
Normal file
20
doc/Jamfile.v2
Normal file
@@ -0,0 +1,20 @@
|
||||
# Boost.Geometry.Index (Spatial Indexes Library)
|
||||
#
|
||||
# Copyright (c) 2008 Federico J. Fernandez.
|
||||
# Copyright (c) 2011 Adam Wulkiewicz.
|
||||
|
||||
# Use, modification and distribution is subject to the Boost Software License,
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
project boost/doc ;
|
||||
import boostbook : boostbook ;
|
||||
|
||||
boostbook geometry-index-doc
|
||||
:
|
||||
index.xml
|
||||
:
|
||||
<xsl:param>boost.root=http://www.boost.org/doc/libs/release
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
|
||||
;
|
||||
|
||||
73
doc/html/index.html
Normal file
73
doc/html/index.html
Normal file
@@ -0,0 +1,73 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Chapter 1. Boost.Geometry.Index</title>
|
||||
<link rel="stylesheet" href="http://www.boost.org/doc/libs/release/doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
|
||||
<link rel="home" href="index.html" title="Chapter 1. Boost.Geometry.Index">
|
||||
<link rel="next" href="index/rtree.html" title="R-tree">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="http://www.boost.org/doc/libs/release/boost.png"></td>
|
||||
<td align="center"><a href="http://www.boost.org/doc/libs/release/index.html">Home</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/doc/libs/release/libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/doc/libs/release/more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav"><a accesskey="n" href="index/rtree.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/next.png" alt="Next"></a></div>
|
||||
<div class="chapter">
|
||||
<div class="titlepage"><div>
|
||||
<div><h2 class="title">
|
||||
<a name="index"></a>Chapter 1. Boost.Geometry.Index</h2></div>
|
||||
<div><div class="author"><h3 class="author">
|
||||
<span class="firstname">Federico J.</span> <span class="surname">Fernandez</span>
|
||||
</h3></div></div>
|
||||
<div><div class="author"><h3 class="author">
|
||||
<span class="firstname">Adam</span> <span class="surname">Wulkiewicz</span>
|
||||
</h3></div></div>
|
||||
<div><p class="copyright">Copyright © 2008 Federico J. Fernandez</p></div>
|
||||
<div><p class="copyright">Copyright © 2011 Adam Wulkiewicz</p></div>
|
||||
<div><div class="legalnotice">
|
||||
<a name="id824565"></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 <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</div></div>
|
||||
</div></div>
|
||||
<div class="toc">
|
||||
<p><b>Table of Contents</b></p>
|
||||
<dl>
|
||||
<dt><span class="section"><a href="index.html#index.intro">Introduction</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html">R-tree</a></span></dt>
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824613">R-tree creation</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824657">Values, Indexables and default Translator</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824700">Inserting and splitting algorithms</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824739">Inserting and removing Values</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824765">Spatial queries</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824804">Spatial predicates</a></span></dt>
|
||||
<dt><span class="section"><a href="index/rtree.html#id824839">Nearest neighbor queries</a></span></dt>
|
||||
</dl></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="index.intro"></a>Introduction</h2></div></div></div>
|
||||
<p>The Boost.Geometry.Index library is intetended to gather containers
|
||||
(spatial indexes) used for speeding spatial queries up. In general, indexes
|
||||
stores geometric objects' representations and allows searching for objects
|
||||
occupying some space or close to some point in space.
|
||||
</p>
|
||||
<p>Currently, only one spatial index is implemented - the R-tree.</p>
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav"><a accesskey="n" href="index/rtree.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/next.png" alt="Next"></a></div>
|
||||
</body>
|
||||
</html>
|
||||
280
doc/html/index/rtree.html
Normal file
280
doc/html/index/rtree.html
Normal file
@@ -0,0 +1,280 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>R-tree</title>
|
||||
<link rel="stylesheet" href="http://www.boost.org/doc/libs/release/doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
|
||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Geometry.Index">
|
||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Geometry.Index">
|
||||
<link rel="prev" href="../index.html" title="Chapter 1. Boost.Geometry.Index">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="http://www.boost.org/doc/libs/release/boost.png"></td>
|
||||
<td align="center"><a href="http://www.boost.org/doc/libs/release/index.html">Home</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/doc/libs/release/libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/doc/libs/release/more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../index.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/home.png" alt="Home"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<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"><a href="rtree.html#id824613">R-tree creation</a></span></dt>
|
||||
<dt><span class="section"><a href="rtree.html#id824657">Values, Indexables and default Translator</a></span></dt>
|
||||
<dt><span class="section"><a href="rtree.html#id824700">Inserting and splitting algorithms</a></span></dt>
|
||||
<dt><span class="section"><a href="rtree.html#id824739">Inserting and removing Values</a></span></dt>
|
||||
<dt><span class="section"><a href="rtree.html#id824765">Spatial queries</a></span></dt>
|
||||
<dt><span class="section"><a href="rtree.html#id824804">Spatial predicates</a></span></dt>
|
||||
<dt><span class="section"><a href="rtree.html#id824839">Nearest neighbor queries</a></span></dt>
|
||||
</dl></div>
|
||||
<p>
|
||||
R-tree is a self-balancing search tree with nodes stored with their axis aligned
|
||||
bounding boxes. Each node's box describes 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 the node are user defined.
|
||||
</p>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824613"></a>R-tree creation</h3></div></div></div>
|
||||
<p>
|
||||
R-tree has 4 parameters:
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
rtree<Value, Parameters, Translator, Allocator>
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||
<li class="listitem">
|
||||
Value - type of object which will be stored in the container.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Parameters - compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Translator - type of object translating Value objects to Indexable objects (Point or Box) which R-tree can handle.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Allocator - the allocator.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
In order to create a R-tree object storing values of type std::pair<Box, int> one may use the following code
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
using namespace boost::geometry;
|
||||
typedef std::pair<Box, int> Value;
|
||||
index::rtree< Value, index::quadratic<32, 8> > rt;
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824657"></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
|
||||
index::translator::def<Value> is able to handle Points, Boxes, std::pairs, pointers and iterators.
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||
<li class="listitem">Indexable = Point | Box</li>
|
||||
<li class="listitem">BasicValue = Indexable | std::pair<Indexable, T> | std::pair<T, Indexable></li>
|
||||
<li class="listitem">Value = BasicValue | BasicValue* | Iterator<BasicValue></li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Examples of Value types:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||
<li class="listitem">geometry::model::point<...></li>
|
||||
<li class="listitem">geometry::model::point_xy<...></li>
|
||||
<li class="listitem">geometry::model::box<...></li>
|
||||
<li class="listitem">std::pair≤geometry::model::box<...>, size_t></li>
|
||||
</ul></div>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824700"></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
|
||||
on algorithms used in the process, especially nodes' splitting algorithm. Currently, three
|
||||
well-known types of R-trees may be created.
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||
<li class="listitem">
|
||||
Linear - classic R-tree using splitting algorithm of linear complexity
|
||||
<pre class="programlisting">
|
||||
index::rtree< Value, index::linear<32, 8> > rt;
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Quadratic - classic R-tree using splitting algorithm of quadratic complexity
|
||||
<pre class="programlisting">
|
||||
index::rtree< Value, index::quadratic<32, 8> > rt;
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
R*-tree - splitting algorithm minimizing nodes' overlap with forced reinsertions
|
||||
<pre class="programlisting">
|
||||
index::rtree< Value, index::rstar<32, 8> > rt;
|
||||
</pre>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824739"></a>Inserting and removing Values</h3></div></div></div>
|
||||
<p>
|
||||
Create
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
using namespace boost::geometry;
|
||||
typedef std::pair<Box, int> Value;
|
||||
index::rtree< Value, index::quadratic<32, 8> > rt;
|
||||
</pre>
|
||||
<p>
|
||||
Insert and remove by method call
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
rt.insert(std::make_pair(Box(...), 0));
|
||||
rt.remove(std::make_pair(Box(...), 0));
|
||||
</pre>
|
||||
<p>
|
||||
or by function call
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
index::insert(rt, std::make_pair(Box(...), 0));
|
||||
index::remove(rt, std::make_pair(Box(...), 0));
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824765"></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.
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||
<li class="listitem">
|
||||
Method call
|
||||
<pre class="programlisting">
|
||||
std::vector<Value> returned_values;
|
||||
Box box_region(...);
|
||||
rt.query(box_region, std::back_inserter(returned_values));
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Function call
|
||||
<pre class="programlisting">
|
||||
std::vector<Value> returned_values;
|
||||
Box box_region(...);
|
||||
index::query(rt, box_region, std::back_inserter(returned_values));
|
||||
</pre>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Use of operator | (as with ranges)
|
||||
<pre class="programlisting">
|
||||
Box box_region(...);
|
||||
BOOST_FOREACH(Value &v, rt | index::query_filtered(box_region))
|
||||
;// do something with v
|
||||
</pre>
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824804"></a>Spatial predicates</h3></div></div></div>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
rt.query(box, std::back_inserter(result)); // default case - intersects
|
||||
rt.query(index::intersects(box), std::back_inserter(result)); // same as default
|
||||
rt.query(index::covered_by(box), std::back_inserter(result));
|
||||
rt.query(index::disjont(box), std::back_inserter(result));
|
||||
rt.query(index::overlaps(box), std::back_inserter(result));
|
||||
rt.query(index::within(box), std::back_inserter(result));
|
||||
</pre>
|
||||
<p>
|
||||
All predicates may be negated, e.g.:
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
rt.query(index::not_intersects(box), std::back_inserter(result));
|
||||
// or
|
||||
rt.query(!index::intersects(box), std::back_inserter(result));
|
||||
// the same as
|
||||
rt.query(index::disjoint(box), std::back_inserter(result));
|
||||
</pre>
|
||||
<p>
|
||||
It's possible to use some number of predicates by passing std::pair<P1, P2>
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
rt.query(
|
||||
std::make_pair(index::intersects(box1), !index::within(box2))
|
||||
, std::back_inserter(result));
|
||||
</pre>
|
||||
<p>
|
||||
or boost::tuple<P1, P2, P3, ...>
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
rt.query(
|
||||
boost::make_tuple(index::intersects(box1), !index::within(box2), index::overlaps(box3))
|
||||
, std::back_inserter(result));
|
||||
</pre>
|
||||
<p>
|
||||
There is special predicate index::value taking user-defined function/functor
|
||||
which checks if Value should be returned by the query.
|
||||
</p>
|
||||
<pre class="programlisting">
|
||||
bool fun(Value const& v)
|
||||
{
|
||||
return v.is_red();
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
rt.query(
|
||||
boost::make_pair(index::intersects(box), index::value(fun))
|
||||
, std::back_inserter(result));
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id824839"></a>Nearest neighbor queries</h3></div></div></div>
|
||||
TODO
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2008 Federico J. Fernandez<br>Copyright © 2011 Adam Wulkiewicz<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 <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../index.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="http://www.boost.org/doc/libs/release/doc/src/images/home.png" alt="Home"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
255
doc/index.xml
Normal file
255
doc/index.xml
Normal file
@@ -0,0 +1,255 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
||||
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
|
||||
<library name="Geometry.Index" dirname="index" id="index"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<libraryinfo>
|
||||
<author>
|
||||
<firstname>Federico J.</firstname>
|
||||
<surname>Fernandez</surname>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Adam</firstname>
|
||||
<surname>Wulkiewicz</surname>
|
||||
</author>
|
||||
|
||||
<copyright>
|
||||
<year>2008</year>
|
||||
<holder>Federico J. Fernandez</holder>
|
||||
</copyright>
|
||||
<copyright>
|
||||
<year>2011</year>
|
||||
<holder>Adam Wulkiewicz</holder>
|
||||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>Use, modification and distribution is subject to the Boost
|
||||
Software License, Version 1.0. (See accompanying file
|
||||
<filename>LICENSE_1_0.txt</filename> or copy at <ulink
|
||||
url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)</para>
|
||||
</legalnotice>
|
||||
|
||||
<librarypurpose>Spatial indexes for faster spatial and knn queries.</librarypurpose>
|
||||
<librarycategory name="category:data-structures"/>
|
||||
</libraryinfo>
|
||||
|
||||
<title>Boost.Geometry.Index</title>
|
||||
|
||||
<section id="index.intro">
|
||||
<title>Introduction</title>
|
||||
<para>The Boost.Geometry.Index library is intetended to gather containers
|
||||
(spatial indexes) used for speeding spatial queries up. In general, indexes
|
||||
stores geometric objects' representations and allows searching for objects
|
||||
occupying some space or close to some point in space.
|
||||
</para>
|
||||
|
||||
<para>Currently, only one spatial index is implemented - the R-tree.</para>
|
||||
</section>
|
||||
|
||||
<section id="index.rtree">
|
||||
<title>R-tree</title>
|
||||
<para>
|
||||
R-tree is a self-balancing search tree with nodes stored with their axis aligned
|
||||
bounding boxes. Each node's box describes 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 the node are user defined.
|
||||
</para>
|
||||
|
||||
<section>
|
||||
<title>R-tree creation</title>
|
||||
<para>
|
||||
R-tree has 4 parameters:
|
||||
<programlisting>
|
||||
rtree<Value, Parameters, Translator, Allocator>
|
||||
</programlisting>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
Value - type of object which will be stored in the container.
|
||||
</listitem>
|
||||
<listitem>
|
||||
Parameters - compile-time parameters, e.g. inserting/splitting algorithm with min and max nodes' elements numbers.
|
||||
</listitem>
|
||||
<listitem>
|
||||
Translator - type of object translating Value objects to Indexable objects (Point or Box) which R-tree can handle.
|
||||
</listitem>
|
||||
<listitem>
|
||||
Allocator - the allocator.
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
In order to create a R-tree object storing values of type std::pair<Box, int> one may use the following code
|
||||
<programlisting>
|
||||
using namespace boost::geometry;
|
||||
typedef std::pair<Box, int> Value;
|
||||
index::rtree< Value, index::quadratic<32, 8> > rt;
|
||||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<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
|
||||
index::translator::def<Value> is able to handle Points, Boxes, std::pairs, pointers and iterators.
|
||||
<itemizedlist>
|
||||
<listitem>Indexable = Point | Box</listitem>
|
||||
<listitem>BasicValue = Indexable | std::pair<Indexable, T> | std::pair<T, Indexable></listitem>
|
||||
<listitem>Value = BasicValue | BasicValue* | Iterator<BasicValue></listitem>
|
||||
</itemizedlist>
|
||||
Examples of Value types:
|
||||
<itemizedlist>
|
||||
<listitem>geometry::model::point<...></listitem>
|
||||
<listitem>geometry::model::point_xy<...></listitem>
|
||||
<listitem>geometry::model::box<...></listitem>
|
||||
<listitem>std::pair≤geometry::model::box<...>, size_t></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<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
|
||||
on algorithms used in the process, especially nodes' splitting algorithm. Currently, three
|
||||
well-known types of R-trees may be created.
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
Linear - classic R-tree using splitting algorithm of linear complexity
|
||||
<programlisting>
|
||||
index::rtree< Value, index::linear<32, 8> > rt;
|
||||
</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
Quadratic - classic R-tree using splitting algorithm of quadratic complexity
|
||||
<programlisting>
|
||||
index::rtree< Value, index::quadratic<32, 8> > rt;
|
||||
</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
R*-tree - splitting algorithm minimizing nodes' overlap with forced reinsertions
|
||||
<programlisting>
|
||||
index::rtree< Value, index::rstar<32, 8> > rt;
|
||||
</programlisting>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Inserting and removing Values</title>
|
||||
<para>
|
||||
Create
|
||||
<programlisting>
|
||||
using namespace boost::geometry;
|
||||
typedef std::pair<Box, int> Value;
|
||||
index::rtree< Value, index::quadratic<32, 8> > rt;
|
||||
</programlisting>
|
||||
Insert and remove by method call
|
||||
<programlisting>
|
||||
rt.insert(std::make_pair(Box(...), 0));
|
||||
rt.remove(std::make_pair(Box(...), 0));
|
||||
</programlisting>
|
||||
or by function call
|
||||
<programlisting>
|
||||
index::insert(rt, std::make_pair(Box(...), 0));
|
||||
index::remove(rt, std::make_pair(Box(...), 0));
|
||||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Spatial queries</title>
|
||||
<para>
|
||||
There are three ways to perform a spatial query. Following queries returns
|
||||
Values intersecting some box_region.
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
Method call
|
||||
<programlisting>
|
||||
std::vector<Value> returned_values;
|
||||
Box box_region(...);
|
||||
rt.query(box_region, std::back_inserter(returned_values));
|
||||
</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
Function call
|
||||
<programlisting>
|
||||
std::vector<Value> returned_values;
|
||||
Box box_region(...);
|
||||
index::query(rt, box_region, std::back_inserter(returned_values));
|
||||
</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
Use of operator | (as with ranges)
|
||||
<programlisting>
|
||||
Box box_region(...);
|
||||
BOOST_FOREACH(Value &v, rt | index::query_filtered(box_region))
|
||||
;// do something with v
|
||||
</programlisting>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Spatial predicates</title>
|
||||
<para>
|
||||
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.
|
||||
<programlisting>
|
||||
rt.query(box, std::back_inserter(result)); // default case - intersects
|
||||
rt.query(index::intersects(box), std::back_inserter(result)); // same as default
|
||||
rt.query(index::covered_by(box), std::back_inserter(result));
|
||||
rt.query(index::disjont(box), std::back_inserter(result));
|
||||
rt.query(index::overlaps(box), std::back_inserter(result));
|
||||
rt.query(index::within(box), std::back_inserter(result));
|
||||
</programlisting>
|
||||
All predicates may be negated, e.g.:
|
||||
<programlisting>
|
||||
rt.query(index::not_intersects(box), std::back_inserter(result));
|
||||
// or
|
||||
rt.query(!index::intersects(box), std::back_inserter(result));
|
||||
// the same as
|
||||
rt.query(index::disjoint(box), std::back_inserter(result));
|
||||
</programlisting>
|
||||
It's possible to use some number of predicates by passing std::pair<P1, P2>
|
||||
<programlisting>
|
||||
rt.query(
|
||||
std::make_pair(index::intersects(box1), !index::within(box2))
|
||||
, std::back_inserter(result));
|
||||
</programlisting>
|
||||
or boost::tuple<P1, P2, P3, ...>
|
||||
<programlisting>
|
||||
rt.query(
|
||||
boost::make_tuple(index::intersects(box1), !index::within(box2), index::overlaps(box3))
|
||||
, std::back_inserter(result));
|
||||
</programlisting>
|
||||
There is special predicate index::value taking user-defined function/functor
|
||||
which checks if Value should be returned by the query.
|
||||
<programlisting>
|
||||
bool fun(Value const& v)
|
||||
{
|
||||
return v.is_red();
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
rt.query(
|
||||
boost::make_pair(index::intersects(box), index::value(fun))
|
||||
, std::back_inserter(result));
|
||||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Nearest neighbor queries</title>
|
||||
TODO
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
</library>
|
||||
Reference in New Issue
Block a user