3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>area (with strategy)</title>
5 <link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../../../index.html" title="Chapter 1. Geometry">
8 <link rel="up" href="../area.html" title="area">
9 <link rel="prev" href="area_1.html" title="area">
10 <link rel="next" href="../assign.html" title="assign">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="area_1.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../area.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../assign.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h5 class="title">
27 <a name="geometry.reference.algorithms.area.area_2_with_strategy"></a><a class="link" href="area_2_with_strategy.html" title="area (with strategy)">area
29 </h5></div></div></div>
31 <a class="indexterm" name="idp87958352"></a>
32 Calculates the area of a geometry using the specified strategy.
35 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h0"></a>
36 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.description"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.description">Description</a>
39 The free function area calculates the area of a geometry using the specified
40 strategy. Reasons to specify a strategy include: use another coordinate
41 system for calculations; construct the strategy beforehand (e.g. with
42 the radius of the Earth); select a strategy when there are more than
43 one available for a calculation.
46 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h1"></a>
47 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.synopsis"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.synopsis">Synopsis</a>
51 <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Strategy</span><span class="special">></span>
52 <span class="identifier">Strategy</span><span class="special">::</span><span class="identifier">return_type</span> <span class="identifier">area</span><span class="special">(</span><span class="identifier">Geometry</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">geometry</span><span class="special">,</span> <span class="identifier">Strategy</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">strategy</span><span class="special">)</span></pre>
56 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h2"></a>
57 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.parameters"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.parameters">Parameters</a>
59 <div class="informaltable"><table class="table">
97 Any type fulfilling a Geometry Concept
107 A model of the specified concept
119 Any type fulfilling a Area Strategy Concept
129 The strategy which will be used for area calculations
136 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h3"></a>
137 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.returns"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.returns">Returns</a>
143 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h4"></a>
144 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.header"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.header">Header</a>
150 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
156 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">algorithms</span><span class="special">/</span><span class="identifier">area</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
159 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h5"></a>
160 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.conformance"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.conformance">Conformance</a>
163 The function area implements function Area from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC
164 Simple Feature Specification</a>.
167 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h6"></a>
168 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.behavior"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.behavior">Behavior</a>
170 <div class="informaltable"><table class="table">
191 pointlike (e.g. point)
203 linear (e.g. linestring)
232 Returns the area in the same units as the input coordinates
244 Returns the area on a unit sphere (or another sphere, if specified
245 as such in the constructor of the strategy)
252 Reversed polygon (coordinates not according their orientiation)
257 Returns the negative area
264 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h7"></a>
265 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.supported_geometries"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.supported_geometries">Supported
268 <div class="informaltable"><table class="table">
294 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
306 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
318 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
330 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
342 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
354 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
366 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
378 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
390 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
402 <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
409 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h8"></a>
410 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.complexity"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.complexity">Complexity</a>
416 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h9"></a>
417 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.example"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.example">Example</a>
420 Calculate the area of a polygon
424 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
426 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
427 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">point_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
428 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
430 <span class="keyword">namespace</span> <span class="identifier">bg</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span> <a class="co" name="geometry.reference.algorithms.area.area_2_with_strategy.c0" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.c1"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a>
432 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
433 <span class="special">{</span>
434 <span class="comment">// Calculate the area of a cartesian polygon</span>
435 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">d2</span><span class="special">::</span><span class="identifier">point_xy</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="special">></span> <span class="identifier">poly</span><span class="special">;</span>
436 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span><span class="string">"POLYGON((0 0,0 7,4 2,2 0,0 0))"</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">);</span>
437 <span class="keyword">double</span> <span class="identifier">area</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">area</span><span class="special">(</span><span class="identifier">poly</span><span class="special">);</span>
438 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Area: "</span> <span class="special"><<</span> <span class="identifier">area</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
440 <span class="comment">// Calculate the area of a spherical polygon (for latitude: 0 at equator)</span>
441 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">point</span><span class="special"><</span><span class="keyword">float</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">spherical_equatorial</span><span class="special"><</span><span class="identifier">bg</span><span class="special">::</span><span class="identifier">degree</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">sph_poly</span><span class="special">;</span>
442 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span><span class="string">"POLYGON((0 0,0 45,45 0,0 0))"</span><span class="special">,</span> <span class="identifier">sph_poly</span><span class="special">);</span>
443 <span class="identifier">area</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">area</span><span class="special">(</span><span class="identifier">sph_poly</span><span class="special">);</span>
444 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Area: "</span> <span class="special"><<</span> <span class="identifier">area</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
446 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
447 <span class="special">}</span>
451 <div class="calloutlist"><table border="0" summary="Callout list"><tr>
452 <td width="5%" valign="top" align="left"><p><a name="geometry.reference.algorithms.area.area_2_with_strategy.c1"></a><a href="#geometry.reference.algorithms.area.area_2_with_strategy.c0"><img src="../../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td>
453 <td valign="top" align="left"><p>
454 Convenient namespace alias
460 <pre class="programlisting">Area: 16
464 <a name="geometry.reference.algorithms.area.area_2_with_strategy.h10"></a>
465 <span class="phrase"><a name="geometry.reference.algorithms.area.area_2_with_strategy.available_strategies"></a></span><a class="link" href="area_2_with_strategy.html#geometry.reference.algorithms.area.area_2_with_strategy.available_strategies">Available
468 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
469 <li class="listitem">
470 <a class="link" href="../../strategies/strategy_area_surveyor.html" title="strategy::area::surveyor">Surveyor
473 <li class="listitem">
474 <a class="link" href="../../strategies/strategy_area_spherical.html" title="strategy::area::spherical">Spherical</a>
478 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
479 <td align="left"></td>
480 <td align="right"><div class="copyright-footer">Copyright © 2009-2017 Barend
481 Gehrels, Bruno Lalande, Mateusz Loskot, Adam Wulkiewicz, Oracle and/or its
483 Distributed under the Boost Software License, Version 1.0. (See accompanying
484 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
489 <div class="spirit-nav">
490 <a accesskey="p" href="area_1.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../area.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../assign.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>