|
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">
+
+</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 <iostream></span>
+
+<span class="preprocessor">#include <ggl/ggl.hpp></span>
+<span class="preprocessor">#include <<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>></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 << <span class="stringliteral">"Hello ("</span> << world.<a name="a1"></a><a class="code" href="classggl_1_1point__xy.html#a7803d55e0758a659d618583b757b272" title="Get x-value.">x</a>() << <span class="stringliteral">","</span> << world.<a name="a2"></a><a class="code" href="classggl_1_1point__xy.html#a83e59f4d401b1a4c6f037979c57260f" title="Get y-value.">y</a>() << <span class="stringliteral">")"</span> << std::endl;
+ std::cout << <span class="stringliteral">"Hello "</span> << <a name="a3"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">dsv</a>(world) << 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 << <span class="stringliteral">"distance a-b is "</span> << <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) << 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 << <span class="stringliteral">"a:"</span> << world.<a class="code" href="classggl_1_1point__xy.html#a7803d55e0758a659d618583b757b272" title="Get x-value.">x</a>() << <span class="stringliteral">" "</span> << world.<a class="code" href="classggl_1_1point__xy.html#a83e59f4d401b1a4c6f037979c57260f" title="Get y-value.">y</a>() << std::endl;
+ std::cout << <span class="stringliteral">"distance a-b is "</span> << <a class="code" href="group__distance.html#g22a618786d2601e9201896a8346c161b" title="Calculate distance between two geometries with a specified strategy.">distance</a>(a,b) << 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<point_2d>(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<point_2d>("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<0>(a, 2); <span class="comment">// set first coordinate to 2</span>
+ set<1>(a, 3); <span class="comment">// set second coordinate to 3</span>
+ std::cout << get<0>(a) << <span class="stringliteral">","</span> << get<1>(a) << std::endl;
+
+ <span class="comment">// set<2>(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 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">
+
+</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 <algorithm></span> <span class="comment">// for reverse, unique</span>
+<span class="preprocessor">#include <iostream></span>
+<span class="preprocessor">#include <iterator></span>
+<span class="preprocessor">#include <utility></span>
+<span class="preprocessor">#include <vector></span>
+
+<span class="preprocessor">#include <ggl/ggl.hpp></span>
+<span class="preprocessor">#include <<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>></span>
+<span class="comment">// Optional includes to handle c-arrays as points, std::vectors as linestrings</span>
+<span class="preprocessor">#include <<a class="code" href="c__array__cartesian_8hpp.html">ggl/geometries/adapted/c_array_cartesian.hpp</a>></span>
+<span class="preprocessor">#include <<a class="code" href="std__as__linestring_8hpp.html">ggl/geometries/adapted/std_as_linestring.hpp</a>></span>
+
+<span class="keyword">template</span> <<span class="keyword">typename</span> P>
+<span class="keyword">struct </span>point_equal
+{
+ <span class="keyword">inline</span> <span class="keywordtype">bool</span> operator()(P <span class="keyword">const</span>& left, P <span class="keyword">const</span>& 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><<span class="keyword">typename</span> P>
+<span class="keyword">inline</span> <span class="keywordtype">void</span> translate_function(P& p)
+{
+ p.x(p.x() + 100.0);
+}
+
+<span class="keyword">template</span><<span class="keyword">typename</span> P>
+<span class="keyword">struct </span>scale_functor
+{
+ <span class="keyword">inline</span> <span class="keywordtype">void</span> operator()(P& 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<point_2d>(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 << <a name="a5"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) << 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 << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(b) << std::endl;
+
+ <span class="comment">// The length of the line can be calulated</span>
+ std::cout << <span class="stringliteral">"length: "</span> << <a name="a8"></a><a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">length</a>(ls) << std::endl;
+
+ <span class="comment">// All things from std::vector can be called, because a linestring is a vector</span>
+ std::cout << <span class="stringliteral">"number of points 1: "</span> << ls.size() << std::endl;
+
+ <span class="comment">// All things from boost ranges can be called because a linestring is considered as a range</span>
+ std::cout << <span class="stringliteral">"number of points 2: "</span> << boost::size(ls) << std::endl;
+
+ <span class="comment">// Generic function from geometry/OGC delivers the same value</span>
+ std::cout << <span class="stringliteral">"number of points 3: "</span> << <a name="a9"></a><a class="code" href="group__access.html#g8d58faff2722b073b44c24f19577e267" title="get number of points">num_points</a>(ls) << 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 << <span class="stringliteral">"distance of "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(p)
+ << <span class="stringliteral">" to line: "</span> << <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) << 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<point_2d ></a>(ls.front(), ls.back()));
+ std::cout << <span class="stringliteral">"distance: "</span> << d << 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 << <span class="stringliteral">"appended: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) << std::endl;
+
+ <span class="comment">// Output as iterator-pair on a vector</span>
+ {
+ std::vector<point_2d> v;
+ std::copy(ls.begin(), ls.end(), std::back_inserter(v));
+
+ std::cout
+ << <span class="stringliteral">"as vector: "</span>
+ << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(v)
+ << std::endl;
+
+ std::cout
+ << <span class="stringliteral">"as it-pair: "</span>
+ << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(std::make_pair(v.begin(), v.end()))
+ << 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 << <span class="stringliteral">"reversed: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) << 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<point_2d> pv(ls.begin(), ls.end());
+ std::cout << <span class="stringliteral">"length: "</span> << <a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">length</a>(pv) << 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 << <span class="stringliteral">"extra duplicate points: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) << 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<point_2d>());
+ ls = ls_copy;
+ std::cout << <span class="stringliteral">"uniquecopy: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls) << 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 << <span class="stringliteral">"simplified: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(ls_simplified) << 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<point_2d>);
+ <a name="a13"></a><a class="code" href="group__loop.html#g71cb52ab6490726f9030b464aa2f5e8a" title="Calls functor for geometry.">for_each_point</a>(lscopy, scale_functor<point_2d>());
+ <a class="code" href="group__loop.html#g71cb52ab6490726f9030b464aa2f5e8a" title="Calls functor for geometry.">for_each_point</a>(lscopy, translate_function<point_2d>);
+ std::cout << <span class="stringliteral">"modified line: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(lscopy) << 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<linestring_2d> clipped;
+ intersection<linestring_2d> (cb, ls, std::back_inserter(clipped));
+
+ <span class="comment">// Also possible: clip-output to a vector of vectors</span>
+ std::vector<std::vector<point_2d> > vector_out;
+ intersection<std::vector<point_2d> >(cb, ls, std::back_inserter(vector_out));
+
+ std::cout << <span class="stringliteral">"clipped output as vector:"</span> << std::endl;
+ <span class="keywordflow">for</span> (std::vector<std::vector<point_2d> >::const_iterator it
+ = vector_out.begin(); it != vector_out.end(); ++it)
+ {
+ std::cout << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(*it) << 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 << <span class="stringliteral">"Convex hull:"</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(hull) << 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<float, 3, cs::cartesian></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<point_type></a> line_type;
+ line_type line3d;
+ line3d.push_back(make<point_type>(1,2,3));
+ line3d.push_back(make<point_type>(4,5,6));
+ line3d.push_back(make<point_type>(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 << <span class="stringliteral">"3D: length: "</span> << <a class="code" href="group__length.html#g7e3572634111ae0252a474a7f435c5aa" title="Calculate length of a geometry.">length</a>(line3d) << <span class="stringliteral">" line: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(line3d) << std::endl;
+
+ <span class="comment">// With DSV you can also use other delimiters, e.g. JSON style</span>
+ std::cout << <span class="stringliteral">"JSON: "</span>
+ << <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>)
+ << 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 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">
+
+</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 <algorithm></span> <span class="comment">// for reverse, unique</span>
+<span class="preprocessor">#include <iostream></span>
+<span class="preprocessor">#include <string></span>
+
+<span class="preprocessor">#include <ggl/ggl.hpp></span>
+<span class="preprocessor">#include <<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>></span>
+<span class="preprocessor">#include <<a class="code" href="c__array__cartesian_8hpp.html">ggl/geometries/adapted/c_array_cartesian.hpp</a>></span>
+<span class="preprocessor">#include <<a class="code" href="std__as__linestring_8hpp.html">ggl/geometries/adapted/std_as_linestring.hpp</a>></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 << <a name="a3"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly) << 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 << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(b) << std::endl;
+
+ <span class="comment">// The area of the polygon can be calulated</span>
+ std::cout << <span class="stringliteral">"area: "</span> << <a name="a6"></a><a class="code" href="group__area.html#g3ebfdefe9c756498730b6d93b83338b3" title="Calculate area of a geometry.">area</a>(poly) << 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 << <span class="stringliteral">"centroid: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(cent) << 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 << "labelpoints: ";</span>
+<span class="comment"> label_info<0>(poly, , std::ostream_iterator<point_2d>(std::cout, " "));</span>
+<span class="comment"> std::cout << std::endl;</span>
+<span class="comment"> */</span>
+
+ <span class="comment">// The number of points have to called per ring separately</span>
+ std::cout << <span class="stringliteral">"number of points in outer ring: "</span> << poly.<a name="a9"></a><a class="code" href="classggl_1_1polygon.html#be04d3ead04813a25be1a219076358a8">outer</a>().size() << 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<point_2d></a>& 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 << <span class="stringliteral">"with inner ring:"</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly) << std::endl;
+ <span class="comment">// The area of the polygon is changed of course</span>
+ std::cout << <span class="stringliteral">"new area of polygon: "</span> << <a class="code" href="group__area.html#g3ebfdefe9c756498730b6d93b83338b3" title="Calculate area of a geometry.">area</a>(poly) << std::endl;
+ <a class="code" href="group__centroid.html#g2b743cdd7177313b561780ba87c633cd" title="Calculate centroid.">centroid</a>(poly, cent);
+ std::cout << <span class="stringliteral">"new centroid: "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(cent) << std::endl;
+
+ <span class="comment">// You can test whether points are within a polygon</span>
+ std::cout << <span class="stringliteral">"point in polygon:"</span>
+ << <span class="stringliteral">" p1: "</span> << boolstr(<a name="a12"></a><a class="code" href="group__boolean__relations.html#g95d6465a12b762c77df41369a039f6dc" title="Within check.">within</a>(make<point_2d>(3.0, 2.0), poly))
+ << <span class="stringliteral">" p2: "</span> << boolstr(<a class="code" href="group__boolean__relations.html#g95d6465a12b762c77df41369a039f6dc" title="Within check.">within</a>(make<point_2d>(3.7, 2.0), poly))
+ << <span class="stringliteral">" p3: "</span> << boolstr(<a class="code" href="group__boolean__relations.html#g95d6465a12b762c77df41369a039f6dc" title="Within check.">within</a>(make<point_2d>(4.4, 2.0), poly))
+ << 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<point_2d>(1.5, 1.5), make<point_2d>(4.5, 2.5));
+ <span class="keyword">typedef</span> std::vector<polygon_2d > polygon_list;
+ polygon_list v;
+
+ intersection<polygon_2d>(cb, poly, std::back_inserter(v));
+ std::cout << <span class="stringliteral">"Clipped output polygons"</span> << std::endl;
+ <span class="keywordflow">for</span> (polygon_list::const_iterator it = v.begin(); it != v.end(); ++it)
+ {
+ std::cout << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(*it) << 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 << <span class="stringliteral">"Convex hull:"</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(hull) << 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<point_2d, std::vector, std::deque></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<polygon_type>::type</a>& 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<point_2d>(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<point_2d>(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<point_2d>(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<point_2d>(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<point_2d>(2.8, 1.9));
+ std::cout << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly2) << 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 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">
+
+</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 <iostream></span>
+
+<span class="preprocessor">#include <ggl/ggl.hpp></span>
+<span class="preprocessor">#include <<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>></span>
+<span class="preprocessor">#include <<a class="code" href="c__array__cartesian_8hpp.html">ggl/geometries/adapted/c_array_cartesian.hpp</a>></span>
+<span class="preprocessor">#include <<a class="code" href="std__as__linestring_8hpp.html">ggl/geometries/adapted/std_as_linestring.hpp</a>></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<point_2d, point_2d></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 << <span class="stringliteral">"transformed point "</span> << <a name="a3"></a><a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(p2) << 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 << <span class="stringliteral">"source polygon "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly) << std::endl;
+ std::cout << <span class="stringliteral">"transformed polygon "</span> << <a class="code" href="namespaceggl.html#3399b7516122f515a1ea5ee5fdf49ce4" title="Main DSV-streaming function.">ggl::dsv</a>(poly2) << 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 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">
+
+</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 <iostream></span>
+<span class="preprocessor">#include <fstream></span>
+<span class="preprocessor">#include <iomanip></span>
+<span class="preprocessor">#include <limits></span>
+
+<span class="preprocessor">#include <boost/tuple/tuple.hpp></span>
+<span class="preprocessor">#include <boost/foreach.hpp></span>
+
+<span class="preprocessor">#include <boost/graph/adjacency_list.hpp></span>
+<span class="preprocessor">#include <boost/graph/dijkstra_shortest_paths.hpp></span>
+
+<span class="preprocessor">#include <ggl/ggl.hpp></span>
+<span class="preprocessor">#include <<a class="code" href="less_8hpp.html">ggl/util/less.hpp</a>></span>
+<span class="preprocessor">#include <<a class="code" href="cartesian2d_8hpp.html">ggl/geometries/cartesian2d.hpp</a>></span>
+
+
+<span class="comment">// Yes, this example currently uses some extensions:</span>
+
+ <span class="comment">// For input:</span>
+<span class="preprocessor"> #include <ggl/extensions/gis/io/wkt/read_wkt.hpp></span>
+
+ <span class="comment">// For output:</span>
+<span class="preprocessor"> #include <<a class="code" href="write__svg_8hpp.html">ggl/extensions/io/svg/write_svg.hpp</a>></span>
+
+ <span class="comment">// For distance-calculations over the Earth:</span>
+<span class="preprocessor"> #include <ggl/extensions/gis/geographic/strategies/andoyer.hpp></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 <0> a geometry and <1> an identifying string</span>
+<span class="keyword">template</span> <<span class="keyword">typename</span> Geometry, <span class="keyword">typename</span> Tuple, <span class="keyword">typename</span> Box>
+<span class="keywordtype">void</span> read_wkt(std::string <span class="keyword">const</span>& filename, std::vector<Tuple>& tuples, Box& 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() && ! 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<Box>(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>
+ <
+ <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<Geometry>::type</a>,
+ Box
+ >()));
+ }
+ }
+ }
+}
+
+<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& stream)
+{
+ stream << <span class="stringliteral">"<?xml version=\"1.0\" standalone=\"no\"?>"</span> << std::endl;
+ stream << <span class="stringliteral">"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\""</span> << std::endl;
+ stream << <span class="stringliteral">"\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">"</span> << std::endl;
+
+ stream << <span class="stringliteral">"<svg width=\"100%\" height=\"100%\" version=\"1.1\""</span> << std::endl;
+ stream << <span class="stringliteral">"xmlns=\"http://www.w3.org/2000/svg\">"</span> << 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> <<span class="keyword">typename</span> Po<span class="keywordtype">int</span>>
+<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>& loc)
+ {
+ location = loc;
+ }
+
+ Point location;
+};
+
+<span class="comment">// Define properties for edge</span>
+<span class="keyword">template</span> <<span class="keyword">typename</span> Line<span class="keywordtype">string</span>>
+<span class="keyword">struct </span>ggl_edge_property
+{
+ ggl_edge_property(Linestring <span class="keyword">const</span>& 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>& 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> <<span class="keyword">typename</span> M, <span class="keyword">typename</span> K, <span class="keyword">typename</span> G>
+<span class="keyword">inline</span> <span class="keyword">typename</span> boost::graph_traits<G>::vertex_descriptor find_or_insert(M& map, K <span class="keyword">const</span>& key, G& 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<G>::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<typename M::key_type>(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->second;
+}
+
+<span class="keyword">template</span>
+<
+ <span class="keyword">typename</span> Line,
+ <span class="keyword">typename</span> Graph,
+ <span class="keyword">typename</span> RoadTupleVector,
+ <span class="keyword">typename</span> CityTupleVector
+>
+<span class="keywordtype">void</span> add_roads_and_connect_cities(Graph& graph,
+ RoadTupleVector <span class="keyword">const</span>& roads,
+ CityTupleVector& 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<Line>::type</a> point_type;
+
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::graph_traits<Graph>::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<point_type, vertex_type, ggl::less<point_type> > 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<RoadTupleVector>::type road_type;
+ BOOST_FOREACH(road_type <span class="keyword">const</span>& road, roads)
+ {
+ <span class="comment">// Find or add begin/end point of these line</span>
+ vertex_type from = find_or_insert(map, road.get<0>().front(), graph);
+ vertex_type to = find_or_insert(map, road.get<0>().back(), graph);
+ boost::add_edge(from, to, ggl_edge_property<Line>(road.get<0>()), 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<CityTupleVector>::type city_type;
+ BOOST_FOREACH(city_type& 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->first, city.get<0>());
+ <span class="keywordflow">if</span> (dist < min_distance)
+ {
+ min_distance = dist;
+ <span class="comment">// Set the vertex</span>
+ city.get<2>() = it->second;
+ }
+ }
+ }
+}
+
+<span class="keyword">template</span> <<span class="keyword">typename</span> Graph, <span class="keyword">typename</span> Route>
+<span class="keyword">inline</span> <span class="keywordtype">void</span> add_edge_to_route(Graph <span class="keyword">const</span>& graph,
+ <span class="keyword">typename</span> boost::graph_traits<Graph>::vertex_descriptor vertex1,
+ <span class="keyword">typename</span> boost::graph_traits<Graph>::vertex_descriptor vertex2,
+ Route& route)
+{
+ std::pair
+ <
+ <span class="keyword">typename</span> boost::graph_traits<Graph>::edge_descriptor,
+ <span class="keywordtype">bool</span>
+ > 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<Route> <span class="keyword">const</span>& 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<typename ggl::point_type<Route>::type> <span class="keyword">const</span>& 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> <<span class="keyword">typename</span> Graph, <span class="keyword">typename</span> Route>
+<span class="keyword">inline</span> <span class="keywordtype">void</span> build_route(Graph <span class="keyword">const</span>& graph,
+ std::vector<<span class="keyword">typename</span> boost::graph_traits<Graph>::vertex_descriptor> <span class="keyword">const</span>& predecessors,
+ <span class="keyword">typename</span> boost::graph_traits<Graph>::vertex_descriptor vertex1,
+ <span class="keyword">typename</span> boost::graph_traits<Graph>::vertex_descriptor vertex2,
+ Route& route)
+{
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::graph_traits<Graph>::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<double, 2, ggl::cs::geographic<ggl::degree></a> > 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<point_type></a> line_type;
+
+ <span class="comment">// Define the graph, lateron containing the road network</span>
+ <span class="keyword">typedef</span> boost::adjacency_list
+ <
+ boost::vecS, boost::vecS, boost::undirectedS
+ , boost::property<vertex_ggl_property_t, ggl_vertex_property<point_type> >
+ , boost::property<edge_ggl_property_t, ggl_edge_property<line_type> >
+ > graph_type;
+
+ <span class="keyword">typedef</span> boost::graph_traits<graph_type>::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<point_type, std::string, vertex_type> city_type;
+ std::vector<city_type> cities;
+ read_wkt<point_type>(<span class="stringliteral">"data/cities.wkt"</span>, cities, box);
+
+ <span class="comment">// Read the road network</span>
+ <span class="keyword">typedef</span> boost::tuple<line_type, std::string> road_type;
+ std::vector<road_type> roads;
+ read_wkt<line_type>(<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<line_type>(graph, roads, cities);
+
+ <span class="keywordtype">double</span> <span class="keyword">const</span> km = 1000.0;
+ std::cout << <span class="stringliteral">"distances, all in KM"</span> << std::endl
+ << std::fixed << 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>& city1, cities)
+ {
+ std::vector<vertex_type> predecessors(n);
+ std::vector<double> costs(n);
+
+ <span class="comment">// Call Dijkstra (without named-parameter to be compatible with all VC)</span>
+ boost::dijkstra_shortest_paths(graph, city1.get<2>(),
+ &predecessors[0], &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<double>(), std::plus<double>(),
+ (std::numeric_limits<double>::max)(), <span class="keywordtype">double</span>(),
+ boost::dijkstra_visitor<boost::null_visitor>());
+
+ BOOST_FOREACH(city_type <span class="keyword">const</span>& 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<1>(), city2.get<1>()))
+ {
+ <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<2>()] / 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<0>(), city2.get<0>()) / km;
+
+ std::cout
+ << std::setiosflags (std::ios_base::left) << std::setw(15)
+ << city1.get<1>() << <span class="stringliteral">" - "</span>
+ << std::setiosflags (std::ios_base::left) << std::setw(15)
+ << city2.get<1>()
+ << <span class="stringliteral">" -> through the air: "</span> << std::setw(4) << acof
+ << <span class="stringliteral">" , over the road: "</span> << std::setw(4) << distance
+ << std::endl;
+
+ <span class="keywordflow">if</span> (first)
+ {
+ build_route(graph, predecessors,
+ city1.get<2>(), city2.get<2>(),
+ 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<int></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>
+ <
+ point_type,
+ svg_point_type, <span class="keyword">true</span>, <span class="keyword">true</span>
+ > matrix(box, 1000, 800);
+
+ <span class="comment">// Map roads</span>
+ BOOST_FOREACH(road_type <span class="keyword">const</span>& 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<svg_point_type></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<0>(), line, matrix);
+ stream << <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>) << 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<svg_point_type></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 << <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>) << std::endl;
+ }
+
+ <span class="comment">// Map cities</span>
+ BOOST_FOREACH(city_type <span class="keyword">const</span>& 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<0>(), point, matrix);
+ stream << <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>) << std::endl;
+ }
+
+ stream << <span class="stringliteral">"</svg>"</span> << 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 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