quickstart.qbk 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. [/============================================================================
  2. Boost.Geometry Index
  3. Copyright (c) 2011-2012 Adam Wulkiewicz.
  4. Use, modification and distribution is subject to the Boost Software License,
  5. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================/]
  8. [section:rtree_quickstart Quick Start]
  9. This Quick Start section shows simple way to creating a typical R-tree and perform
  10. spatial query.
  11. The code below assumes that following files are included and namespaces used.
  12. [rtree_quickstart_include]
  13. Typically you'll store e.g. `std::pair<Box, MyGeometryId>` in the __rtree__. `MyGeometryId`
  14. will be some identifier of a complex `Geometry` stored in other container, e.g. index type
  15. of a `Polygon` stored in the vector or an iterator of list of `Ring`s. To keep it simple to
  16. define `Value` we will use predefined __box__ and unsigned int.
  17. [rtree_quickstart_valuetype]
  18. R-tree may be created using various algorithm and parameters. You should choose the algorithm you'll
  19. find the best for your purpose. In this example we will use quadratic algorithm. Parameters are
  20. passed as template parameters. Maximum number of elements in nodes is set to 16.
  21. [rtree_quickstart_create]
  22. Typically `Value`s will be generated in a loop from e.g. `Polygon`s stored in some other container.
  23. In this case `Box` objects will probably be created with `geometry::envelope()` function.
  24. But to keep it simple lets just generate some boxes manually and insert them into the R-tree by
  25. using `insert()` method.
  26. [rtree_quickstart_insert]
  27. There are various types of spatial queries that may be performed, they can be even combined together
  28. in one call. For simplicity, we use the default one. The following query return values intersecting
  29. a box. The sequence of `Values` in the result is not specified.
  30. [rtree_quickstart_spatial_query]
  31. Other type of query is k-nearest neighbor search. It returns some number of values nearest to some point
  32. in space. The default knn query may be performed as follows. The sequence of `Values` in the result is not specified.
  33. [rtree_quickstart_nearest_query]
  34. At the end we'll print results.
  35. [rtree_quickstart_output]
  36. [h3 More]
  37. More information about the R-tree implementation, other algorithms and queries may be found in
  38. other parts of this documentation.
  39. [endsect]