diff --git a/doc/index/Doxyfile b/doc/index/Doxyfile
new file mode 100644
index 000000000..597de34d0
--- /dev/null
+++ b/doc/index/Doxyfile
@@ -0,0 +1,332 @@
+# Doxyfile 1.8.1.2
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+DOXYFILE_ENCODING = UTF-8
+PROJECT_NAME = "Boost.Geometry.Index"
+PROJECT_NUMBER =
+PROJECT_BRIEF =
+PROJECT_LOGO =
+OUTPUT_DIRECTORY =
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = YES
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = NO
+QT_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = NO
+TAB_SIZE = 8
+ALIASES =
+TCL_SUBST =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+OPTIMIZE_FOR_FORTRAN = NO
+OPTIMIZE_OUTPUT_VHDL = NO
+EXTENSION_MAPPING =
+MARKDOWN_SUPPORT = YES
+BUILTIN_STL_SUPPORT = YES
+CPP_CLI_SUPPORT = NO
+SIP_SUPPORT = NO
+IDL_PROPERTY_SUPPORT = YES
+DISTRIBUTE_GROUP_DOC = NO
+SUBGROUPING = YES
+INLINE_GROUPED_CLASSES = NO
+INLINE_SIMPLE_STRUCTS = NO
+TYPEDEF_HIDES_STRUCT = NO
+SYMBOL_CACHE_SIZE = 0
+LOOKUP_CACHE_SIZE = 0
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_PACKAGE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = NO
+EXTRACT_ANON_NSPACES = NO
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+FORCE_LOCAL_INCLUDES = NO
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_MEMBERS_CTORS_1ST = NO
+SORT_GROUP_NAMES = NO
+SORT_BY_SCOPE_NAME = NO
+STRICT_PROTO_MATCHING = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_FILES = YES
+SHOW_NAMESPACES = YES
+FILE_VERSION_FILTER =
+LAYOUT_FILE =
+CITE_BIB_FILES =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = YES
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = ../../../../boost/geometry/index/ \
+ ../../../../boost/geometry/index/adaptors
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.markdown \
+ *.md \
+ *.mm \
+ *.dox \
+ *.py \
+ *.f90 \
+ *.f \
+ *.for \
+ *.vhd \
+ *.vhdl
+RECURSIVE = NO
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXCLUDE_SYMBOLS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+FILTER_SOURCE_PATTERNS =
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION = NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html_by_doxygen
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_EXTRA_FILES =
+HTML_COLORSTYLE_HUE = 220
+HTML_COLORSTYLE_SAT = 100
+HTML_COLORSTYLE_GAMMA = 80
+HTML_TIMESTAMP = YES
+HTML_DYNAMIC_SECTIONS = NO
+HTML_INDEX_NUM_ENTRIES = 100
+GENERATE_DOCSET = NO
+DOCSET_FEEDNAME = "Doxygen generated docs"
+DOCSET_BUNDLE_ID = org.doxygen.Project
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+DOCSET_PUBLISHER_NAME = Publisher
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+CHM_INDEX_ENCODING =
+BINARY_TOC = NO
+TOC_EXPAND = NO
+GENERATE_QHP = NO
+QCH_FILE =
+QHP_NAMESPACE = org.doxygen.Project
+QHP_VIRTUAL_FOLDER = doc
+QHP_CUST_FILTER_NAME =
+QHP_CUST_FILTER_ATTRS =
+QHP_SECT_FILTER_ATTRS =
+QHG_LOCATION =
+GENERATE_ECLIPSEHELP = NO
+ECLIPSE_DOC_ID = org.doxygen.Project
+DISABLE_INDEX = NO
+GENERATE_TREEVIEW = NO
+ENUM_VALUES_PER_LINE = 4
+TREEVIEW_WIDTH = 250
+EXT_LINKS_IN_WINDOW = NO
+FORMULA_FONTSIZE = 10
+FORMULA_TRANSPARENT = YES
+USE_MATHJAX = NO
+MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+MATHJAX_EXTENSIONS =
+SEARCHENGINE = YES
+SERVER_BASED_SEARCH = NO
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4
+EXTRA_PACKAGES =
+LATEX_HEADER =
+LATEX_FOOTER =
+PDF_HYPERLINKS = YES
+USE_PDFLATEX = YES
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+LATEX_SOURCE_CODE = NO
+LATEX_BIB_STYLE = plain
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = YES
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = NO
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = YES
+EXPAND_ONLY_PREDEF = YES
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED = "BOOST_RV_REF(T)=T &&" \
+ "BOOST_COPY_ASSIGN_REF(T)=T const &"
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+MSCGEN_PATH =
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+DOT_NUM_THREADS = 0
+DOT_FONTNAME = Helvetica
+DOT_FONTSIZE = 10
+DOT_FONTPATH =
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = NO
+UML_LIMIT_NUM_FIELDS = 10
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+CALLER_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+INTERACTIVE_SVG = NO
+DOT_PATH =
+DOTFILE_DIRS =
+MSCFILE_DIRS =
+DOT_GRAPH_MAX_NODES = 50
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
diff --git a/doc/index/Jamfile.v2 b/doc/index/Jamfile.v2
new file mode 100644
index 000000000..e6f507006
--- /dev/null
+++ b/doc/index/Jamfile.v2
@@ -0,0 +1,32 @@
+# Boost.Geometry Index
+#
+# Copyright (c) 2011-2012 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 geometry_index/doc ;
+
+import boostbook ;
+import quickbook ;
+
+boostbook geometry_index-doc
+ :
+ index.qbk
+ :
+ Jamfile.v2
+ generated/rtree.qbk
+
+ html
+ pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
+ chunk.section.depth=2
+ chunk.first.sections=1
+ toc.section.depth=3
+ toc.max.depth=2
+ generate.section.toc.level=2
+ boost.root=http://www.boost.org/doc/libs/release
+
+ enable_index
+ $(here)
+ ;
diff --git a/doc/index/imports.qbk b/doc/index/imports.qbk
new file mode 100644
index 000000000..5d81a7639
--- /dev/null
+++ b/doc/index/imports.qbk
@@ -0,0 +1,17 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[import src/examples/rtree/quick_start.cpp]
+[import src/examples/rtree/polygons_vector.cpp]
+[import src/examples/rtree/polygons_shared_ptr.cpp]
+[import src/examples/rtree/variants_map.cpp]
+[import src/examples/rtree/value_shared_ptr.cpp]
+[import src/examples/rtree/value_index.cpp]
+[import src/examples/rtree/interprocess.cpp]
diff --git a/doc/index/index.qbk b/doc/index/index.qbk
new file mode 100644
index 000000000..5766162af
--- /dev/null
+++ b/doc/index/index.qbk
@@ -0,0 +1,38 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[/library Geometry Index
+ [quickbook 1.5]
+ [authors [Wulkiewicz, Adam]]
+ [copyright 2011-2013 Adam Wulkiewicz]
+ [purpose Documentation of Boost.Geometry Index library]
+ [license
+ Distributed under 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])
+ ]
+ [id geometry]
+ [category geometry]
+/]
+
+[def __boost_geometry_index__ Boost.Geometry.Index]
+
+[def __rtree__ R-tree]
+
+[def __value__ Value]
+[def __parameters__ Parameters]
+[def __allocator__ Allocator]
+[def __indexable__ Indexable]
+
+[include imports.qbk]
+
+[/include introduction.qbk/]
+
+[include rtree.qbk]
diff --git a/doc/index/introduction.qbk b/doc/index/introduction.qbk
new file mode 100644
index 000000000..0c7e0b7a8
--- /dev/null
+++ b/doc/index/introduction.qbk
@@ -0,0 +1,19 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[section Introduction]
+
+The __boost_geometry_index__ is intetended to gather containers (spatial indexes) which may be used to accelerate spatial searching.
+It is a part of the __boost_geometry__ library. In general, spatial indexes stores geometric objects' representations and
+allows searching for objects occupying some space or close to some point in space.
+
+Currently, only one spatial index is implemented - __rtree__.
+
+[endsect]
diff --git a/doc/index/make_qbk.py b/doc/index/make_qbk.py
new file mode 100755
index 000000000..9185f3f10
--- /dev/null
+++ b/doc/index/make_qbk.py
@@ -0,0 +1,39 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+# ===========================================================================
+# Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
+# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+#
+# 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)9
+# ============================================================================
+
+import os, sys
+
+cmd = "doxygen_xml2qbk"
+cmd = cmd + " --xml xml/%s.xml"
+cmd = cmd + " --start_include boost/"
+cmd = cmd + " --output_style alt"
+cmd = cmd + " > generated/%s.qbk"
+
+os.system("doxygen Doxyfile")
+os.system(cmd % ("classboost_1_1geometry_1_1index_1_1rtree", "rtree"))
+os.system(cmd % ("group__rtree__functions", "rtree_functions"))
+
+os.system(cmd % ("structboost_1_1geometry_1_1index_1_1linear", "rtree_linear"))
+os.system(cmd % ("structboost_1_1geometry_1_1index_1_1quadratic", "rtree_quadratic"))
+os.system(cmd % ("structboost_1_1geometry_1_1index_1_1rstar", "rtree_rstar"))
+os.system(cmd % ("classboost_1_1geometry_1_1index_1_1dynamic__linear", "rtree_dynamic_linear"))
+os.system(cmd % ("classboost_1_1geometry_1_1index_1_1dynamic__quadratic", "rtree_dynamic_quadratic"))
+os.system(cmd % ("classboost_1_1geometry_1_1index_1_1dynamic__rstar", "rtree_dynamic_rstar"))
+
+os.system(cmd % ("structboost_1_1geometry_1_1index_1_1indexable", "indexable"))
+os.system(cmd % ("structboost_1_1geometry_1_1index_1_1equal__to", "equal_to"))
+
+os.system(cmd % ("group__predicates", "predicates"))
+#os.system(cmd % ("group__nearest__relations", "nearest_relations"))
+os.system(cmd % ("group__adaptors", "adaptors"))
+os.system(cmd % ("group__inserters", "inserters"))
+
+#os.system("b2")
diff --git a/doc/index/rtree.qbk b/doc/index/rtree.qbk
new file mode 100644
index 000000000..46063c8f5
--- /dev/null
+++ b/doc/index/rtree.qbk
@@ -0,0 +1,21 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[section R-tree]
+
+[include rtree/introduction.qbk]
+[include rtree/quickstart.qbk]
+[include rtree/creation.qbk]
+[include rtree/query.qbk]
+[include rtree/examples.qbk]
+[include rtree/experimental.qbk]
+[/include rtree/reference.qbk]
+
+[endsect]
diff --git a/doc/index/rtree/creation.qbk b/doc/index/rtree/creation.qbk
new file mode 100644
index 000000000..04aa9734b
--- /dev/null
+++ b/doc/index/rtree/creation.qbk
@@ -0,0 +1,231 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[section Creation and modification]
+
+[section Template parameters]
+
+__rtree__ has 5 parameters:
+
+ rtree,
+ EqualTo = index::equal_to,
+ Allocator = std::allocator >
+
+* `__value__` - type of object which will be stored in the container,
+* `Parameters` - parameters type, inserting/splitting algorithm,
+* `IndexableGetter` - function object translating `__value__` to `__indexable__` (`__point__` or `__box__`) which __rtree__ can handle,
+* `EqualTo` - function object comparing `__value__`s,
+* `Allocator` - `Value`s allocator, all allocators needed by the container are created from it.
+
+[endsect]
+
+[section Values and Indexables]
+
+__rtree__ may store `__value__`s of any type as long as passed function objects know how to interpret those `__value__`s, that is
+extract an `__indexable__` that the __rtree__ can handle and compare `__value__`s.
+
+By default function objects `index::indexable` and `index::equal_to` are defined for some typically used `__value__`
+types which may be stored without defining any additional classes. By default the rtree may store pure `__indexable__`s, pairs
+and tuples. In the case of those two collection types, the `__indexable__` must be the first stored type.
+
+* `__indexable__ = __point__ | __box__`
+* `__value__ = Indexable | std::pair<__indexable__, T> | tuple<__indexable__, ...>`
+
+By default `boost::tuple<...>` is supported on all compilers. If the compiler supports C++11 tuples and variadic templates
+then `std::tuple<...>` may be used "out of the box" as well.
+
+Examples of default `__value__` types:
+
+ geometry::model::point<...>
+ geometry::model::point_xy<...>
+ geometry::model::box<...>
+ std::pair, unsigned>
+ boost::tuple, int, float>
+
+The predefined `index::indexable` returns const reference to the `__indexable__` stored in the `__value__`.
+
+[important The translation is done quite frequently inside the continer - each time the rtree needs it. ]
+
+The predefined `index::equal_to`:
+
+* for `__point__` and `__box__` - compares `__value__`s with geometry::equals().
+* for `std::pair<...>` - compares both components of the `__value__`. The first value stored in the pair is compared before the second one.
+ If the value stored in the pair is a Geometry, `geometry::equals()` is used. For other types it uses `operator==()`.
+* for `tuple<...>` - compares all components of the `__value__`. If the component is a `Geometry`, `geometry::equals()`
+ function is used. For other types it uses `operator==()`.
+
+[endsect]
+
+[section Balancing algorithms]
+
+[heading Compile-time]
+
+`__value__`s may be inserted to the __rtree__ in many various ways. Final internal structure
+of the __rtree__ depends on algorithms used in the insertion process and parameters. The most important is
+nodes' balancing algorithm. Currently, three well-known types of R-trees may be created.
+
+Linear - classic __rtree__ using balancing algorithm of linear complexity
+
+ index::rtree< __value__, index::linear<16> > rt;
+
+Quadratic - classic __rtree__ using balancing algorithm of quadratic complexity
+
+ index::rtree< __value__, index::quadratic<16> > rt;
+
+R*-tree - balancing algorithm minimizing nodes' overlap with forced reinsertions
+
+ index::rtree< __value__, index::rstar<16> > rt;
+
+[heading Run-time]
+
+Balancing algorithm parameters may be passed to the __rtree__ in run-time.
+To use run-time versions of the __rtree__ one may pass parameters which
+names start with `dynamic_`.
+
+ // linear
+ index::rtree<__value__, index::dynamic_linear> rt(index::dynamic_linear(16));
+
+ // quadratic
+ index::rtree<__value__, index::dynamic_quadratic> rt(index::dynamic_quadratic(16));
+
+ // rstar
+ index::rtree<__value__, index::dynamic_rstar> rt(index::dynamic_rstar(16));
+
+The obvious drawback is a slightly slower __rtree__.
+
+[heading Non-default parameters]
+
+Non-default R-tree parameters are described in the reference.
+
+[endsect]
+
+[section Copying, moving and swapping]
+
+The __rtree__ is copyable and movable container. Move semantics is implemented using Boost.Move library
+so it's possible to move the container on a compilers without rvalue references support.
+
+ // default constructor
+ index::rtree< __value__, index::rstar<8> > rt1;
+
+ // copy constructor
+ index::rtree< __value__, index::rstar<8> > rt2(r1);
+
+ // copy assignment
+ rt2 = r1;
+
+ // move constructor
+ index::rtree< __value__, index::rstar<8> > rt3(boost::move(rt1));
+
+ // move assignment
+ rt3 = boost::move(rt2);
+
+ // swap
+ rt3.swap(rt2);
+
+[endsect]
+
+[section Inserting and removing Values]
+
+The following code creates an __rtree__ using quadratic balancing algorithm.
+
+ using namespace boost::geometry;
+ typedef std::pair __value__;
+ index::rtree< __value__, index::quadratic<16> > rt;
+
+To insert or remove a `__value__' by method call one may use the following
+code.
+
+ __value__ v = std::make_pair(__box__(...), 0);
+
+ rt.insert(v);
+
+ rt.remove(v);
+
+To insert or remove a `__value__' by function call one may use the following
+code.
+
+ __value__ v = std::make_pair(__box__(...), 0);
+
+ index::insert(rt, v);
+
+ index::remove(rt, v);
+
+Typically you will perform those operations in a loop in order to e.g. insert
+some number of `__value__`s corresponding to geometrical objects (e.g. `Polygons`)
+stored in another container.
+
+[heading Additional interface]
+
+The __rtree__ allows creation, inserting and removing of Values from a range. The range may be passed as
+[first, last) Iterators pair or as a Range.
+
+ namespace bgi = boost::geometry::index;
+ typedef std::pair __value__;
+ typedef bgi::rtree< __value__, bgi::linear<32> > RTree;
+
+ std::vector<__value__> values;
+ /* vector filling code, here */
+
+ // create R-tree with default constructor and insert values with insert(Value const&)
+ RTree rt1;
+ BOOST_FOREACH(__value__ const& v, values)
+ rt1.insert(v);
+
+ // create R-tree with default constructor and insert values with insert(Iter, Iter)
+ RTree rt2;
+ rt2.insert(values.begin(), values.end());
+
+ // create R-tree with default constructor and insert values with insert(Range)
+ RTree rt3;
+ rt3.insert(values);
+
+ // create R-tree with constructor taking Iterators
+ RTree rt4(values.begin(), values.end());
+
+ // create R-tree with constructor taking Range
+ RTree rt5(values);
+
+ // remove values with remove(Value const&)
+ BOOST_FOREACH(__value__ const& v, values)
+ rt1.remove(v);
+
+ // remove values with remove(Iter, Iter)
+ rt2.remove(values.begin(), values.end());
+
+ // remove values with remove(Range)
+ rt3.remove(values);
+
+[heading Insert iterator]
+
+There are functions like `std::copy()`, or __rtree__'s queries that copy values to an output iterator.
+In order to insert values to a container in this kind of function insert iterators may be used.
+Geometry.Index provide its own `bgi::insert_iterator` which is generated by
+`bgi::inserter()` function.
+
+ namespace bgi = boost::geometry::index;
+ typedef std::pair __value__;
+ typedef bgi::rtree< __value__, bgi::linear<32> > RTree;
+
+ std::vector<__value__> values;
+ /* vector filling code, here */
+
+ // create R-tree and insert values from the vector
+ RTree rt1;
+ std::copy(values.begin(), values.end(), bgi::inserter(rt1));
+
+ // create R-tree and insert values returned by a query
+ RTree rt2;
+ rt1.spatial_query(Box(/*...*/), bgi::inserter(rt2));
+
+[endsect]
+
+[endsect] [/ Creation and modification /]
diff --git a/doc/index/rtree/examples.qbk b/doc/index/rtree/examples.qbk
new file mode 100644
index 000000000..8b57bde7e
--- /dev/null
+++ b/doc/index/rtree/examples.qbk
@@ -0,0 +1,41 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2013 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)
+=============================================================================/]
+
+[section:rtree_examples Examples]
+
+[section Quick start]
+[rtree_quickstart]
+[endsect]
+
+[section Index of polygons stored in vector]
+[rtree_polygons_vector]
+[endsect]
+
+[section Index of shared pointers to polygons]
+[rtree_polygons_shared_ptr]
+[endsect]
+
+[section Index of iterators of a map storing variant geometries]
+[rtree_variants_map]
+[endsect]
+
+[section Specializing index::indexable function object - storing shared pointers in the rtree]
+[rtree_value_shared_ptr]
+[endsect]
+
+[section Using IndexableGetter function object - storing indexes of external container's elements]
+[rtree_value_index]
+[endsect]
+
+[section Index stored in shared memory using Boost.Interprocess]
+[rtree_interprocess]
+[endsect]
+
+[endsect]
diff --git a/doc/index/rtree/exception_safety.qbk b/doc/index/rtree/exception_safety.qbk
new file mode 100644
index 000000000..8f1dbb6af
--- /dev/null
+++ b/doc/index/rtree/exception_safety.qbk
@@ -0,0 +1,57 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[section Exception safety]
+
+In order to be exception-safe the __rtree__ requires:
+
+* exception-safe copy constructor and copy assignment of the `__value__`.
+* exception-safe copy constructor and copy assignment of the `CoordinateType` used in the `Indexable`.
+* nonthrowing copy constructor of the `Translator`.
+* nonthrowing destructors of above types.
+
+[table
+[[Operation] [exception-safety]]
+[[`rtree()`] [ /nothrow/ ]]
+[[`rtree(Iterator, Iterator)`] [ *strong* ]]
+[[`~rtree()`] [ /nothrow/ ]]
+[[][]]
+[[`rtree(rtree const&)`] [ *strong* ]]
+[[`operator=(rtree const&)`] [ *strong* ]]
+[[][]]
+[[`rtree(rtree &&)`] [ /nothrow/ ]]
+[[`operator=(rtree &&)`] [ /nothrow/ or *strong*
+[footnote /nothrow/ - if allocators are equal, *strong* - otherwise]]]
+[[`swap(rtree &)`] [ /nothrow/ ]]
+[[][]]
+[[`insert(__value__)`] [ not safe
+[footnote If this operation throws, the R-tree may be left in an inconsistent state, elements must not be inserted or removed, methods may return invalid data.]]]
+[[`insert(Iterator, Iterator)`][ not safe ]]
+[[`insert(Range)`] [ not safe ]]
+[[`remove(__value__)`] [ not safe ]]
+[[`remove(Iterator, Iterator)`][ not safe ]]
+[[`remove(Range)`] [ not safe ]]
+[[`clear()`] [ /nothrow/ ]]
+[[][]]
+[[`spatial_query(...)`] [ *strong* ]]
+[[`nearest_query(...)`] [ *strong* ]]
+[[`count(ValueOrIndexable)`] [ /nothrow/ ]]
+[[][]]
+[[`size()`] [ /nothrow/ ]]
+[[`empty()`] [ /nothrow/ ]]
+[[`box()`] [ /nothrow/ or *strong*
+[footnote /nothrow/ - if `CoordinateType` has nonthrowing copy constructor, *strong* - otherwise]]]
+[[][]]
+[[`get_allocator()`] [ /nothrow/ ]]
+[[`parameters()`] [ /nothrow/ ]]
+[[`translator()`] [ /nothrow/ ]]
+]
+
+[endsect] [/Exception safety/]
diff --git a/doc/index/rtree/experimental.qbk b/doc/index/rtree/experimental.qbk
new file mode 100644
index 000000000..71aae4f28
--- /dev/null
+++ b/doc/index/rtree/experimental.qbk
@@ -0,0 +1,110 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2013 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)
+=============================================================================/]
+
+[section Experimental features]
+
+This section describes experimental features which are implemented but unavailable by default.
+Be aware that they may not be released in the future or functionalities may be released but
+behind different interface.
+
+To enable them one must define `BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL` in compiler's command line or before
+including spatial index.
+
+[heading Nearest query distance calculation]
+
+It is possible to define how distance to the non-point `__value__` should be calculated. To do this one may pass
+a relation object instead of a Point to the nearest predicate, as follows:
+
+ /* caluclate distance to the Indexables' nearest points */
+ rtree.query(index::nearest(index::to_nearest(pt), k), std::back_inserter(returned_values)); // same as default
+
+ /* caluclate distance to the Indexables' centroid */
+ rtree.query(index::nearest(index::to_centroid(pt), k), std::back_inserter(returned_values));
+
+ /* caluclate distance to the Indexables' furthest points */
+ rtree.query(index::nearest(index::to_furthest(pt), k), std::back_inserter(returned_values));
+
+[heading Path query]
+
+Path query returns `k` first `__value__`s intersecting a path defined by a `Linestring`. The result of a query returning first 5
+values intersecting a path is presented below. Path's flow is denoted by blue arrows, returned values are orange.
+
+[$img/index/rtree/path.png]
+
+To perform this query one may pass a `path()` predicate taking a `Linestring` and maximum number of `__value__`s which
+should be returned:
+
+ rtree.query(index::path(linestring, k), std::back_inserter(returned_values));
+
+[warning Only one distance predicate may be used in a query. This means that there can be only one `nearest()` or `path()` predicate passed. Passing more of them will result in compile-time error.]
+
+[heading Incremental queries]
+
+Sometimes there is a need to stop querying at some desired moment because for example the decision that query should find another value
+is made after analysis of previously returned values. There can also be desirable to pause querying and resume it later.
+
+Currently, those kind of incremental queries are implemented as input (single pass) const iterators, relatively
+big fat-iterators storing stack used in the tree-traversing process. Because the type of predicates passed
+to the query varies, the type of the iterator varies as well.
+
+Therefore to use query iterators one must pass them to some function template, then types will be deduced
+automatically. If iterators objects must be stored one may use Boost.Typeof library to retrieve a type from
+an expression or use C++11 `auto` or `decltype`.
+
+ /* function call */
+ std::copy(rtree.qbegin(index::intersects(box)), rtree.qend(index::intersects(box)), std::back_inserter(returned_values));
+
+ /* Boost.Typeof */
+ typedef BOOST_TYPEOF(rtree.qbegin(index::nearest(pt, 5))) const_query_iterator;
+ const_query_iterator first = rtree.qbegin(index::nearest(pt, 5));
+ const_query_iterator last = rtree.qend(index::nearest(pt, 5));
+ // ...
+ for ( ; first != last ; ++first )
+ *first; // do domething with Value
+
+ /* C++11 */
+ auto first = rtree.qbegin(index::nearest(pt, 5));
+ auto last = rtree.qend(index::nearest(pt, 5));
+ // ...
+ for ( ; first != last ; ++first )
+ *first; // do domething with Value
+
+`qend()` method is overloaded to return a different, lighter type of iterator which may be compared
+with query iterator to check if the querying was finished. But since it has different type than the one returned by
+`qbegin(Pred)` it can't be used with STL-like functions like `std::copy()` which expect that `first` and `last`
+iterators have the same type.
+
+ /* function call */
+ template
+ void my_copy(First first, Last last, Out out)
+ {
+ for ( ; first != last ; ++out, ++first )
+ *out = *first;
+ }
+ // ...
+ my_copy(rtree.qbegin(index::intersects(box)), rtree.qend(), std::back_inserter(returned_values));
+
+ /* Boost.Typeof */
+ typedef BOOST_TYPEOF(rtree.qbegin(index::nearest(pt, 5))) const_query_iterator;
+ typedef BOOST_TYPEOF(rtree.qend()) end_iterator;
+ const_query_iterator first = rtree.qbegin(index::nearest(pt, 5));
+ end_iterator last = rtree.qend();
+ // ...
+ for ( ; first != last ; ++first )
+ *first; // do domething with Value
+
+ /* C++11 */
+ auto first = rtree.qbegin(index::nearest(pt, 5));
+ auto last = rtree.qend();
+ // ...
+ for ( ; first != last ; ++first )
+ *first; // do domething with Value
+
+[endsect] [/ Experimental features /]
diff --git a/doc/index/rtree/introduction.qbk b/doc/index/rtree/introduction.qbk
new file mode 100644
index 000000000..9d25d47a9
--- /dev/null
+++ b/doc/index/rtree/introduction.qbk
@@ -0,0 +1,68 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[section Introduction]
+
+__rtree__ is a tree data structure used for spatial searching. It was proposed by
+Antonin Guttman in 1984 [footnote Guttman, A. (1984). /R-Trees: A Dynamic Index Structure for Spatial Searching/]
+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
+[footnote Cheung, K.; Fu, A. (1998). /Enhanced Nearest Neighbour Search on the R-tree/].
+
+The __rtree__ structure is presented on the image below. Each __rtree__'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).
+
+[$img/index/rtree/rstar.png]
+
+The __rtree__ is a self-balanced data structure. The key part of balancing algorithm is node splitting algorithm
+[footnote Greene, D. (1989). /An implementation and performance analysis of spatial data access methods/]
+[footnote Beckmann, N.; Kriegel, H. P.; Schneider, R.; Seeger, B. (1990). /The R*-tree: an efficient and robust access method for points and rectangles/].
+Each algorithm produces 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. 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. The performance of the R-tree depends on balancing algorithm, parameters and data inserted into the container.
+Example structures of trees created by use of three different algorithms and operations time are presented below. Data used in benchmark was random,
+non-overlapping boxes.
+
+[table
+[[] [linear algorithm] [quadratic algorithm] [R*-tree]]
+[[*Example structure*] [[$img/index/rtree/linear.png]] [[$img/index/rtree/quadratic.png]] [[$img/index/rtree/rstar.png]]]
+[[*1M Values inserts*] [1.65s] [2.51s] [4.96s]]
+[[*100k spatial queries*] [0.87s] [0.25s] [0.09s]]
+[[*100k knn queries*] [3.25s] [1.41s] [0.51s]]
+]
+
+[heading Implementation details]
+
+Key features of this implementation of the __rtree__ are:
+
+* capable to store arbitrary __value__ type,
+* three different creation algorithms - linear, quadratic or rstar,
+* parameters (including maximal and minimal number of elements) may be passed as compile- or run-time parameters,
+* advanced queries - e.g. search for 5 nearest values to some point and intersecting some region but not within the other one,
+* C++11 conformant: move semantics, stateful allocators,
+* capable to store __value__ type with no default constructor.
+
+[heading Dependencies]
+
+R-tree depends on *Boost.Move*, *Boost.Container*, *Boost.Tuple*, *Boost.Utility*, *Boost.MPL*.
+
+[heading Contributors]
+
+The spatial index was originally started by Federico J. Fernandez during the Google Summer of Code 2008 program, mentored by Hartmut Kaiser.
+
+[heading Spatial thanks]
+
+I'd like to thank Barend Gehrels, Bruno Lalande, Mateusz Łoskot, Lucanus J. Simonson for their support and ideas.
+
+[endsect]
+
+
diff --git a/doc/index/rtree/query.qbk b/doc/index/rtree/query.qbk
new file mode 100644
index 000000000..328dc6437
--- /dev/null
+++ b/doc/index/rtree/query.qbk
@@ -0,0 +1,219 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2013 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)
+=============================================================================/]
+
+[section Queries]
+
+Queries returns `__value__`s which meets some predicates. Currently supported are three types of predicates:
+
+* 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:
+
+* intersecting some area but not within other area,
+* are nearest to some point,
+* overlapping a box and has user-defined property.
+
+[section Performing a query]
+
+There are three ways to perform a query presented below. All of them returns `__value__`s intersecting some
+region defined as a `__box__`.
+
+Method call
+
+ std::vector<__value__> returned_values;
+ __box__ box_region(...);
+ rt.query(bgi::intersects(box_region), std::back_inserter(returned_values));
+
+Function call
+
+ std::vector<__value__> returned_values;
+ __box__ box_region(...);
+ index::query(rt, bgi::intersects(box_region), std::back_inserter(returned_values));
+
+Use of pipe operator generating a range
+
+ __box__ box_region(...);
+ BOOST_FOREACH(__value__ & v, rt | index::adaptors::queried(bgi::intersects(box_region)))
+ ; // do something with v
+
+[endsect]
+
+[section Spatial predicates]
+
+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)] [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]]]
+]
+
+[table
+[[intersects(Ring)] [intersects(Polygon)] [intersects(MultiPolygon)]]
+[[[$img/index/rtree/intersects_ring.png]] [[$img/index/rtree/intersects_poly.png]] [[$img/index/rtree/intersects_mpoly.png]]]
+]
+
+To use a spatial predicate one may use one of the functions defined in `boost::geometry::index` namespace.
+
+ rt.query(index::intersects(box), std::back_inserter(result));
+ 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));
+
+All spatial predicates may be negated, e.g.:
+
+ rt.query(!index::intersects(box), std::back_inserter(result));
+ // the same as
+ rt.query(index::disjoint(box), std::back_inserter(result));
+
+[endsect]
+
+[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.
+The example of knn query is presented below. 5 `__value__`s nearest to some point are orange.
+
+[$img/index/rtree/knn.png]
+
+[heading k nearest neighbours]
+
+There are three ways of performing knn queries. Following queries returns
+`k` `__value__`s closest to some point in space. For `__box__`es
+`__indexable__`s the distance to the nearest point is calculated by default.
+
+Method call
+
+ std::vector<__value__> returned_values;
+ __point__ pt(...);
+ rt.query(index::nearest(pt, k), std::back_inserter(returned_values));
+
+Function call
+
+ std::vector<__value__> returned_values;
+ __point__ pt(...);
+ index::query(rt, index::nearest(pt, k), std::back_inserter(returned_values));
+
+Use of `operator |`
+
+ __point__ pt(...);
+ BOOST_FOREACH(__value__ & v, rt | index::adaptors::queried(index::nearest(pt, k)))
+ ; // do something with v
+
+[endsect]
+
+[section User-defined unary predicate]
+
+The user may pass a `UnaryPredicate` - function, function object or lambda expression taking const reference to Value and returning bool.
+This object may be passed to the query in order to check if `__value__` should be returned by the query. To do it one
+may use `index::satisfies()` function like on the example below:
+
+ bool is_red(__value__ const& v)
+ {
+ return v.is_red();
+ }
+
+ struct is_red_o
+ {
+ template
+ bool operator()(__value__ const& v)
+ {
+ return v.is_red();
+ }
+ }
+
+ // ...
+
+ rt.query(index::intersects(box) && index::satisfies(is_red),
+ std::back_inserter(result));
+
+ rt.query(index::intersects(box) && index::satisfies(is_red_o()),
+ std::back_inserter(result));
+
+ #ifndef BOOST_NO_CXX11_LAMBDAS
+ rt.query(index::intersects(box) && index::satisfies([](__value__ const& v) { return v.is_red(); }),
+ 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]
+
+It's possible to use some number of predicates in one query by connecting them with `operator&&` e.g. `Pred1 && Pred2 && Pred3 && ...`.
+
+These predicates are connected by logical AND. Passing all predicates together not only makes possible
+to construct advanced queries but is also faster than separate calls because the tree is traversed only once.
+Traversing is continued and `Value`s are returned only if all predicates are met. Predicates are checked
+left-to-right so placing most restictive predicates first should accelerate the search.
+
+ rt.query(index::intersects(box1) && !index::within(box2),
+ std::back_inserter(result));
+
+ rt.query(index::intersects(box1) && !index::within(box2) && index::overlaps(box3),
+ std::back_inserter(result));
+
+Of course it's possible to connect different types of predicates together.
+
+ index::query(rt, index::nearest(pt, k) && index::within(b), std::back_inserter(returned_values));
+
+ BOOST_FOREACH(Value & v, rt | index::adaptors::queried(index::nearest(pt, k) && index::covered_by(b)))
+ ; // do something with v
+
+[endsect]
+
+[section Inserting query results into the other R-tree]
+
+There are several ways of inserting Values returned by a query to the other R-tree container.
+The most basic way is creating a temporary container for Values and insert them later.
+
+ namespace bgi = boost::geometry::index;
+ typedef std::pair __value__;
+ typedef bgi::rtree< __value__, bgi::linear<32, 8> > RTree;
+
+ RTree rt1;
+ /* some inserting into the tree */
+
+ std::vector result;
+ rt1.query(bgi::intersects(Box(/*...*/)), std::back_inserter(result));
+ RTree rt2(result.begin(), result.end());
+
+However there are better ways. One of these methods is mentioned in the "Creation and modification" section.
+The insert iterator may be passed directly into the query.
+
+ RTree rt3;
+ rt1.query(bgi::intersects(Box(/*...*/))), bgi::inserter(rt3));
+
+If you like Boost.Range you'll appreciate the third option. You may pass the result Range directly into the
+constructor.
+
+ RTree rt4(rt1 | bgi::adaptors::queried(bgi::intersects(Box(/*...*/)))));
+
+[endsect]
+
+[endsect] [/ Queries /]
diff --git a/doc/index/rtree/quickstart.qbk b/doc/index/rtree/quickstart.qbk
new file mode 100644
index 000000000..92c50c4fc
--- /dev/null
+++ b/doc/index/rtree/quickstart.qbk
@@ -0,0 +1,59 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2012 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)
+=============================================================================/]
+
+[section:rtree_quickstart Quick Start]
+
+This Quick Start section shows simple way to creating a typical R-tree and perform
+spatial query.
+
+The code below assumes that following files are included and namespaces used.
+
+[rtree_quickstart_include]
+
+Typically you'll store e.g. `std::pair` in the __rtree__. `MyGeometryId`
+will be some indentifier of a complex `Geometry` stored in other container, e.g. index type
+of a `Polygon` stored in the vector or an iterator of list of `Ring`s. To keep it simple to
+define `Value` we will use predefined __box__ and unsigned int.
+
+[rtree_quickstart_valuetype]
+
+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 is set to 16.
+
+[rtree_quickstart_create]
+
+Typically `Value`s will be generated in a loop from e.g. `Polygon`s stored in some other container.
+In this case `Box` objects will probably be created with `geometry::envelope()` function.
+But to keep it simple lets just generate some boxes manually and insert them into the R-tree by
+using `insert()` method.
+
+[rtree_quickstart_insert]
+
+There are various types of spatial queries that may be performed, they can 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 `Values` in the result is not specified.
+
+[rtree_quickstart_spatial_query]
+
+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.
+
+[rtree_quickstart_nearest_query]
+
+At the end we'll print results.
+
+[rtree_quickstart_output]
+
+[h3 More]
+More information about the R-tree implementation, other algorithms and queries may be found in
+other parts of this documentation.
+
+[endsect]
diff --git a/doc/index/rtree/reference.qbk b/doc/index/rtree/reference.qbk
new file mode 100644
index 000000000..c53b01fbd
--- /dev/null
+++ b/doc/index/rtree/reference.qbk
@@ -0,0 +1,40 @@
+[/============================================================================
+ Boost.Geometry Index
+
+ Copyright (c) 2011-2013 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)
+=============================================================================/]
+
+[section:reference Reference]
+
+[include ../generated/rtree.qbk]
+[include ../generated/rtree_functions.qbk]
+
+[section:parameters R-tree parameters (boost::geometry::index::)]
+
+[include ../generated/rtree_linear.qbk]
+[include ../generated/rtree_quadratic.qbk]
+[include ../generated/rtree_rstar.qbk]
+[include ../generated/rtree_dynamic_linear.qbk]
+[include ../generated/rtree_dynamic_quadratic.qbk]
+[include ../generated/rtree_dynamic_rstar.qbk]
+
+[endsect]
+
+[/section:function_objects Function objects (boost::geometry::index::)/]
+
+[include ../generated/indexable.qbk]
+[include ../generated/equal_to.qbk]
+
+[/endsect/]
+
+[include ../generated/predicates.qbk]
+[include ../generated/nearest_relations.qbk]
+[include ../generated/adaptors.qbk]
+
+[include ../generated/inserters.qbk]
+
+[endsect]
diff --git a/doc/index/src/examples/Jamfile.v2 b/doc/index/src/examples/Jamfile.v2
new file mode 100644
index 000000000..e221ca86b
--- /dev/null
+++ b/doc/index/src/examples/Jamfile.v2
@@ -0,0 +1,19 @@
+# Boost.Geometry Index
+#
+# Copyright (c) 2011-2012 Adam Wulkiewicz, Lodz, Poland.
+#
+# 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)
+
+import testing ;
+
+project boost-geometry-index-doc-src-examples
+ :
+ requirements
+ ../../..
+ #../../../boost/geometry/extensions/contrib/ttmath
+ msvc:on
+ ;
+
+build-project rtree ;
diff --git a/doc/index/src/examples/rtree/Jamfile.v2 b/doc/index/src/examples/rtree/Jamfile.v2
new file mode 100644
index 000000000..79778b9ab
--- /dev/null
+++ b/doc/index/src/examples/rtree/Jamfile.v2
@@ -0,0 +1,25 @@
+# Boost.Geometry Index
+#
+# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+#
+# 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)
+
+exe quick_start : quick_start.cpp ;
+exe polygons_vector : polygons_vector.cpp ;
+exe polygons_shared_ptr : polygons_shared_ptr.cpp ;
+exe variants_map : variants_map.cpp ;
+exe value_shared_ptr : value_shared_ptr.cpp ;
+exe value_index : value_index.cpp ;
+
+exe interprocess : interprocess.cpp /boost/thread//boost_thread
+ :
+ acc:-lrt
+ acc-pa_risc:-lrt
+ gcc-mingw:"-lole32 -loleaut32 -lpsapi -ladvapi32"
+ hpux,gcc:"-Wl,+as,mpas"
+ :
+ multi
+ : # requirements
+ ;
diff --git a/doc/index/src/examples/rtree/interprocess.cpp b/doc/index/src/examples/rtree/interprocess.cpp
new file mode 100644
index 000000000..61d3f0b50
--- /dev/null
+++ b/doc/index/src/examples/rtree/interprocess.cpp
@@ -0,0 +1,112 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_interprocess
+
+#include
+#include
+#include
+
+#include
+
+#include
+
+#include
+#include
+
+#include
+#include
+#include //std::system
+
+//For parent process argc == 1, for child process argc > 1
+int main(int argc, char *argv[])
+{
+ using namespace boost::interprocess;
+ namespace bg = boost::geometry;
+ namespace bgm = bg::model;
+ namespace bgi = bg::index;
+
+ typedef bgm::point P;
+ typedef bgm::box
B;
+
+ typedef bgi::linear<32, 8> Par;
+ typedef bgi::indexable I;
+ typedef bgi::equal_to E;
+ typedef allocator Alloc;
+ typedef bgi::rtree Rtree;
+
+ //Parent process
+ if ( argc == 1 )
+ {
+ struct shm_remove
+ {
+ shm_remove() { shared_memory_object::remove("MySharedMemory"); }
+ ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); }
+ } remover;
+
+ managed_shared_memory segment(create_only, "MySharedMemory", 65536);
+
+ std::cout << "Parent: Constructing container\n";
+
+ Rtree * tree = segment.construct("Rtree")(Par(), I(), E(), Alloc(segment.get_segment_manager()));
+
+ std::cout << "Parent: Filling container with 100 boxes\n";
+
+ for ( float i = 0 ; i < 100 ; i += 1 )
+ tree->insert(B(P(i, i), P(i+0.5f, i+0.5f)));
+
+ std::cout << "Parent: Tree content\n";
+ Rtree::bounds_type bb = tree->bounds();
+ std::cout << "[(" << bg::get<0>(bb.min_corner()) << ", " << bg::get<1>(bb.min_corner())
+ << ")(" << bg::get<0>(bb.max_corner()) << ", " << bg::get<1>(bb.max_corner()) << ")]\n";
+
+ std::cout << "Parent: Running child process\n";
+
+ std::string s(argv[0]); s += " child ";
+ if ( 0 != std::system(s.c_str()) )
+ return 1;
+
+ if ( segment.find("Rtree").first )
+ return 1;
+
+ std::cout << "Parent: Container was properly destroyed by the child process\n";
+ }
+ //Child process
+ else
+ {
+ managed_shared_memory segment(open_only, "MySharedMemory");
+
+ std::cout << "Child: Searching of the container in shared memory\n";
+
+ Rtree * tree = segment.find("Rtree").first;
+
+ std::cout << "Child: Querying for objects intersecting box = [(45, 45)(55, 55)]\n";
+
+ std::vector result;
+ unsigned k = tree->query(bgi::intersects(B(P(45, 45), P(55, 55))), std::back_inserter(result));
+
+ std::cout << "Child: Found objects:\n";
+ std::cout << k << "\n";
+ BOOST_FOREACH(B const& b, result)
+ {
+ std::cout << "[(" << bg::get<0>(b.min_corner()) << ", " << bg::get<1>(b.min_corner())
+ << ")(" << bg::get<0>(b.max_corner()) << ", " << bg::get<1>(b.max_corner()) << ")]\n";
+ }
+ std::cout << "\n";
+
+ std::cout << "Child: Destroying container\n";
+
+ segment.destroy("Rtree");
+ }
+
+ return 0;
+};
+
+//]
diff --git a/doc/index/src/examples/rtree/polygons_shared_ptr.cpp b/doc/index/src/examples/rtree/polygons_shared_ptr.cpp
new file mode 100644
index 000000000..c65ba5376
--- /dev/null
+++ b/doc/index/src/examples/rtree/polygons_shared_ptr.cpp
@@ -0,0 +1,88 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_polygons_shared_ptr
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+namespace bg = boost::geometry;
+namespace bgi = boost::geometry::index;
+
+int main(void)
+{
+ typedef bg::model::point point;
+ typedef bg::model::box box;
+ typedef bg::model::polygon polygon; // ccw, open polygon
+ typedef boost::shared_ptr shp;
+ typedef std::pair value;
+
+ // create the rtree using default constructor
+ bgi::rtree< value, bgi::linear<16, 4> > rtree;
+
+ std::cout << "filling index with polygons shared pointers:" << std::endl;
+
+ // create some polygons and fill the spatial index
+ for ( unsigned i = 0 ; i < 10 ; ++i )
+ {
+ // create a polygon
+ shp p(new polygon());
+ for ( float a = 0 ; a < 6.28316f ; a += 1.04720f )
+ {
+ float x = i + int(10*::cos(a))*0.1f;
+ float y = i + int(10*::sin(a))*0.1f;
+ p->outer().push_back(point(x, y));
+ }
+
+ // display new polygon
+ std::cout << bg::wkt(*p) << std::endl;
+
+ // calculate polygon bounding box
+ box b = bg::return_envelope(*p);
+ // insert new value
+ rtree.insert(std::make_pair(b, p));
+ }
+
+ // find values intersecting some area defined by a box
+ box query_box(point(0, 0), point(5, 5));
+ std::vector result_s;
+ rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));
+
+ // find 5 nearest values to a point
+ std::vector result_n;
+ rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));
+
+ // display results
+ std::cout << "spatial query box:" << std::endl;
+ std::cout << bg::wkt(query_box) << std::endl;
+ std::cout << "spatial query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_s)
+ std::cout << bg::wkt(*v.second) << std::endl;
+
+ std::cout << "knn query point:" << std::endl;
+ std::cout << bg::wkt(point(0, 0)) << std::endl;
+ std::cout << "knn query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_n)
+ std::cout << bg::wkt(*v.second) << std::endl;
+
+ return 0;
+}
+
+//]
diff --git a/doc/index/src/examples/rtree/polygons_vector.cpp b/doc/index/src/examples/rtree/polygons_vector.cpp
new file mode 100644
index 000000000..a8984a732
--- /dev/null
+++ b/doc/index/src/examples/rtree/polygons_vector.cpp
@@ -0,0 +1,96 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_polygons_vector
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+namespace bg = boost::geometry;
+namespace bgi = boost::geometry::index;
+
+int main(void)
+{
+ typedef bg::model::point point;
+ typedef bg::model::box box;
+ typedef bg::model::polygon polygon; // ccw, open polygon
+ typedef std::pair value;
+
+ // polygons
+ std::vector polygons;
+
+ // create some polygons
+ for ( unsigned i = 0 ; i < 10 ; ++i )
+ {
+ // create a polygon
+ polygon p;
+ for ( float a = 0 ; a < 6.28316f ; a += 1.04720f )
+ {
+ float x = i + int(10*::cos(a))*0.1f;
+ float y = i + int(10*::sin(a))*0.1f;
+ p.outer().push_back(point(x, y));
+ }
+
+ // add polygon
+ polygons.push_back(p);
+ }
+
+ // display polygons
+ std::cout << "generated polygons:" << std::endl;
+ BOOST_FOREACH(polygon const& p, polygons)
+ std::cout << bg::wkt(p) << std::endl;
+
+ // create the rtree using default constructor
+ bgi::rtree< value, bgi::rstar<16, 4> > rtree;
+
+ // fill the spatial index
+ for ( unsigned i = 0 ; i < polygons.size() ; ++i )
+ {
+ // calculate polygon bounding box
+ box b = bg::return_envelope(polygons[i]);
+ // insert new value
+ rtree.insert(std::make_pair(b, i));
+ }
+
+ // find values intersecting some area defined by a box
+ box query_box(point(0, 0), point(5, 5));
+ std::vector result_s;
+ rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));
+
+ // find 5 nearest values to a point
+ std::vector result_n;
+ rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));
+
+ // display results
+ std::cout << "spatial query box:" << std::endl;
+ std::cout << bg::wkt(query_box) << std::endl;
+ std::cout << "spatial query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_s)
+ std::cout << bg::wkt(polygons[v.second]) << std::endl;
+
+ std::cout << "knn query point:" << std::endl;
+ std::cout << bg::wkt(point(0, 0)) << std::endl;
+ std::cout << "knn query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_n)
+ std::cout << bg::wkt(polygons[v.second]) << std::endl;
+
+ return 0;
+}
+
+//]
diff --git a/doc/index/src/examples/rtree/quick_start.cpp b/doc/index/src/examples/rtree/quick_start.cpp
new file mode 100644
index 000000000..80c883122
--- /dev/null
+++ b/doc/index/src/examples/rtree/quick_start.cpp
@@ -0,0 +1,87 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_quickstart
+
+//[rtree_quickstart_include
+
+#include
+#include
+#include
+
+#include
+
+// to store queries results
+#include
+
+// just for output
+#include
+#include
+
+namespace bg = boost::geometry;
+namespace bgi = boost::geometry::index;
+//]
+
+int main(void)
+{
+ //[rtree_quickstart_valuetype
+ typedef bg::model::point point;
+ typedef bg::model::box box;
+ typedef std::pair value;
+ //]
+
+ //[rtree_quickstart_create
+ // create the rtree using default constructor
+ bgi::rtree< value, bgi::quadratic<16> > rtree;
+ //]
+
+ //[rtree_quickstart_insert
+ // 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));
+ }
+ //]
+
+ //[rtree_quickstart_spatial_query
+ // find values intersecting some area defined by a box
+ box query_box(point(0, 0), point(5, 5));
+ std::vector result_s;
+ rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));
+ //]
+
+ //[rtree_quickstart_nearest_query
+ // find 5 nearest values to a point
+ std::vector result_n;
+ rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));
+ //]
+
+ //[rtree_quickstart_output
+ // display results
+ std::cout << "spatial query box:" << std::endl;
+ std::cout << bg::wkt(query_box) << std::endl;
+ std::cout << "spatial query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_s)
+ std::cout << bg::wkt(v.first) << " - " << v.second << std::endl;
+
+ std::cout << "knn query point:" << std::endl;
+ std::cout << bg::wkt(point(0, 0)) << std::endl;
+ std::cout << "knn query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_n)
+ std::cout << bg::wkt(v.first) << " - " << v.second << std::endl;
+ //]
+
+ return 0;
+}
+
+//]
diff --git a/doc/index/src/examples/rtree/value_index.cpp b/doc/index/src/examples/rtree/value_index.cpp
new file mode 100644
index 000000000..32f306909
--- /dev/null
+++ b/doc/index/src/examples/rtree/value_index.cpp
@@ -0,0 +1,97 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_value_index
+
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+namespace bg = boost::geometry;
+namespace bgi = boost::geometry::index;
+
+template
+class my_indexable
+{
+ typedef typename Container::size_type size_t;
+ typedef typename Container::const_reference cref;
+ Container const& container;
+
+public:
+ typedef cref result_type;
+ explicit my_indexable(Container const& c) : container(c) {}
+ result_type operator()(size_t i) const { return container[i]; }
+};
+
+int main(void)
+{
+ typedef bg::model::point point;
+ typedef bg::model::box box;
+ typedef std::vector::size_type value;
+ typedef bgi::rstar<16, 4> parameters;
+ typedef my_indexable< std::vector > indexable_getter;
+
+ // boxes
+ std::vector boxes;
+
+ // create some boxes
+ for ( unsigned i = 0 ; i < 10 ; ++i )
+ {
+ // add a box
+ boxes.push_back(box(point(i, i), point(i+0.5f, i+0.5f)));
+ }
+
+ // display boxes
+ std::cout << "generated boxes:" << std::endl;
+ BOOST_FOREACH(box const& b, boxes)
+ std::cout << bg::wkt(b) << std::endl;
+
+ // create the rtree
+ parameters params;
+ indexable_getter ind(boxes);
+ bgi::rtree rtree(params, ind);
+
+ // fill the spatial index
+ for ( size_t i = 0 ; i < boxes.size() ; ++i )
+ rtree.insert(i);
+
+ // find values intersecting some area defined by a box
+ box query_box(point(0, 0), point(5, 5));
+ std::vector result_s;
+ rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));
+
+ // find 5 nearest values to a point
+ std::vector result_n;
+ rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));
+
+ // display results
+ std::cout << "spatial query box:" << std::endl;
+ std::cout << bg::wkt(query_box) << std::endl;
+ std::cout << "spatial query result:" << std::endl;
+ BOOST_FOREACH(value i, result_s)
+ std::cout << bg::wkt(boxes[i]) << std::endl;
+
+ std::cout << "knn query point:" << std::endl;
+ std::cout << bg::wkt(point(0, 0)) << std::endl;
+ std::cout << "knn query result:" << std::endl;
+ BOOST_FOREACH(value i, result_n)
+ std::cout << bg::wkt(boxes[i]) << std::endl;
+
+ return 0;
+}
+
+//]
diff --git a/doc/index/src/examples/rtree/value_shared_ptr.cpp b/doc/index/src/examples/rtree/value_shared_ptr.cpp
new file mode 100644
index 000000000..e2ff55737
--- /dev/null
+++ b/doc/index/src/examples/rtree/value_shared_ptr.cpp
@@ -0,0 +1,91 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_value_shared_ptr
+
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+namespace bg = boost::geometry;
+namespace bgi = boost::geometry::index;
+
+namespace boost { namespace geometry { namespace index {
+
+template
+struct indexable< boost::shared_ptr >
+{
+ typedef boost::shared_ptr V;
+
+ typedef Box const& result_type;
+ result_type operator()(V const& v) const { return *v; }
+};
+
+}}} // namespace boost::geometry::index
+
+int main(void)
+{
+ typedef bg::model::point point;
+ typedef bg::model::box box;
+ typedef boost::shared_ptr shp;
+ typedef shp value;
+
+ // create the rtree using default constructor
+ bgi::rtree< value, bgi::linear<16, 4> > rtree;
+
+ std::cout << "filling index with boxes shared pointers:" << std::endl;
+
+ // fill the spatial index
+ for ( unsigned i = 0 ; i < 10 ; ++i )
+ {
+ // create a box
+ shp b(new box(point(i, i), point(i+0.5f, i+0.5f)));
+
+ // display new box
+ std::cout << bg::wkt(*b) << std::endl;
+
+ // insert new value
+ rtree.insert(b);
+ }
+
+ // find values intersecting some area defined by a box
+ box query_box(point(0, 0), point(5, 5));
+ std::vector result_s;
+ rtree.query(bgi::intersects(query_box), std::back_inserter(result_s));
+
+ // find 5 nearest values to a point
+ std::vector result_n;
+ rtree.query(bgi::nearest(point(0, 0), 5), std::back_inserter(result_n));
+
+ // display results
+ std::cout << "spatial query box:" << std::endl;
+ std::cout << bg::wkt(query_box) << std::endl;
+ std::cout << "spatial query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_s)
+ std::cout << bg::wkt(*v) << std::endl;
+
+ std::cout << "knn query point:" << std::endl;
+ std::cout << bg::wkt(point(0, 0)) << std::endl;
+ std::cout << "knn query result:" << std::endl;
+ BOOST_FOREACH(value const& v, result_n)
+ std::cout << bg::wkt(*v) << std::endl;
+
+ return 0;
+}
+
+//]
diff --git a/doc/index/src/examples/rtree/variants_map.cpp b/doc/index/src/examples/rtree/variants_map.cpp
new file mode 100644
index 000000000..462795002
--- /dev/null
+++ b/doc/index/src/examples/rtree/variants_map.cpp
@@ -0,0 +1,143 @@
+// Boost.Geometry Index
+//
+// Quickbook Examples
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// 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)
+
+//[rtree_variants_map
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include