mirror of
https://github.com/boostorg/geometry.git
synced 2026-01-25 18:22:16 +00:00
* Update geometry.qbk * Update introduction.qbk * Update compiling.qbk * Update design_rationale.qbk * Update introduction.qbk * Update quickstart.qbk * Update creation.qbk * Update query.qbk * Update reference.qbk * Update * Update * Update * Update * Update buffer_with_strategies.qbk * Update expand.qbk * Update expand.qbk * Update union.hpp * Update point.qbk * Update box.qbk * Update cs.hpp * Update closure.hpp * Update point.hpp * Update rtree.hpp * Update choose_next_node.hpp * Update iterator.hpp * Update point_in_poly_winding.hpp * Update spatial_query.hpp * Update imw_p.hpp * Update remove.hpp * Update redistribute_elements.hpp * Update redistribute_elements.hpp * Update insert.hpp * Update redistribute_elements.hpp * Update point_in_poly_crossings_multiply.hpp * Update closeable_view.hpp * Update example_adapting_a_legacy_geometry_object_model.qbk * Update acknowledgments.qbk * Update indexable.hpp * Update for_each.hpp * Update iterators.hpp * Update spatial_query.hpp * Update query_iterators.hpp
60 lines
2.4 KiB
Plaintext
60 lines
2.4 KiB
Plaintext
[/============================================================================
|
|
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 a simple way to create 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<Box, MyGeometryId>` in the __rtree__. `MyGeometryId`
|
|
will be some identifier 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 let's 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]
|