Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56786 - in sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output: . html
From: barend.gehrels_at_[hidden]
Date: 2009-10-13 12:09:48


Author: barendgehrels
Date: 2009-10-13 12:09:45 EDT (Tue, 13 Oct 2009)
New Revision: 56786
URL: http://svn.boost.org/trac/boost/changeset/56786

Log:
Added doc and example folders
Some doc changes in sources plus some moves to extension
Added:
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/01__point__example_8cpp-example.html (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/02__linestring__example_8cpp-example.html (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/03__polygon__example_8cpp-example.html (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/06__transformation__example_8cpp-example.html (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07__graph__route__example_8cpp-example.html (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07_graph_route_example_svg.png (contents, props changed)
   sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07_graph_route_example_text.png (contents, props changed)

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/01__point__example_8cpp-example.html
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/01__point__example_8cpp-example.html 2009-10-13 12:09:45 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,144 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Generic Geometry Library</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head>
+<body style="background-image: url(images/draft.png);">
+
+<table cellpadding="2" width="100%">
+<tbody>
+<tr>
+<td valign="top">
+<img alt="GGL" src="images/ggl-logo-big.png" height="80" width="200">
+&nbsp;&nbsp;
+</td>
+<td valign="top" align="right">
+<img alt="Boost C++ Libraries" src="images/proposed_boost.png" height="86" width="277">
+</td>
+</tr>
+</tbody>
+</table>
+<!-- Generated by Doxygen 1.5.9 -->
+<div class="navigation" id="top">
+ <div class="tabs">
+ <ul>
+ <li>Main Page</li>
+ <li>Related Pages</li>
+ <li>Modules</li>
+ <li>Namespaces</li>
+ <li>Classes</li>
+ <li>Files</li>
+ <li>Examples</li>
+ </ul>
+ </div>
+</div>
+<div class="contents">
+<h1>01_point_example.cpp</h1>In most cases the documentation gives small examples of how to use the algorithms or classes. The point example is a slightly larger example giving the an idea of how to use different algorithms from the library, related to points. It shows<ul>
+<li>the usage of include files</li><li>how to declare points, using different coordinate types</li><li>how to construct points, specifying coordinates, initializing to zero or to infinite</li><li>how to compare points to each other</li><li>how points can be streamed as OGC text</li><li>calculating the distance from point to point</li></ul>
+<p>
+<div class="fragment"><pre class="fragment"><span class="comment">// Generic Geometry Library</span>
+<span class="comment">//</span>
+<span class="comment">// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.</span>
+<span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
+<span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
+<span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
+<span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
+<span class="comment">//</span>
+<span class="comment">// Point Example - showing Cartesian points</span>
+
+<span class="preprocessor">#include &lt;iostream&gt;</span>
+
+<span class="preprocessor">#include &lt;ggl/ggl.hpp&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>&gt;</span>
+
+
+<span class="keywordtype">int</span> main()
+{
+ <span class="keyword">using namespace </span>ggl;
+
+ <a name="_a0"></a><a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> world(1, 2);
+ std::cout &lt;&lt; <span class="stringliteral">"Hello ("</span> &lt;&lt; world.<a name="a1"></a><a class="code" href="classggl_1_1point__xy.html#a7803d55e0758a659d618583b757b272" title="Get x-value.">x</a>() &lt;&lt; <span class="stringliteral">","</span> &lt;&lt; world.<a name="a2"></a><a class="code" href="classggl_1_1point__xy.html#a83e59f4d401b1a4c6f037979c57260f" title="Get y-value.">y</a>() &lt;&lt; <span class="stringliteral">")"</span> &lt;&lt; std::endl;
+ std::cout &lt;&lt; <span class="stringliteral">"Hello "</span> &lt;&lt; <a name="a3"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">dsv</a>(world) &lt;&lt; std::endl;
+
+ <span class="comment">// Construct two points using constructor with two values</span>
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> a(1, 2);
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> b(5, 6);
+
+ <span class="comment">// The distance between them can be calculated</span>
+ std::cout &lt;&lt; <span class="stringliteral">"distance a-b is "</span> &lt;&lt; <a name="a4"></a><a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">distance</a>(a,b) &lt;&lt; std::endl;
+
+ <span class="comment">// Cartesian points have .x() and .y() for getting and setting coordinate values</span>
+ a.<a class="code" href="classggl_1_1point__xy.html#a7803d55e0758a659d618583b757b272" title="Get x-value.">x</a>(3);
+ a.<a class="code" href="classggl_1_1point__xy.html#a83e59f4d401b1a4c6f037979c57260f" title="Get y-value.">y</a>(4);
+ b.<a class="code" href="classggl_1_1point__xy.html#a7803d55e0758a659d618583b757b272" title="Get x-value.">x</a>(7);
+ b.<a class="code" href="classggl_1_1point__xy.html#a83e59f4d401b1a4c6f037979c57260f" title="Get y-value.">y</a>(8);
+ std::cout &lt;&lt; <span class="stringliteral">"a:"</span> &lt;&lt; world.<a class="code" href="classggl_1_1point__xy.html#a7803d55e0758a659d618583b757b272" title="Get x-value.">x</a>() &lt;&lt; <span class="stringliteral">" "</span> &lt;&lt; world.<a class="code" href="classggl_1_1point__xy.html#a83e59f4d401b1a4c6f037979c57260f" title="Get y-value.">y</a>() &lt;&lt; std::endl;
+ std::cout &lt;&lt; <span class="stringliteral">"distance a-b is "</span> &lt;&lt; <a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">distance</a>(a,b) &lt;&lt; std::endl;
+
+ <span class="comment">// Several ways of construction:</span>
+ <span class="comment">// 1: default constructor, required for every point</span>
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> c1;
+
+ <span class="comment">// 2: for Cartesian points: constructor with two values</span>
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> c2(1,1);
+
+ <span class="comment">// Until here, we assumed Cartesian points, having x,y coordinates. However, the Geometry Library</span>
+ <span class="comment">// uses a coordinate agnostic approach. This means that internally there is never referred</span>
+ <span class="comment">// to the name of coordinate axes. Points might also have more than 2 dimensions. Spherical</span>
+ <span class="comment">// points (which normally have theta/phi) and geographic points (which are referred to by</span>
+ <span class="comment">// latitude/longitude) are also possible.</span>
+
+ <span class="comment">// Below we do not show all kind of points, but we show the coordinate agnostic ways of</span>
+ <span class="comment">// constructing points, assigning values and retrieving values without .x/.y</span>
+ <span class="comment">// Developers using Cartesian points can of course still use .x() and .y(), which is more readable.</span>
+
+ <span class="comment">// 3: for any point, and other geometry objects: the "make" object generator</span>
+ <span class="comment">// (this one requires to specify the point-type). We say this is coordinate agnostic</span>
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> c3 = make&lt;point_2d&gt;(1,1);
+
+ <span class="comment">// 4: there is also an assign algorithm, in the same way as make, but not returning</span>
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> c4;
+ <a name="a5"></a><a class="code" href="group__access.html#ge58b5c7b493d0112202dc139af200c73" title="assign two values to a 2D point">assign</a>(c4, 1, 1);
+
+ <span class="comment">// 5: there is also a parse algorithm which takes strings (not so useful here, but</span>
+ <span class="comment">// convenient for geographic points using "32N", "18E" etc).</span>
+ <span class="comment">//point_2d c5 = parse&lt;point_2d&gt;("1", "1");</span>
+
+ <span class="comment">// The coordinate agnostic way of getting and setting</span>
+ <span class="comment">// without referring to .x() and .y()</span>
+ set&lt;0&gt;(a, 2); <span class="comment">// set first coordinate to 2</span>
+ set&lt;1&gt;(a, 3); <span class="comment">// set second coordinate to 3</span>
+ std::cout &lt;&lt; get&lt;0&gt;(a) &lt;&lt; <span class="stringliteral">","</span> &lt;&lt; get&lt;1&gt;(a) &lt;&lt; std::endl;
+
+ <span class="comment">// set&lt;2&gt;(a, 4); try to set third coordinate, this won't compile for a 2D point</span>
+
+ <span class="comment">// Other examples show other types of points, geometries and more algorithms</span>
+
+ <span class="keywordflow">return</span> 0;
+}
+</pre></div> </div>
+<hr size="1">
+<table width="100%">
+<tbody>
+<tr>
+<td align="left"><small>
+<p>October 13, 2009</p>
+</small></td>
+<td align="right">
+<small>Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
+Copyright © 2008-2009 Bruno Lalande, Paris<br>
+Copyright © 2009 Mateusz Loskot, Cadcorp, London<br>
+</small>
+</td>
+</tr>
+</tbody>
+</table>
+
+<address style="text-align: right;"><small>
+Documentation is generated by&nbsp;Doxygen
+</small></address>
+</body>
+</html>

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/02__linestring__example_8cpp-example.html
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/02__linestring__example_8cpp-example.html 2009-10-13 12:09:45 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,277 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Generic Geometry Library</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head>
+<body style="background-image: url(images/draft.png);">
+
+<table cellpadding="2" width="100%">
+<tbody>
+<tr>
+<td valign="top">
+<img alt="GGL" src="images/ggl-logo-big.png" height="80" width="200">
+&nbsp;&nbsp;
+</td>
+<td valign="top" align="right">
+<img alt="Boost C++ Libraries" src="images/proposed_boost.png" height="86" width="277">
+</td>
+</tr>
+</tbody>
+</table>
+<!-- Generated by Doxygen 1.5.9 -->
+<div class="navigation" id="top">
+ <div class="tabs">
+ <ul>
+ <li>Main Page</li>
+ <li>Related Pages</li>
+ <li>Modules</li>
+ <li>Namespaces</li>
+ <li>Classes</li>
+ <li>Files</li>
+ <li>Examples</li>
+ </ul>
+ </div>
+</div>
+<div class="contents">
+<h1>02_linestring_example.cpp</h1>The linestring example shows how linestrings can be declared and used and shows some more algorithms. One of the important concepts of the Generic Geometry Library is that it is totally built upon the standard library, using the standard containers such as std::vector.<p>
+A linestring is, as explained elsewhere in this documentation, not much more than a vector of points. Most algorithms run on linestrings, but can also run on any iterator pair. And all algorithms on std::vector can be used on geometry::linestring.<p>
+The sample shows this, shows some algorithms:<ul>
+<li>geometry::envelope</li><li>geometry::length</li><li>geometry::distance</li><li>geometry::simplify</li><li>geometry::for_each</li><li>geometry::intersection</li></ul>
+<p>
+This documentation illustrates the simplify algorithm and the intersection algorithm with some pictures.<p>
+The simplify algorithm simplifies a linestring. Simplification means that the less important points are removed from the line and that the points that are most important for the shape of a line are kept. Simplification is done using the well known Douglas Peucker algorithm. The library user can specify the distance or tolerance, which indicates how much the linestring should be simplified.<p>
+The image below shows the original and simplified linestring: <div align="center">
+<img src="simplify_linestring.png" alt="simplify_linestring.png">
+</div>
+ The blue line is the original linestring; the red line is the simplified line which has one point less. In geographical applications simplification can reduce a linestring to its basic form containing only 10% of its original points.<p>
+The intersection algorithm intersects two geometries which each other, delivering a third geometry. In the case of the example a linestring is intersected with a box. Intersection with a box is often called a clip. The image below illustrates the intersection. <div align="center">
+<img src="clip_linestring.png" alt="clip_linestring.png">
+</div>
+ The yellow line is intersected with the blue box. The intersection result, painted in red, contains three linestrings.<p>
+<div class="fragment"><pre class="fragment"><span class="comment">// Generic Geometry Library</span>
+<span class="comment">//</span>
+<span class="comment">// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.</span>
+<span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
+<span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
+<span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
+<span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
+<span class="comment">//</span>
+<span class="comment">// Linestring Example</span>
+
+<span class="preprocessor">#include &lt;algorithm&gt;</span> <span class="comment">// for reverse, unique</span>
+<span class="preprocessor">#include &lt;iostream&gt;</span>
+<span class="preprocessor">#include &lt;iterator&gt;</span>
+<span class="preprocessor">#include &lt;utility&gt;</span>
+<span class="preprocessor">#include &lt;vector&gt;</span>
+
+<span class="preprocessor">#include &lt;ggl/ggl.hpp&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>&gt;</span>
+<span class="comment">// Optional includes to handle c-arrays as points, std::vectors as linestrings</span>
+<span class="preprocessor">#include &lt;<a class="code" href="c__array__cartesian_8hpp.html">ggl/geometries/adapted/c_array_cartesian.hpp</a>&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="std__as__linestring_8hpp.html">ggl/geometries/adapted/std_as_linestring.hpp</a>&gt;</span>
+
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> P&gt;
+<span class="keyword">struct </span>point_equal
+{
+ <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator()(P <span class="keyword">const</span>&amp; left, P <span class="keyword">const</span>&amp; right)<span class="keyword"> const</span>
+<span class="keyword"> </span>{
+ <span class="keywordflow">return</span> <a name="a0"></a><a class="code" href="group__boolean__relations.html#g122b1fd835cee0742da7c97dfdda94c5" title="Calculate if two geometries are equals.">ggl::equals</a>(left, right);
+ }
+};
+
+
+<span class="keyword">template</span>&lt;<span class="keyword">typename</span> P&gt;
+<span class="keyword">inline</span> <span class="keywordtype">void</span> translate_function(P&amp; p)
+{
+ p.x(p.x() + 100.0);
+}
+
+<span class="keyword">template</span>&lt;<span class="keyword">typename</span> P&gt;
+<span class="keyword">struct </span>scale_functor
+{
+ <span class="keyword">inline</span> <span class="keywordtype">void</span> operator()(P&amp; p)
+ {
+ p.x(p.x() * 1000.0);
+ p.y(p.y() * 1000.0);
+ }
+};
+
+<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
+{
+ <span class="keyword">using namespace </span>ggl;
+
+ <span class="comment">// Define a linestring, which is a vector of points, and add some points</span>
+ <span class="comment">// (we add them deliberately in different ways)</span>
+ <a name="_a1"></a><a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">linestring_2d</a> ls;
+
+ <span class="comment">// points can be created using "make" and added to a linestring using the std:: "push_back"</span>
+ ls.push_back(make&lt;point_2d&gt;(1.1, 1.1));
+
+ <span class="comment">// points can also be assigned using "assign" and added to a linestring using "append"</span>
+ <a name="_a2"></a><a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> lp;
+ <a name="a3"></a><a class="code" href="group__access.html#ge58b5c7b493d0112202dc139af200c73" title="assign two values to a 2D point">assign</a>(lp, 2.5, 2.1);
+ <a name="a4"></a><a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ls, lp);
+
+ <span class="comment">// Lines can be streamed using DSV (delimiter separated values)</span>
+ std::cout &lt;&lt; <a name="a5"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) &lt;&lt; std::endl;
+
+ <span class="comment">// The bounding box of linestrings can be calculated</span>
+ <a name="_a6"></a><a class="code" href="classggl_1_1box.html" title="Class box: defines a box made of two describing points.">box_2d</a> b;
+ <a name="a7"></a><a class="code" href="group__envelope.html#g376bdcefa676ef2b705656b690767b36" title="Calculate envelope of a geometry, using a specified strategy.">envelope</a>(ls, b);
+ std::cout &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(b) &lt;&lt; std::endl;
+
+ <span class="comment">// The length of the line can be calulated</span>
+ std::cout &lt;&lt; <span class="stringliteral">"length: "</span> &lt;&lt; <a name="a8"></a><a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">length</a>(ls) &lt;&lt; std::endl;
+
+ <span class="comment">// All things from std::vector can be called, because a linestring is a vector</span>
+ std::cout &lt;&lt; <span class="stringliteral">"number of points 1: "</span> &lt;&lt; ls.size() &lt;&lt; std::endl;
+
+ <span class="comment">// All things from boost ranges can be called because a linestring is considered as a range</span>
+ std::cout &lt;&lt; <span class="stringliteral">"number of points 2: "</span> &lt;&lt; boost::size(ls) &lt;&lt; std::endl;
+
+ <span class="comment">// Generic function from geometry/OGC delivers the same value</span>
+ std::cout &lt;&lt; <span class="stringliteral">"number of points 3: "</span> &lt;&lt; <a name="a9"></a><a class="code" href="group__access.html#g8d58faff2722b073b44c24f19577e267" title="get number of points">num_points</a>(ls) &lt;&lt; std::endl;
+
+ <span class="comment">// The distance from a point to a linestring can be calculated</span>
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> p(1.9, 1.2);
+ std::cout &lt;&lt; <span class="stringliteral">"distance of "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(p)
+ &lt;&lt; <span class="stringliteral">" to line: "</span> &lt;&lt; <a name="a10"></a><a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">distance</a>(p, ls) &lt;&lt; std::endl;
+
+ <span class="comment">// A linestring is a vector. However, some algorithms consider "segments",</span>
+ <span class="comment">// which are the line pieces between two points of a linestring.</span>
+ <span class="keywordtype">double</span> d = <a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">distance</a>(p, <a name="_a11"></a><a class="code" href="structggl_1_1segment.html" title="Class segment: small containing two (templatized) point references.">segment&lt;point_2d &gt;</a>(ls.front(), ls.back()));
+ std::cout &lt;&lt; <span class="stringliteral">"distance: "</span> &lt;&lt; d &lt;&lt; std::endl;
+
+ <span class="comment">// Add some three points more, let's do it using a classic array.</span>
+ <span class="comment">// (See documentation for picture of this linestring)</span>
+ <span class="keyword">const</span> <span class="keywordtype">double</span> c[][2] = { {3.1, 3.1}, {4.9, 1.1}, {3.1, 1.9} };
+ <a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ls, c);
+ std::cout &lt;&lt; <span class="stringliteral">"appended: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) &lt;&lt; std::endl;
+
+ <span class="comment">// Output as iterator-pair on a vector</span>
+ {
+ std::vector&lt;point_2d&gt; v;
+ std::copy(ls.begin(), ls.end(), std::back_inserter(v));
+
+ std::cout
+ &lt;&lt; <span class="stringliteral">"as vector: "</span>
+ &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(v)
+ &lt;&lt; std::endl;
+
+ std::cout
+ &lt;&lt; <span class="stringliteral">"as it-pair: "</span>
+ &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(std::make_pair(v.begin(), v.end()))
+ &lt;&lt; std::endl;
+ }
+
+ <span class="comment">// All algorithms from std can be used: a linestring is a vector</span>
+ std::reverse(ls.begin(), ls.end());
+ std::cout &lt;&lt; <span class="stringliteral">"reversed: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) &lt;&lt; std::endl;
+ std::reverse(boost::begin(ls), boost::end(ls));
+
+ <span class="comment">// The other way, using a vector instead of a linestring, is also possible</span>
+ std::vector&lt;point_2d&gt; pv(ls.begin(), ls.end());
+ std::cout &lt;&lt; <span class="stringliteral">"length: "</span> &lt;&lt; <a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">length</a>(pv) &lt;&lt; std::endl;
+
+ <span class="comment">// If there are double points in the line, you can use unique to remove them</span>
+ <span class="comment">// So we add the last point, print, make a unique copy and print</span>
+ ls.push_back(ls.back());
+ ls.insert(ls.begin(), ls.front());
+ std::cout &lt;&lt; <span class="stringliteral">"extra duplicate points: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) &lt;&lt; std::endl;
+
+ {
+ <a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">linestring_2d</a> ls_copy;
+ std::unique_copy(ls.begin(), ls.end(), std::back_inserter(ls_copy),
+ point_equal&lt;point_2d&gt;());
+ ls = ls_copy;
+ std::cout &lt;&lt; <span class="stringliteral">"uniquecopy: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) &lt;&lt; std::endl;
+ }
+
+ <span class="comment">// Lines can be simplified. This removes points, but preserves the shape</span>
+ <a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">linestring_2d</a> ls_simplified;
+ <a name="a12"></a><a class="code" href="group__simplify.html#g188e72f668c33ac75ad08653625a7cbb" title="Simplify a geometry.">simplify</a>(ls, std::back_inserter(ls_simplified), 0.5);
+ std::cout &lt;&lt; <span class="stringliteral">"simplified: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls_simplified) &lt;&lt; std::endl;
+
+
+ <span class="comment">// for_each:</span>
+ <span class="comment">// 1) Lines can be visited with std::for_each</span>
+ <span class="comment">// 2) for_each_point is also defined for all geometries</span>
+ <span class="comment">// 3) for_each_segment is defined for all geometries to all segments</span>
+ <span class="comment">// 4) loop is defined for geometries to visit segments</span>
+ <span class="comment">// with state apart, and to be able to break out (not shown here)</span>
+ {
+ <a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">linestring_2d</a> lscopy = ls;
+ std::for_each(lscopy.begin(), lscopy.end(), translate_function&lt;point_2d&gt;);
+ <a name="a13"></a><a class="code" href="group__loop.html#g71cb52ab6490726f9030b464aa2f5e8a" title="Calls functor for geometry.">for_each_point</a>(lscopy, scale_functor&lt;point_2d&gt;());
+ <a class="code" href="group__loop.html#g71cb52ab6490726f9030b464aa2f5e8a" title="Calls functor for geometry.">for_each_point</a>(lscopy, translate_function&lt;point_2d&gt;);
+ std::cout &lt;&lt; <span class="stringliteral">"modified line: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(lscopy) &lt;&lt; std::endl;
+ }
+
+ <span class="comment">// Lines can be clipped using a clipping box. Clipped lines are added to the output iterator</span>
+ <a class="code" href="classggl_1_1box.html" title="Class box: defines a box made of two describing points.">box_2d</a> cb(<a name="a14"></a><a class="code" href="namespaceggl.html#440bc7037bbf1ba7118d6952d71b8e00">point_2d</a>(1.5, 1.5), <a class="code" href="namespaceggl.html#440bc7037bbf1ba7118d6952d71b8e00">point_2d</a>(4.5, 2.5));
+
+ std::vector&lt;linestring_2d&gt; clipped;
+ intersection&lt;linestring_2d&gt; (cb, ls, std::back_inserter(clipped));
+
+ <span class="comment">// Also possible: clip-output to a vector of vectors</span>
+ std::vector&lt;std::vector&lt;point_2d&gt; &gt; vector_out;
+ intersection&lt;std::vector&lt;point_2d&gt; &gt;(cb, ls, std::back_inserter(vector_out));
+
+ std::cout &lt;&lt; <span class="stringliteral">"clipped output as vector:"</span> &lt;&lt; std::endl;
+ <span class="keywordflow">for</span> (std::vector&lt;std::vector&lt;point_2d&gt; &gt;::const_iterator it
+ = vector_out.begin(); it != vector_out.end(); ++it)
+ {
+ std::cout &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(*it) &lt;&lt; std::endl;
+ }
+
+ <span class="comment">// Calculate the convex hull of the linestring</span>
+ <a name="_a15"></a><a class="code" href="classggl_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon_2d</a> hull;
+ <a name="a16"></a><a class="code" href="group__convex__hull.html#gc1989428c0a32cd2fd48272cd6833e18" title="Calculate the convex hull of a geometry.">convex_hull</a>(ls, std::back_inserter(hull.<a name="a17"></a><a class="code" href="classggl_1_1polygon.html#be04d3ead04813a25be1a219076358a8">outer</a>()));
+ std::cout &lt;&lt; <span class="stringliteral">"Convex hull:"</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(hull) &lt;&lt; std::endl;
+
+ <span class="comment">// All the above assumed 2D Cartesian linestrings. 3D is possible as well</span>
+ <span class="comment">// Let's define a 3D point ourselves, this time using 'float'</span>
+ <span class="keyword">typedef</span> <a name="_a18"></a><a class="code" href="classggl_1_1point.html" title="Basic point class, having coordinates defined in a neutral way.">point&lt;float, 3, cs::cartesian&gt;</a> <a name="_a19"></a><a class="code" href="structggl_1_1point__type.html" title="Meta-function which defines point type of any geometry.">point_type</a>;
+ <span class="keyword">typedef</span> <a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">linestring&lt;point_type&gt;</a> line_type;
+ line_type line3d;
+ line3d.push_back(make&lt;point_type&gt;(1,2,3));
+ line3d.push_back(make&lt;point_type&gt;(4,5,6));
+ line3d.push_back(make&lt;point_type&gt;(7,8,9));
+
+ <span class="comment">// Not all algorithms work on 3d lines. For example convex hull does NOT.</span>
+ <span class="comment">// But for example length, distance, simplify, envelope and stream do.</span>
+ std::cout &lt;&lt; <span class="stringliteral">"3D: length: "</span> &lt;&lt; <a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">length</a>(line3d) &lt;&lt; <span class="stringliteral">" line: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(line3d) &lt;&lt; std::endl;
+
+ <span class="comment">// With DSV you can also use other delimiters, e.g. JSON style</span>
+ std::cout &lt;&lt; <span class="stringliteral">"JSON: "</span>
+ &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls, <span class="stringliteral">", "</span>, <span class="stringliteral">"["</span>, <span class="stringliteral">"]"</span>, <span class="stringliteral">", "</span>, <span class="stringliteral">"[ "</span>, <span class="stringliteral">" ]"</span>)
+ &lt;&lt; std::endl;
+
+ <span class="keywordflow">return</span> 0;
+}
+</pre></div> </div>
+<hr size="1">
+<table width="100%">
+<tbody>
+<tr>
+<td align="left"><small>
+<p>October 13, 2009</p>
+</small></td>
+<td align="right">
+<small>Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
+Copyright © 2008-2009 Bruno Lalande, Paris<br>
+Copyright © 2009 Mateusz Loskot, Cadcorp, London<br>
+</small>
+</td>
+</tr>
+</tbody>
+</table>
+
+<address style="text-align: right;"><small>
+Documentation is generated by&nbsp;Doxygen
+</small></address>
+</body>
+</html>

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/03__polygon__example_8cpp-example.html
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/03__polygon__example_8cpp-example.html 2009-10-13 12:09:45 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,213 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Generic Geometry Library</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head>
+<body style="background-image: url(images/draft.png);">
+
+<table cellpadding="2" width="100%">
+<tbody>
+<tr>
+<td valign="top">
+<img alt="GGL" src="images/ggl-logo-big.png" height="80" width="200">
+&nbsp;&nbsp;
+</td>
+<td valign="top" align="right">
+<img alt="Boost C++ Libraries" src="images/proposed_boost.png" height="86" width="277">
+</td>
+</tr>
+</tbody>
+</table>
+<!-- Generated by Doxygen 1.5.9 -->
+<div class="navigation" id="top">
+ <div class="tabs">
+ <ul>
+ <li>Main Page</li>
+ <li>Related Pages</li>
+ <li>Modules</li>
+ <li>Namespaces</li>
+ <li>Classes</li>
+ <li>Files</li>
+ <li>Examples</li>
+ </ul>
+ </div>
+</div>
+<div class="contents">
+<h1>03_polygon_example.cpp</h1>The polygon example shows some examples of what can be done with polygons in the Generic Geometry Library: the outer ring and the inner rings how to calculate the area of a polygon how to get the centroid, and how to get an often more interesting label point how to correct the polygon such that it is clockwise and closed within: the well-known point in polygon algorithm how to use polygons which use another container, or which use different containers for points and for inner rings how polygons can be intersected, or clipped, using a clipping box<p>
+The illustrations below show the usage of the within algorithm and the intersection algorithm.<p>
+The within algorithm results in true if a point lies completly within a polygon. If it lies exactly on a border it is not considered as within and if it is inside a hole it is also not within the polygon. This is illustrated below, where only the point in the middle is within the polygon.<p>
+<div align="center">
+<img src="within_polygon.png" alt="within_polygon.png">
+</div>
+<p>
+The clipping algorithm, called intersection, is illustrated below:<p>
+<div align="center">
+<img src="clip_polygon.png" alt="clip_polygon.png">
+</div>
+<p>
+The yellow polygon, containing a hole, is clipped with the blue rectangle, resulting in a multi_polygon of three polygons, drawn in red. The hole is vanished.<p>
+include polygon_example.cpp<p>
+<div class="fragment"><pre class="fragment"><span class="comment">// Generic Geometry Library</span>
+<span class="comment">//</span>
+<span class="comment">// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.</span>
+<span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
+<span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
+<span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
+<span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
+<span class="comment">//</span>
+<span class="comment">// Polygon Example</span>
+
+<span class="preprocessor">#include &lt;algorithm&gt;</span> <span class="comment">// for reverse, unique</span>
+<span class="preprocessor">#include &lt;iostream&gt;</span>
+<span class="preprocessor">#include &lt;string&gt;</span>
+
+<span class="preprocessor">#include &lt;ggl/ggl.hpp&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="c__array__cartesian_8hpp.html">ggl/geometries/adapted/c_array_cartesian.hpp</a>&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="std__as__linestring_8hpp.html">ggl/geometries/adapted/std_as_linestring.hpp</a>&gt;</span>
+
+std::string boolstr(<span class="keywordtype">bool</span> v)
+{
+ <span class="keywordflow">return</span> v ? <span class="stringliteral">"true"</span> : <span class="stringliteral">"false"</span>;
+}
+
+<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
+{
+ <span class="keyword">using namespace </span>ggl;
+
+ <span class="comment">// Define a polygon and fill the outer ring.</span>
+ <span class="comment">// In most cases you will read it from a file or database</span>
+ <a name="_a0"></a><a class="code" href="classggl_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon_2d</a> poly;
+ {
+ <span class="keyword">const</span> <span class="keywordtype">double</span> coor[][2] = {
+ {2.0, 1.3}, {2.4, 1.7}, {2.8, 1.8}, {3.4, 1.2}, {3.7, 1.6},
+ {3.4, 2.0}, {4.1, 3.0}, {5.3, 2.6}, {5.4, 1.2}, {4.9, 0.8}, {2.9, 0.7},
+ {2.0, 1.3} <span class="comment">// closing point is opening point</span>
+ };
+ <a name="a1"></a><a class="code" href="group__access.html#ge58b5c7b493d0112202dc139af200c73" title="assign two values to a 2D point">assign</a>(poly, coor);
+ }
+
+ <span class="comment">// Polygons should be closed, and directed clockwise. If you're not sure if that is the case,</span>
+ <span class="comment">// call the correct algorithm</span>
+ <a name="a2"></a><a class="code" href="namespaceggl.html#de63f8bac74d1e2a56c2d2712eceb8af">correct</a>(poly);
+
+ <span class="comment">// Polygons can be streamed as text</span>
+ <span class="comment">// (or more precisely: as DSV (delimiter separated values))</span>
+ std::cout &lt;&lt; <a name="a3"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly) &lt;&lt; std::endl;
+
+ <span class="comment">// As with lines, bounding box of polygons can be calculated</span>
+ <a name="_a4"></a><a class="code" href="classggl_1_1box.html" title="Class box: defines a box made of two describing points.">box_2d</a> b;
+ <a name="a5"></a><a class="code" href="group__envelope.html#g376bdcefa676ef2b705656b690767b36" title="Calculate envelope of a geometry, using a specified strategy.">envelope</a>(poly, b);
+ std::cout &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(b) &lt;&lt; std::endl;
+
+ <span class="comment">// The area of the polygon can be calulated</span>
+ std::cout &lt;&lt; <span class="stringliteral">"area: "</span> &lt;&lt; <a name="a6"></a><a class="code" href="group__area.html#g3ebfdefe9c756498730b6d93b83338b3" title="Calculate area of a geometry.">area</a>(poly) &lt;&lt; std::endl;
+
+ <span class="comment">// And the centroid, which is the center of gravity</span>
+ <a name="_a7"></a><a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> cent;
+ <a name="a8"></a><a class="code" href="group__centroid.html#g2b743cdd7177313b561780ba87c633cd" title="Calculate centroid.">centroid</a>(poly, cent);
+ std::cout &lt;&lt; <span class="stringliteral">"centroid: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(cent) &lt;&lt; std::endl;
+
+ <span class="comment">// Actually in most cases you don't want the centroid, which is only defined for polygons.</span>
+ <span class="comment">// You want a nice labelpoint instead. Call labelpoint in those cases, which is defined</span>
+ <span class="comment">// for all geometries</span>
+ <span class="comment">/* not yet in preview, syntax might change</span>
+<span class="comment"> std::cout &lt;&lt; "labelpoints: ";</span>
+<span class="comment"> label_info&lt;0&gt;(poly, , std::ostream_iterator&lt;point_2d&gt;(std::cout, " "));</span>
+<span class="comment"> std::cout &lt;&lt; std::endl;</span>
+<span class="comment"> */</span>
+
+ <span class="comment">// The number of points have to called per ring separately</span>
+ std::cout &lt;&lt; <span class="stringliteral">"number of points in outer ring: "</span> &lt;&lt; poly.<a name="a9"></a><a class="code" href="classggl_1_1polygon.html#be04d3ead04813a25be1a219076358a8">outer</a>().size() &lt;&lt; std::endl;
+
+ <span class="comment">// Polygons can have one or more inner rings, also called holes, donuts, islands, interior rings.</span>
+ <span class="comment">// Let's add one</span>
+ {
+ poly.<a name="a10"></a><a class="code" href="classggl_1_1polygon.html#0d41c7b42a1444fdc759550644c7924e">inners</a>().resize(1);
+ <a name="_a11"></a><a class="code" href="classggl_1_1linear__ring.html" title="A linear_ring (linear linear_ring) is a closed line which should not be selfintersecting...">linear_ring&lt;point_2d&gt;</a>&amp; inner = poly.<a class="code" href="classggl_1_1polygon.html#0d41c7b42a1444fdc759550644c7924e">inners</a>().back();
+
+ <span class="keyword">const</span> <span class="keywordtype">double</span> coor[][2] = { {4.0, 2.0}, {4.2, 1.4}, {4.8, 1.9}, {4.4, 2.2}, {4.0, 2.0} };
+ <a class="code" href="group__access.html#ge58b5c7b493d0112202dc139af200c73" title="assign two values to a 2D point">assign</a>(inner, coor);
+ }
+
+ <a class="code" href="namespaceggl.html#de63f8bac74d1e2a56c2d2712eceb8af">correct</a>(poly);
+
+ std::cout &lt;&lt; <span class="stringliteral">"with inner ring:"</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly) &lt;&lt; std::endl;
+ <span class="comment">// The area of the polygon is changed of course</span>
+ std::cout &lt;&lt; <span class="stringliteral">"new area of polygon: "</span> &lt;&lt; <a class="code" href="group__area.html#g3ebfdefe9c756498730b6d93b83338b3" title="Calculate area of a geometry.">area</a>(poly) &lt;&lt; std::endl;
+ <a class="code" href="group__centroid.html#g2b743cdd7177313b561780ba87c633cd" title="Calculate centroid.">centroid</a>(poly, cent);
+ std::cout &lt;&lt; <span class="stringliteral">"new centroid: "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(cent) &lt;&lt; std::endl;
+
+ <span class="comment">// You can test whether points are within a polygon</span>
+ std::cout &lt;&lt; <span class="stringliteral">"point in polygon:"</span>
+ &lt;&lt; <span class="stringliteral">" p1: "</span> &lt;&lt; boolstr(<a name="a12"></a><a class="code" href="group__boolean__relations.html#g95d6465a12b762c77df41369a039f6dc" title="Within check.">within</a>(make&lt;point_2d&gt;(3.0, 2.0), poly))
+ &lt;&lt; <span class="stringliteral">" p2: "</span> &lt;&lt; boolstr(<a class="code" href="group__boolean__relations.html#g95d6465a12b762c77df41369a039f6dc" title="Within check.">within</a>(make&lt;point_2d&gt;(3.7, 2.0), poly))
+ &lt;&lt; <span class="stringliteral">" p3: "</span> &lt;&lt; boolstr(<a class="code" href="group__boolean__relations.html#g95d6465a12b762c77df41369a039f6dc" title="Within check.">within</a>(make&lt;point_2d&gt;(4.4, 2.0), poly))
+ &lt;&lt; std::endl;
+
+ <span class="comment">// You can call for_each or for_each_segment on polygons to, this will visit all points / segments</span>
+ <span class="comment">// in outer ring and inner rings</span>
+ <span class="comment">//for_each(poly, f);</span>
+
+ <span class="comment">// As with linestrings and points, you can derive from polygon to add, for example,</span>
+ <span class="comment">// fill color and stroke color. Or SRID (spatial reference ID). Or Z-value. Or a property map.</span>
+ <span class="comment">// We don't show this here.</span>
+
+ <span class="comment">// Clip the polygon using a bounding box</span>
+ <a class="code" href="classggl_1_1box.html" title="Class box: defines a box made of two describing points.">box_2d</a> cb(make&lt;point_2d&gt;(1.5, 1.5), make&lt;point_2d&gt;(4.5, 2.5));
+ <span class="keyword">typedef</span> std::vector&lt;polygon_2d &gt; polygon_list;
+ polygon_list v;
+
+ intersection&lt;polygon_2d&gt;(cb, poly, std::back_inserter(v));
+ std::cout &lt;&lt; <span class="stringliteral">"Clipped output polygons"</span> &lt;&lt; std::endl;
+ <span class="keywordflow">for</span> (polygon_list::const_iterator it = v.begin(); it != v.end(); ++it)
+ {
+ std::cout &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(*it) &lt;&lt; std::endl;
+ }
+
+ <a class="code" href="classggl_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon_2d</a> hull;
+ <a name="a13"></a><a class="code" href="group__convex__hull.html#gc1989428c0a32cd2fd48272cd6833e18" title="Calculate the convex hull of a geometry.">convex_hull</a>(poly, std::back_inserter(hull.<a class="code" href="classggl_1_1polygon.html#be04d3ead04813a25be1a219076358a8">outer</a>()));
+ std::cout &lt;&lt; <span class="stringliteral">"Convex hull:"</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(hull) &lt;&lt; std::endl;
+
+ <span class="comment">// If you really want:</span>
+ <span class="comment">// You don't have to use a vector, you can define a polygon with a deque</span>
+ <span class="comment">// You can specify the container for the points and for the inner rings independantly</span>
+
+ <span class="keyword">typedef</span> <a class="code" href="classggl_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon&lt;point_2d, std::vector, std::deque&gt;</a> polygon_type;
+ polygon_type poly2;
+ <a name="_a14"></a><a class="code" href="structggl_1_1ring__type.html" title="Meta-function which defines ring type of (multi)polygon geometry.">ring_type&lt;polygon_type&gt;::type</a>&amp; ring = <a name="a15"></a><a class="code" href="group__access.html#gf92470d0612da7f0e118d296e7fcfe01" title="Function to get the exterior_ring ring of a polygon.">exterior_ring</a>(poly2);
+ <a name="a16"></a><a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ring, make&lt;point_2d&gt;(2.8, 1.9));
+ <a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ring, make&lt;point_2d&gt;(2.9, 2.4));
+ <a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ring, make&lt;point_2d&gt;(3.3, 2.2));
+ <a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ring, make&lt;point_2d&gt;(3.2, 1.8));
+ <a class="code" href="group__access.html#g8cfdebdb885a95bacb1305744f0d0d7c" title="Appends one or more points to a linestring, linear-ring, polygon, multi.">append</a>(ring, make&lt;point_2d&gt;(2.8, 1.9));
+ std::cout &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly2) &lt;&lt; std::endl;
+
+ <span class="keywordflow">return</span> 0;
+}
+</pre></div> </div>
+<hr size="1">
+<table width="100%">
+<tbody>
+<tr>
+<td align="left"><small>
+<p>October 13, 2009</p>
+</small></td>
+<td align="right">
+<small>Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
+Copyright © 2008-2009 Bruno Lalande, Paris<br>
+Copyright © 2009 Mateusz Loskot, Cadcorp, London<br>
+</small>
+</td>
+</tr>
+</tbody>
+</table>
+
+<address style="text-align: right;"><small>
+Documentation is generated by&nbsp;Doxygen
+</small></address>
+</body>
+</html>

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/06__transformation__example_8cpp-example.html
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/06__transformation__example_8cpp-example.html 2009-10-13 12:09:45 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,112 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Generic Geometry Library</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head>
+<body style="background-image: url(images/draft.png);">
+
+<table cellpadding="2" width="100%">
+<tbody>
+<tr>
+<td valign="top">
+<img alt="GGL" src="images/ggl-logo-big.png" height="80" width="200">
+&nbsp;&nbsp;
+</td>
+<td valign="top" align="right">
+<img alt="Boost C++ Libraries" src="images/proposed_boost.png" height="86" width="277">
+</td>
+</tr>
+</tbody>
+</table>
+<!-- Generated by Doxygen 1.5.9 -->
+<div class="navigation" id="top">
+ <div class="tabs">
+ <ul>
+ <li>Main Page</li>
+ <li>Related Pages</li>
+ <li>Modules</li>
+ <li>Namespaces</li>
+ <li>Classes</li>
+ <li>Files</li>
+ <li>Examples</li>
+ </ul>
+ </div>
+</div>
+<div class="contents">
+<h1>06_transformation_example.cpp</h1>This sample demonstrates the usage of transformations in the Generic Geometry Library. Behind the screens this is done using with the uBLAS matrix/vector library.<p>
+<div class="fragment"><pre class="fragment"><span class="comment">// Generic Geometry Library</span>
+<span class="comment">//</span>
+<span class="comment">// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.</span>
+<span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
+<span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
+<span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
+<span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
+<span class="comment">//</span>
+<span class="comment">// Transformation Example</span>
+
+<span class="preprocessor">#include &lt;iostream&gt;</span>
+
+<span class="preprocessor">#include &lt;ggl/ggl.hpp&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="c__array__cartesian_8hpp.html">ggl/geometries/adapted/c_array_cartesian.hpp</a>&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="std__as__linestring_8hpp.html">ggl/geometries/adapted/std_as_linestring.hpp</a>&gt;</span>
+
+<span class="keywordtype">int</span> main()
+{
+ <span class="keyword">using namespace </span>ggl;
+
+ <a name="_a0"></a><a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> p(1, 1);
+ <a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">point_2d</a> p2;
+
+ <span class="comment">// Example: translate a point over (5,5)</span>
+ <a name="_a1"></a><a class="code" href="structggl_1_1strategy_1_1transform_1_1translate__transformer.html" title="Transformation strategy to translate in Cartesian system.">strategy::transform::translate_transformer&lt;point_2d, point_2d&gt;</a> translate(5, 5);
+
+ <a name="a2"></a><a class="code" href="group__transform.html#ge33cee2442ebab063f9c987121cd3500" title="Transforms from one geometry to another geometry using a strategy.">transform</a>(p, p2, translate);
+ std::cout &lt;&lt; <span class="stringliteral">"transformed point "</span> &lt;&lt; <a name="a3"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(p2) &lt;&lt; std::endl;
+
+ <span class="comment">// Transform a polygon</span>
+ <a name="_a4"></a><a class="code" href="classggl_1_1polygon.html" title="The polygon contains an outer ring and zero or more inner rings.">polygon_2d</a> poly, poly2;
+ <span class="keyword">const</span> <span class="keywordtype">double</span> coor[][2] = { {0, 0}, {0, 7}, {2, 2}, {2, 0}, {0, 0} };
+ <span class="comment">// note that for this syntax you have to include the two</span>
+ <span class="comment">// include files above (c_array_cartesian.hpp, std_as_linestring.hpp)</span>
+ <a name="a5"></a><a class="code" href="group__access.html#ge58b5c7b493d0112202dc139af200c73" title="assign two values to a 2D point">assign</a>(poly, coor);
+ <span class="comment">//read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly);</span>
+ <a class="code" href="group__transform.html#ge33cee2442ebab063f9c987121cd3500" title="Transforms from one geometry to another geometry using a strategy.">transform</a>(poly, poly2, translate);
+
+ std::cout &lt;&lt; <span class="stringliteral">"source polygon "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly) &lt;&lt; std::endl;
+ std::cout &lt;&lt; <span class="stringliteral">"transformed polygon "</span> &lt;&lt; <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly2) &lt;&lt; std::endl;
+
+ <span class="comment">// Many more transformations are possible:</span>
+ <span class="comment">// - from Cartesian to Spherical coordinate systems and back</span>
+ <span class="comment">// - from Cartesian to Cartesian (mapping, affine transformations) and back (inverse)</span>
+ <span class="comment">// - Map Projections</span>
+ <span class="comment">// - from Degree to Radian and back in spherical or geographic coordinate systems</span>
+
+ <span class="keywordflow">return</span> 0;
+}
+</pre></div> </div>
+<hr size="1">
+<table width="100%">
+<tbody>
+<tr>
+<td align="left"><small>
+<p>October 13, 2009</p>
+</small></td>
+<td align="right">
+<small>Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
+Copyright © 2008-2009 Bruno Lalande, Paris<br>
+Copyright © 2009 Mateusz Loskot, Cadcorp, London<br>
+</small>
+</td>
+</tr>
+</tbody>
+</table>
+
+<address style="text-align: right;"><small>
+Documentation is generated by&nbsp;Doxygen
+</small></address>
+</body>
+</html>

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07__graph__route__example_8cpp-example.html
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07__graph__route__example_8cpp-example.html 2009-10-13 12:09:45 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,482 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Generic Geometry Library</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head>
+<body style="background-image: url(images/draft.png);">
+
+<table cellpadding="2" width="100%">
+<tbody>
+<tr>
+<td valign="top">
+<img alt="GGL" src="images/ggl-logo-big.png" height="80" width="200">
+&nbsp;&nbsp;
+</td>
+<td valign="top" align="right">
+<img alt="Boost C++ Libraries" src="images/proposed_boost.png" height="86" width="277">
+</td>
+</tr>
+</tbody>
+</table>
+<!-- Generated by Doxygen 1.5.9 -->
+<div class="navigation" id="top">
+ <div class="tabs">
+ <ul>
+ <li>Main Page</li>
+ <li>Related Pages</li>
+ <li>Modules</li>
+ <li>Namespaces</li>
+ <li>Classes</li>
+ <li>Files</li>
+ <li>Examples</li>
+ </ul>
+ </div>
+</div>
+<div class="contents">
+<h1>07_graph_route_example.cpp</h1>The graph route example shows how GGL can be combined with Boost.Graph. The sample does the following things:<ul>
+<li>it reads roads (included in the distribution, stored on disk in the form of a text file containing geometries and names)</li><li>it reads cities</li><li>it creates a graph from the roads</li><li>it connects each city to the nearest vertex in the graph</li><li>it calculates the shortest route between each pair of cities</li><li>it outputs the distance over the road, and also of the air</li><li>it creates an SVG image with the roads, the cities, and the first calculated route</li></ul>
+<p>
+Note that this example is useful, but it is only an example. It could be built in many different ways. For example:<ul>
+<li>the roads/cities could be read from a database using SOCI, or from a shapefile using shapelib</li><li>it could support oneway roads and roads on different levels (disconnected bridges)</li><li>it currently uses tuples but that could be anything</li><li>etc</li></ul>
+<p>
+The SVG looks like: <div align="center">
+<img src="07_graph_route_example_svg.png" alt="07_graph_route_example_svg.png">
+</div>
+<p>
+The output screen looks like: <div align="center">
+<img src="07_graph_route_example_text.png" alt="07_graph_route_example_text.png">
+</div>
+<p>
+<div class="fragment"><pre class="fragment"><span class="comment">// Generic Geometry Library</span>
+<span class="comment">//</span>
+<span class="comment">// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.</span>
+<span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
+<span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
+<span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
+<span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
+<span class="comment">//</span>
+<span class="comment">// Example showing GGL combined with Boost.Graph, calculating shortest routes</span>
+<span class="comment">// input: two WKT's, provided in subfolder data</span>
+<span class="comment">// output: text, + an SVG, displayable in e.g. Firefox)</span>
+
+<span class="preprocessor">#include &lt;iostream&gt;</span>
+<span class="preprocessor">#include &lt;fstream&gt;</span>
+<span class="preprocessor">#include &lt;iomanip&gt;</span>
+<span class="preprocessor">#include &lt;limits&gt;</span>
+
+<span class="preprocessor">#include &lt;boost/tuple/tuple.hpp&gt;</span>
+<span class="preprocessor">#include &lt;boost/foreach.hpp&gt;</span>
+
+<span class="preprocessor">#include &lt;boost/graph/adjacency_list.hpp&gt;</span>
+<span class="preprocessor">#include &lt;boost/graph/dijkstra_shortest_paths.hpp&gt;</span>
+
+<span class="preprocessor">#include &lt;ggl/ggl.hpp&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="less_8hpp.html">ggl/util/less.hpp</a>&gt;</span>
+<span class="preprocessor">#include &lt;<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>&gt;</span>
+
+
+<span class="comment">// Yes, this example currently uses some extensions:</span>
+
+ <span class="comment">// For input:</span>
+<span class="preprocessor"> #include &lt;ggl/extensions/gis/io/wkt/read_wkt.hpp&gt;</span>
+
+ <span class="comment">// For output:</span>
+<span class="preprocessor"> #include &lt;<a class="code" href="write__svg_8hpp.html">ggl/extensions/io/svg/write_svg.hpp</a>&gt;</span>
+
+ <span class="comment">// For distance-calculations over the Earth:</span>
+<span class="preprocessor"> #include &lt;ggl/extensions/gis/geographic/strategies/andoyer.hpp&gt;</span>
+
+
+
+<span class="comment">// Read an ASCII file containing WKT's, fill a vector of tuples</span>
+<span class="comment">// The tuples consist of at least &lt;0&gt; a geometry and &lt;1&gt; an identifying string</span>
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Geometry, <span class="keyword">typename</span> Tuple, <span class="keyword">typename</span> Box&gt;
+<span class="keywordtype">void</span> read_wkt(std::string <span class="keyword">const</span>&amp; filename, std::vector&lt;Tuple&gt;&amp; tuples, Box&amp; box)
+{
+ std::ifstream cpp_file(filename.c_str());
+ <span class="keywordflow">if</span> (cpp_file.is_open())
+ {
+ <span class="keywordflow">while</span> (! cpp_file.eof() )
+ {
+ std::string line;
+ std::getline(cpp_file, line);
+ Geometry geometry;
+ boost::trim(line);
+ <span class="keywordflow">if</span> (! line.empty() &amp;&amp; ! boost::starts_with(line, <span class="stringliteral">"#"</span>))
+ {
+ std::string name;
+
+ <span class="comment">// Split at ';', if any</span>
+ std::string::size_type pos = line.find(<span class="stringliteral">";"</span>);
+ <span class="keywordflow">if</span> (pos != std::string::npos)
+ {
+ name = line.substr(pos + 1);
+ line.erase(pos);
+
+ boost::trim(line);
+ boost::trim(name);
+ }
+
+ Geometry geometry;
+ ggl::read_wkt(line, geometry);
+
+ Tuple tuple(geometry, name);
+
+ tuples.push_back(tuple);
+ <a name="a0"></a><a class="code" href="group__combine.html#gf2336ad085ad8b79cde5a759ab229199" title="Combines a box with another geometry (box, point).">ggl::combine</a>(box, ggl::make_envelope&lt;Box&gt;(geometry,
+ <span class="comment">// Todo: necessary for latlong, but should not be, solve this</span>
+ <a name="_a1"></a><a class="code" href="structggl_1_1strategy_1_1envelope_1_1combine__xy.html">ggl::strategy::envelope::combine_xy</a>
+ &lt;
+ <span class="keyword">typename</span> <a name="_a2"></a><a class="code" href="structggl_1_1point__type.html" title="Meta-function which defines point type of any geometry.">ggl::point_type&lt;Geometry&gt;::type</a>,
+ Box
+ &gt;()));
+ }
+ }
+ }
+}
+
+<span class="comment">// Boilerplate code to initialize the SVG XML.</span>
+<span class="comment">// Note that this is (on purpose) not part of the library but of this sample.</span>
+<span class="comment">// GGL itself only streams small pieces of SVG, in any coordinate system</span>
+<span class="keywordtype">void</span> svg_header(std::ofstream&amp; stream)
+{
+ stream &lt;&lt; <span class="stringliteral">"&lt;?xml version=\"1.0\" standalone=\"no\"?&gt;"</span> &lt;&lt; std::endl;
+ stream &lt;&lt; <span class="stringliteral">"&lt;!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\""</span> &lt;&lt; std::endl;
+ stream &lt;&lt; <span class="stringliteral">"\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"&gt;"</span> &lt;&lt; std::endl;
+
+ stream &lt;&lt; <span class="stringliteral">"&lt;svg width=\"100%\" height=\"100%\" version=\"1.1\""</span> &lt;&lt; std::endl;
+ stream &lt;&lt; <span class="stringliteral">"xmlns=\"http://www.w3.org/2000/svg\"&gt;"</span> &lt;&lt; std::endl;
+}
+
+
+<span class="comment">// Code to define properties for Boost Graph's</span>
+<span class="keyword">enum</span> vertex_ggl_property_t { vertex_ggl_property };
+<span class="keyword">enum</span> edge_ggl_property_t { edge_ggl_property };
+<span class="keyword">namespace </span>boost
+{
+ BOOST_INSTALL_PROPERTY(vertex, ggl_property);
+ BOOST_INSTALL_PROPERTY(edge, ggl_property);
+}
+
+<span class="comment">// Define properties for vertex</span>
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Po<span class="keywordtype">int</span>&gt;
+<span class="keyword">struct </span>ggl_vertex_property
+{
+ ggl_vertex_property()
+ {
+ <a name="a3"></a><a class="code" href="group__access.html#g2fba6ded1fb6ecc7dba897b55c70f2d0" title="assign zero values to a box, point">ggl::assign_zero</a>(location);
+ }
+ ggl_vertex_property(Point <span class="keyword">const</span>&amp; loc)
+ {
+ location = loc;
+ }
+
+ Point location;
+};
+
+<span class="comment">// Define properties for edge</span>
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Line<span class="keywordtype">string</span>&gt;
+<span class="keyword">struct </span>ggl_edge_property
+{
+ ggl_edge_property(Linestring <span class="keyword">const</span>&amp; line)
+ : m_line(line)
+ {
+ m_length = <a name="a4"></a><a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">ggl::length</a>(line);
+ }
+
+ <span class="keyword">inline</span> operator double()<span class="keyword"> const</span>
+<span class="keyword"> </span>{
+ <span class="keywordflow">return</span> m_length;
+ }
+
+ <span class="keyword">inline</span> Linestring <span class="keyword">const</span>&amp; line()<span class="keyword"> const</span>
+<span class="keyword"> </span>{
+ <span class="keywordflow">return</span> m_line;
+ }
+
+<span class="keyword">private</span> :
+ <span class="keywordtype">double</span> m_length;
+ Linestring m_line;
+};
+
+<span class="comment">// Utility function to add a vertex to a graph. It might exist already. Then do not insert,</span>
+<span class="comment">// but return vertex descriptor back. It might not exist. Then add it (and return).</span>
+<span class="comment">// To efficiently handle this, a std::map is used.</span>
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> M, <span class="keyword">typename</span> K, <span class="keyword">typename</span> G&gt;
+<span class="keyword">inline</span> <span class="keyword">typename</span> boost::graph_traits&lt;G&gt;::vertex_descriptor find_or_insert(M&amp; map, K <span class="keyword">const</span>&amp; key, G&amp; graph)
+{
+ <span class="keyword">typename</span> M::const_iterator it = map.find(key);
+ <span class="keywordflow">if</span> (it == map.end())
+ {
+ <span class="comment">// Add a vertex to the graph</span>
+ <span class="keyword">typename</span> boost::graph_traits&lt;G&gt;::vertex_descriptor new_vertex
+ = boost::add_vertex(graph);
+
+ <span class="comment">// Set the property (= location)</span>
+ boost::put(<a name="a5"></a><a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(vertex_ggl_property, graph), new_vertex,
+ ggl_vertex_property&lt;typename M::key_type&gt;(key));
+
+ <span class="comment">// Add to the map, using POINT as key</span>
+ map[key] = new_vertex;
+ <span class="keywordflow">return</span> new_vertex;
+ }
+ <span class="keywordflow">return</span> it-&gt;second;
+}
+
+<span class="keyword">template</span>
+&lt;
+ <span class="keyword">typename</span> Line,
+ <span class="keyword">typename</span> Graph,
+ <span class="keyword">typename</span> RoadTupleVector,
+ <span class="keyword">typename</span> CityTupleVector
+&gt;
+<span class="keywordtype">void</span> add_roads_and_connect_cities(Graph&amp; graph,
+ RoadTupleVector <span class="keyword">const</span>&amp; roads,
+ CityTupleVector&amp; cities)
+{
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structggl_1_1point__type.html" title="Meta-function which defines point type of any geometry.">ggl::point_type&lt;Line&gt;::type</a> point_type;
+
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor vertex_type;
+
+ <span class="comment">// Define a map to be used during graph filling</span>
+ <span class="comment">// Maps from point to vertex-id's</span>
+ <span class="keyword">typedef</span> std::map&lt;point_type, vertex_type, ggl::less&lt;point_type&gt; &gt; map_type;
+ map_type map;
+
+
+ <span class="comment">// Fill the graph</span>
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::range_value&lt;RoadTupleVector&gt;::type road_type;
+ BOOST_FOREACH(road_type <span class="keyword">const</span>&amp; road, roads)
+ {
+ <span class="comment">// Find or add begin/end point of these line</span>
+ vertex_type from = find_or_insert(map, road.get&lt;0&gt;().front(), graph);
+ vertex_type to = find_or_insert(map, road.get&lt;0&gt;().back(), graph);
+ boost::add_edge(from, to, ggl_edge_property&lt;Line&gt;(road.get&lt;0&gt;()), graph);
+ }
+
+ <span class="comment">// Find nearest graph vertex for each city, using the map</span>
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::range_value&lt;CityTupleVector&gt;::type city_type;
+ BOOST_FOREACH(city_type&amp; city, cities)
+ {
+ <span class="keywordtype">double</span> min_distance = 1e300;
+ <span class="keywordflow">for</span>(<span class="keyword">typename</span> map_type::const_iterator it = map.begin(); it != map.end(); ++it)
+ {
+ <span class="keywordtype">double</span> dist = <a name="a6"></a><a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">ggl::distance</a>(it-&gt;first, city.get&lt;0&gt;());
+ <span class="keywordflow">if</span> (dist &lt; min_distance)
+ {
+ min_distance = dist;
+ <span class="comment">// Set the vertex</span>
+ city.get&lt;2&gt;() = it-&gt;second;
+ }
+ }
+ }
+}
+
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Graph, <span class="keyword">typename</span> Route&gt;
+<span class="keyword">inline</span> <span class="keywordtype">void</span> add_edge_to_route(Graph <span class="keyword">const</span>&amp; graph,
+ <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor vertex1,
+ <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor vertex2,
+ Route&amp; route)
+{
+ std::pair
+ &lt;
+ <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::edge_descriptor,
+ <span class="keywordtype">bool</span>
+ &gt; opt_edge = boost::edge(vertex1, vertex2, graph);
+ <span class="keywordflow">if</span> (opt_edge.second)
+ {
+ <span class="comment">// Get properties of edge and of vertex</span>
+ ggl_edge_property&lt;Route&gt; <span class="keyword">const</span>&amp; edge_prop =
+ <a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(<a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(edge_ggl_property, graph), opt_edge.first);
+
+ ggl_vertex_property&lt;typename ggl::point_type&lt;Route&gt;::type&gt; <span class="keyword">const</span>&amp; vertex_prop =
+ <a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(<a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(vertex_ggl_property, graph), vertex2);
+
+ <span class="comment">// Depending on how edge connects to vertex, copy it forward or backward</span>
+ <span class="keywordflow">if</span> (<a name="a7"></a><a class="code" href="group__boolean__relations.html#g122b1fd835cee0742da7c97dfdda94c5" title="Calculate if two geometries are equals.">ggl::equals</a>(edge_prop.line().front(), vertex_prop.location))
+ {
+ std::copy(edge_prop.line().begin(), edge_prop.line().end(),
+ std::back_inserter(route));
+ }
+ <span class="keywordflow">else</span>
+ {
+ std::reverse_copy(edge_prop.line().begin(), edge_prop.line().end(),
+ std::back_inserter(route));
+ }
+ }
+}
+
+
+<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Graph, <span class="keyword">typename</span> Route&gt;
+<span class="keyword">inline</span> <span class="keywordtype">void</span> build_route(Graph <span class="keyword">const</span>&amp; graph,
+ std::vector&lt;<span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor&gt; <span class="keyword">const</span>&amp; predecessors,
+ <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor vertex1,
+ <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor vertex2,
+ Route&amp; route)
+{
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::graph_traits&lt;Graph&gt;::vertex_descriptor vertex_type;
+ vertex_type pred = predecessors[vertex2];
+
+ add_edge_to_route(graph, vertex2, pred, route);
+ <span class="keywordflow">while</span> (pred != vertex1)
+ {
+ add_edge_to_route(graph, predecessors[pred], pred, route);
+ pred = predecessors[pred];
+ }
+}
+
+
+<span class="keywordtype">int</span> main()
+{
+ <span class="comment">// Define a point in the Geographic coordinate system</span>
+ <span class="keyword">typedef</span> <a name="_a8"></a><a class="code" href="classggl_1_1point.html" title="Basic point class, having coordinates defined in a neutral way.">ggl::point&lt;double, 2, ggl::cs::geographic&lt;ggl::degree&gt;</a> &gt; point_type;
+
+ <span class="keyword">typedef</span> <a name="_a9"></a><a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">ggl::linestring&lt;point_type&gt;</a> line_type;
+
+ <span class="comment">// Define the graph, lateron containing the road network</span>
+ <span class="keyword">typedef</span> boost::adjacency_list
+ &lt;
+ boost::vecS, boost::vecS, boost::undirectedS
+ , boost::property&lt;vertex_ggl_property_t, ggl_vertex_property&lt;point_type&gt; &gt;
+ , boost::property&lt;edge_ggl_property_t, ggl_edge_property&lt;line_type&gt; &gt;
+ &gt; graph_type;
+
+ <span class="keyword">typedef</span> boost::graph_traits&lt;graph_type&gt;::vertex_descriptor vertex_type;
+
+
+ <span class="comment">// Init a bounding box, lateron used to define SVG map</span>
+ <a name="_a10"></a><a class="code" href="classggl_1_1box.html" title="Class box: defines a box made of two describing points.">ggl::box_2d</a> box;
+ <a name="a11"></a><a class="code" href="group__access.html#gaa27514a7d1c16133d28dd5601cd32fd" title="assign to a box inverse infinite">ggl::assign_inverse</a>(box);
+
+ <span class="comment">// Read the cities</span>
+ <span class="keyword">typedef</span> boost::tuple&lt;point_type, std::string, vertex_type&gt; city_type;
+ std::vector&lt;city_type&gt; cities;
+ read_wkt&lt;point_type&gt;(<span class="stringliteral">"data/cities.wkt"</span>, cities, box);
+
+ <span class="comment">// Read the road network</span>
+ <span class="keyword">typedef</span> boost::tuple&lt;line_type, std::string&gt; road_type;
+ std::vector&lt;road_type&gt; roads;
+ read_wkt&lt;line_type&gt;(<span class="stringliteral">"data/roads.wkt"</span>, roads, box);
+
+
+ graph_type graph;
+
+ <span class="comment">// Add roads and connect cities</span>
+ add_roads_and_connect_cities&lt;line_type&gt;(graph, roads, cities);
+
+ <span class="keywordtype">double</span> <span class="keyword">const</span> km = 1000.0;
+ std::cout &lt;&lt; <span class="stringliteral">"distances, all in KM"</span> &lt;&lt; std::endl
+ &lt;&lt; std::fixed &lt;&lt; std::setprecision(0);
+
+ <span class="comment">// Main functionality: calculate shortest routes from/to all cities</span>
+
+ <span class="comment">// For the first one, the complete route is stored as a linestring</span>
+ <span class="keywordtype">bool</span> first = <span class="keyword">true</span>;
+ line_type route;
+
+ <span class="keywordtype">int</span> <span class="keyword">const</span> n = boost::num_vertices(graph);
+ BOOST_FOREACH(city_type <span class="keyword">const</span>&amp; city1, cities)
+ {
+ std::vector&lt;vertex_type&gt; predecessors(n);
+ std::vector&lt;double&gt; costs(n);
+
+ <span class="comment">// Call Dijkstra (without named-parameter to be compatible with all VC)</span>
+ boost::dijkstra_shortest_paths(graph, city1.get&lt;2&gt;(),
+ &amp;predecessors[0], &amp;costs[0],
+ <a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(edge_ggl_property, graph),
+ <a class="code" href="group__access.html#g6cf833a7f9622af2fc05fd94aa61153f" title="get a coordinate value of a point / nsphere">boost::get</a>(boost::vertex_index, graph),
+ std::less&lt;double&gt;(), std::plus&lt;double&gt;(),
+ (std::numeric_limits&lt;double&gt;::max)(), <span class="keywordtype">double</span>(),
+ boost::dijkstra_visitor&lt;boost::null_visitor&gt;());
+
+ BOOST_FOREACH(city_type <span class="keyword">const</span>&amp; city2, cities)
+ {
+ <span class="keywordflow">if</span> (! <a class="code" href="group__boolean__relations.html#g122b1fd835cee0742da7c97dfdda94c5" title="Calculate if two geometries are equals.">boost::equals</a>(city1.get&lt;1&gt;(), city2.get&lt;1&gt;()))
+ {
+ <span class="keywordtype">double</span> <a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">distance</a> = costs[city2.get&lt;2&gt;()] / km;
+ <span class="keywordtype">double</span> acof = <a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">ggl::distance</a>(city1.get&lt;0&gt;(), city2.get&lt;0&gt;()) / km;
+
+ std::cout
+ &lt;&lt; std::setiosflags (std::ios_base::left) &lt;&lt; std::setw(15)
+ &lt;&lt; city1.get&lt;1&gt;() &lt;&lt; <span class="stringliteral">" - "</span>
+ &lt;&lt; std::setiosflags (std::ios_base::left) &lt;&lt; std::setw(15)
+ &lt;&lt; city2.get&lt;1&gt;()
+ &lt;&lt; <span class="stringliteral">" -&gt; through the air: "</span> &lt;&lt; std::setw(4) &lt;&lt; acof
+ &lt;&lt; <span class="stringliteral">" , over the road: "</span> &lt;&lt; std::setw(4) &lt;&lt; distance
+ &lt;&lt; std::endl;
+
+ <span class="keywordflow">if</span> (first)
+ {
+ build_route(graph, predecessors,
+ city1.get&lt;2&gt;(), city2.get&lt;2&gt;(),
+ route);
+ first = <span class="keyword">false</span>;
+ }
+ }
+ }
+ }
+
+ <span class="comment">// Create the SVG</span>
+ <span class="keyword">typedef</span> <a name="_a12"></a><a class="code" href="classggl_1_1point__xy.html" title="2D point in Cartesian coordinate system">ggl::point_xy&lt;int&gt;</a> svg_point_type;
+ std::ofstream stream(<span class="stringliteral">"routes.svg"</span>);
+ svg_header(stream);
+
+ <a name="_a13"></a><a class="code" href="structggl_1_1strategy_1_1transform_1_1map__transformer.html" title="Transformation strategy to do map from one to another Cartesian system.">ggl::strategy::transform::map_transformer</a>
+ &lt;
+ point_type,
+ svg_point_type, <span class="keyword">true</span>, <span class="keyword">true</span>
+ &gt; matrix(box, 1000, 800);
+
+ <span class="comment">// Map roads</span>
+ BOOST_FOREACH(road_type <span class="keyword">const</span>&amp; road, roads)
+ {
+ <a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">ggl::linestring&lt;svg_point_type&gt;</a> line;
+ <a name="a14"></a><a class="code" href="group__transform.html#ge33cee2442ebab063f9c987121cd3500" title="Transforms from one geometry to another geometry using a strategy.">ggl::transform</a>(road.get&lt;0&gt;(), line, matrix);
+ stream &lt;&lt; <a name="a15"></a><a class="code" href="group__svg.html#g98ba8f58eaff68c96c23f9d9a90bc4fd" title="Main svg function to stream geometries as SVG.">ggl::svg</a>(line, <span class="stringliteral">"stroke:rgb(128,128,128);stroke-width:1"</span>) &lt;&lt; std::endl;
+ }
+
+ <span class="comment">// Map the calculated route as thicker green transparent markation</span>
+ {
+ <a class="code" href="classggl_1_1linestring.html" title="A linestring (named so by OGC) is a collection (default a vector) of points.">ggl::linestring&lt;svg_point_type&gt;</a> line;
+ <a class="code" href="group__transform.html#ge33cee2442ebab063f9c987121cd3500" title="Transforms from one geometry to another geometry using a strategy.">ggl::transform</a>(route, line, matrix);
+ stream &lt;&lt; <a class="code" href="group__svg.html#g98ba8f58eaff68c96c23f9d9a90bc4fd" title="Main svg function to stream geometries as SVG.">ggl::svg</a>(line, <span class="stringliteral">"stroke:rgb(0, 255, 0);stroke-width:6;opacity:0.5"</span>) &lt;&lt; std::endl;
+ }
+
+ <span class="comment">// Map cities</span>
+ BOOST_FOREACH(city_type <span class="keyword">const</span>&amp; city, cities)
+ {
+ svg_point_type point;
+ <a class="code" href="group__transform.html#ge33cee2442ebab063f9c987121cd3500" title="Transforms from one geometry to another geometry using a strategy.">ggl::transform</a>(city.get&lt;0&gt;(), point, matrix);
+ stream &lt;&lt; <a class="code" href="group__svg.html#g98ba8f58eaff68c96c23f9d9a90bc4fd" title="Main svg function to stream geometries as SVG.">ggl::svg</a>(point, <span class="stringliteral">"fill:rgb(255,255,0);stroke:rgb(0,0,0);stroke-width:1"</span>) &lt;&lt; std::endl;
+ }
+
+ stream &lt;&lt; <span class="stringliteral">"&lt;/svg&gt;"</span> &lt;&lt; std::endl;
+
+ <span class="keywordflow">return</span> 0;
+}
+</pre></div> </div>
+<hr size="1">
+<table width="100%">
+<tbody>
+<tr>
+<td align="left"><small>
+<p>October 13, 2009</p>
+</small></td>
+<td align="right">
+<small>Copyright © 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
+Copyright © 2008-2009 Bruno Lalande, Paris<br>
+Copyright © 2009 Mateusz Loskot, Cadcorp, London<br>
+</small>
+</td>
+</tr>
+</tbody>
+</table>
+
+<address style="text-align: right;"><small>
+Documentation is generated by&nbsp;Doxygen
+</small></address>
+</body>
+</html>

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07_graph_route_example_svg.png
==============================================================================
Binary file. No diff available.

Added: sandbox/ggl/formal_review_request/libs/ggl/doc/doxygen_output/html/07_graph_route_example_text.png
==============================================================================
Binary file. No diff available.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk