From df45fd87355c6a3ee33fcc1485a9d64f7b83ff9f Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Tue, 4 Jan 2011 17:08:47 +0000 Subject: [PATCH] Added previously forgotten example-file [SVN r67649] --- .../algorithms/area_with_strategy.cpp | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 doc/src/examples/algorithms/area_with_strategy.cpp diff --git a/doc/src/examples/algorithms/area_with_strategy.cpp b/doc/src/examples/algorithms/area_with_strategy.cpp new file mode 100644 index 000000000..6200389ee --- /dev/null +++ b/doc/src/examples/algorithms/area_with_strategy.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + // Define a spherical point + typedef bg::model::point > pnt_type; + + bg::model::polygon 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 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 +] +*/ +//]