doxygen_examples.hpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. //
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef _DOXYGEN_EXAMPLES_HPP
  9. #define _DOXYGEN_EXAMPLES_HPP
  10. /*!
  11. \example 01_point_example.cpp
  12. In most cases the documentation gives small examples of how to use the algorithms or classes.
  13. The point example is a slightly larger example giving an idea of how to use different
  14. algorithms from the library, related to points. It shows
  15. - the usage of include files
  16. - how to declare points, using different coordinate types
  17. - how to construct points, specifying coordinates, initializing to zero or to infinite
  18. - how to compare points to each other
  19. - how points can be streamed as OGC text
  20. - calculating the distance from point to point
  21. */
  22. //---------------------------------------------------------------------------------------------------
  23. /*!
  24. \example 02_linestring_example.cpp
  25. The linestring example shows how linestrings can be declared and used and shows some more algorithms.
  26. One of the important concepts of the Generic Geometry Library is that it is totally built upon the standard
  27. library, using the standard containers such as std::vector.
  28. A linestring is, as explained elsewhere in this documentation, not much more than a vector of points.
  29. Most algorithms run on linestrings, but can also run on any iterator pair. And all algorithms
  30. on std::vector can be used on geometry::linestring.
  31. The sample shows this, shows some algorithms:
  32. - geometry::envelope
  33. - geometry::length
  34. - geometry::distance
  35. - geometry::simplify
  36. - geometry::for_each
  37. - geometry::intersection
  38. This documentation illustrates the simplify algorithm and the intersection algorithm with some pictures.
  39. The simplify algorithm simplifies a linestring. Simplification means that the less important points
  40. are removed from the line and that the points that are most important for the shape of a line are
  41. kept. Simplification is done using the well known Douglas Peucker algorithm. The library user can
  42. specify the distance or tolerance, which indicates how much the linestring should be simplified.
  43. The image below shows the original and simplified linestring:
  44. \image html simplify_linestring.png
  45. The blue line is the original linestring; the red line is the simplified line which has one point less.
  46. In geographical applications simplification can reduce a linestring to its basic form containing only
  47. 10% of its original points.
  48. The intersection algorithm intersects two geometries which each other, delivering a third geometry.
  49. In the case of the example a linestring is intersected with a box. Intersection with a box is often
  50. called a clip. The image below illustrates the intersection.
  51. \image html clip_linestring.png
  52. The yellow line is intersected with the blue box.
  53. The intersection result, painted in red, contains three linestrings.
  54. */
  55. //---------------------------------------------------------------------------------------------------
  56. /*!
  57. \example 03_polygon_example.cpp
  58. The polygon example shows some examples of what can be done with polygons in the Generic Geometry Library:
  59. * the outer ring and the inner rings
  60. * how to calculate the area of a polygon
  61. * how to get the centroid, and how to get an often more interesting label point
  62. * how to correct the polygon such that it is clockwise and closed
  63. * within: the well-known point in polygon algorithm
  64. * how to use polygons which use another container, or which use different containers for points and for inner rings
  65. * how polygons can be intersected, or clipped, using a clipping box
  66. The illustrations below show the usage of the within algorithm and the intersection algorithm.
  67. The within algorithm results in true if a point lies completly within a polygon. If it lies exactly
  68. on a border it is not considered as within and if it is inside a hole it is also not within the
  69. polygon. This is illustrated below, where only the point in the middle is within the polygon.
  70. \image html within_polygon.png
  71. The clipping algorithm, called intersection, is illustrated below:
  72. \image html clip_polygon.png
  73. The yellow polygon, containing a hole, is clipped with the blue rectangle, resulting in a
  74. multi_polygon of three polygons, drawn in red. The hole is vanished.
  75. include polygon_example.cpp
  76. */
  77. //---------------------------------------------------------------------------------------------------
  78. /*!
  79. \example 06_a_transformation_example.cpp
  80. This sample demonstrates the usage of transformations in the Generic Geometry Library.
  81. Behind the screens this is done using with the uBLAS matrix/vector library.
  82. \example 06_b_transformation_example.cpp
  83. */
  84. //---------------------------------------------------------------------------------------------------
  85. /*!
  86. \example 07_a_graph_route_example.cpp
  87. The graph route example shows how GGL can be combined with Boost.Graph. The sample does the following things:
  88. - it reads roads (included in the distribution, stored on disk in the form of a text file containing geometries and names)
  89. - it reads cities
  90. - it creates a graph from the roads
  91. - it connects each city to the nearest vertex in the graph
  92. - it calculates the shortest route between each pair of cities
  93. - it outputs the distance over the road, and also of the air
  94. - it creates an SVG image with the roads, the cities, and the first calculated route
  95. Note that this example is useful, but it is only an example. It could be built in many different ways.
  96. For example:
  97. - the roads/cities could be read from a database using SOCI, or from a shapefile using shapelib
  98. - it could support oneway roads and roads on different levels (disconnected bridges)
  99. - it currently uses tuples but that could be anything
  100. - etc
  101. The SVG looks like:
  102. \image html 07_graph_route_example_svg.png
  103. The output screen looks like:
  104. \image html 07_graph_route_example_text.png
  105. \example 07_b_graph_route_example.cpp
  106. */
  107. //---------------------------------------------------------------------------------------------------
  108. /*!
  109. \example c01_custom_point_example.cpp
  110. This sample demonstrates that custom points can be made as well. This sample contains many points, derived
  111. from boost::tuple, created from scratch, read only points, legacy points, etc.
  112. */
  113. //---------------------------------------------------------------------------------------------------
  114. /*!
  115. \example c02_custom_box_example.cpp
  116. Besides custom points, custom boxes are possible as shown in this example.
  117. */
  118. //---------------------------------------------------------------------------------------------------
  119. /*
  120. \example c03_custom_linestring_example.cpp
  121. GPS tracks are shown in this example: a custom linestring with GPS points
  122. */
  123. //---------------------------------------------------------------------------------------------------
  124. /*!
  125. \example c04_a_custom_triangle_example.cpp
  126. The \b custom triangle \b example goes even further and implements a custom ring, where the area calculation
  127. algorithm is optimized for a triangle
  128. */
  129. //---------------------------------------------------------------------------------------------------
  130. /*!
  131. \example c04_b_custom_triangle_example.cpp
  132. This second custom triangle example shows an alternative implementation for a custom shape, showing a
  133. partial specialization for the area calculation.
  134. */
  135. //---------------------------------------------------------------------------------------------------
  136. /*!
  137. \example c05_custom_point_pointer_example.cpp
  138. This example shows how GGL can be used to adapt a pointer-to-a-point, used e.g. in a linestring
  139. */
  140. //---------------------------------------------------------------------------------------------------
  141. /*!
  142. \example c06_custom_polygon_example.cpp
  143. Showing a custom polygon (asked on the list during Formal Review)
  144. */
  145. //---------------------------------------------------------------------------------------------------
  146. /*!
  147. \example x01_qt_example.cpp
  148. This sample demonstrates that by usage of concepts, external geometries can be handled
  149. by GGL, just calling by a one-line registration macro. In this case for the Qt Widget Library.
  150. The example, code shown below, results in this window-output:
  151. \image html x01_qt_example_output.png
  152. */
  153. //---------------------------------------------------------------------------------------------------
  154. /*!
  155. \example x03_a_soci_example.cpp
  156. First example showing how to get spatial data from a database using SOCI and put them into GGL
  157. */
  158. //---------------------------------------------------------------------------------------------------
  159. /*!
  160. \example x03_b_soci_example.cpp
  161. Second example showing how to get polygons from a database using SOCI and put them into GGL, using WKT.
  162. */
  163. //---------------------------------------------------------------------------------------------------
  164. /*
  165. \example x03_c_soci_example.cpp
  166. Example showing how to get polygons from PostGIS using SOCI and use them in GGL through WKB
  167. */
  168. //---------------------------------------------------------------------------------------------------
  169. /*
  170. \example x03_d_soci_example.cpp
  171. Example showing how to get polygons from PostGIS using SOCI and use them in GGL through WKB
  172. */
  173. #endif // _DOXYGEN_EXAMPLES_HPP