Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67649 - trunk/libs/geometry/doc/src/examples/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-01-04 12:08:48


Author: barendgehrels
Date: 2011-01-04 12:08:47 EST (Tue, 04 Jan 2011)
New Revision: 67649
URL: http://svn.boost.org/trac/boost/changeset/67649

Log:
Added previously forgotten example-file
Added:
   trunk/libs/geometry/doc/src/examples/algorithms/area_with_strategy.cpp (contents, props changed)

Added: trunk/libs/geometry/doc/src/examples/algorithms/area_with_strategy.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/examples/algorithms/area_with_strategy.cpp 2011-01-04 12:08:47 EST (Tue, 04 Jan 2011)
@@ -0,0 +1,49 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2011, Geodan, Amsterdam, the Netherlands
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// Quickbook Example
+
+//[area_with_strategy
+//` Calculate the area of a polygon specifying a strategy
+
+#include <iostream>
+#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+namespace bg = boost::geometry;
+
+int main()
+{
+ // Define a spherical point
+ typedef bg::model::point<double, 2, bg::cs::spherical<bg::degree> > pnt_type;
+
+ bg::model::polygon<pnt_type> hawaii;
+ bg::read_wkt("POLYGON((-155.86 18.93,-155.84 20.30,-154.80 19.52,-155.86 18.93))" /*< Rough appromation of [@http://en.wikipedia.org/wiki/Hawaii_%28island%29 Hawaii Island] >*/
+ , hawaii);
+ double const mean_radius = 6371.0; /*< [@http://en.wikipedia.org/wiki/Earth_radius Wiki] >*/
+
+
+ // Construct the strategy (Huiller) and calculate the area
+ bg::strategy::area::huiller<pnt_type> in_square_kilometers(mean_radius);
+ double area = bg::area(hawaii, in_square_kilometers);
+
+ std::cout << area << " km2" << std::endl;
+
+ return 0;
+}
+
+//]
+
+
+//[area_with_strategy_output
+/*`
+Output:
+[pre
+Area: 8393.22 km2
+]
+*/
+//]


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