• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>centroid (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="../centroid.html" title="centroid">
9<link rel="prev" href="../centroid.html" title="centroid">
10<link rel="next" href="centroid_2.html" title="centroid">
11</head>
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>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../centroid.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../centroid.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="centroid_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy"></a><a class="link" href="centroid_3_with_strategy.html" title="centroid (with strategy)">centroid
28          (with strategy)</a>
29</h5></div></div></div>
30<p>
31            <a class="indexterm" name="idm45635705813648"></a>
32Calculates the centroid of a geometry using the specified strategy.
33          </p>
34<h6>
35<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h0"></a>
36            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.description"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.description">Description</a>
37          </h6>
38<p>
39            The free function centroid calculates the geometric center (or: center
40            of mass) of a geometry. Reasons to specify a strategy include: use another
41            coordinate system for calculations; construct the strategy beforehand
42            (e.g. with the radius of the Earth); select a strategy when there are
43            more than one available for a calculation.
44          </p>
45<h6>
46<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h1"></a>
47            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.synopsis"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.synopsis">Synopsis</a>
48          </h6>
49<p>
50</p>
51<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Point</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Strategy</span><span class="special">&gt;</span>
52<span class="keyword">void</span> <span class="identifier">centroid</span><span class="special">(</span><span class="identifier">Geometry</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">geometry</span><span class="special">,</span> <span class="identifier">Point</span> <span class="special">&amp;</span> <span class="identifier">c</span><span class="special">,</span> <span class="identifier">Strategy</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">strategy</span><span class="special">)</span></pre>
53<p>
54          </p>
55<h6>
56<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h2"></a>
57            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.parameters"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.parameters">Parameters</a>
58          </h6>
59<div class="informaltable"><table class="table">
60<colgroup>
61<col>
62<col>
63<col>
64<col>
65</colgroup>
66<thead><tr>
67<th>
68                    <p>
69                      Type
70                    </p>
71                  </th>
72<th>
73                    <p>
74                      Concept
75                    </p>
76                  </th>
77<th>
78                    <p>
79                      Name
80                    </p>
81                  </th>
82<th>
83                    <p>
84                      Description
85                    </p>
86                  </th>
87</tr></thead>
88<tbody>
89<tr>
90<td>
91                    <p>
92                      Geometry const &amp;
93                    </p>
94                  </td>
95<td>
96                    <p>
97                      Any type fulfilling a Geometry Concept
98                    </p>
99                  </td>
100<td>
101                    <p>
102                      geometry
103                    </p>
104                  </td>
105<td>
106                    <p>
107                      A model of the specified concept
108                    </p>
109                  </td>
110</tr>
111<tr>
112<td>
113                    <p>
114                      Point &amp;
115                    </p>
116                  </td>
117<td>
118                    <p>
119                      Any type fulfilling a Point Concept
120                    </p>
121                  </td>
122<td>
123                    <p>
124                      c
125                    </p>
126                  </td>
127<td>
128                    <p>
129                      A model of the specified Point Concept which is set to the
130                      centroid
131                    </p>
132                  </td>
133</tr>
134<tr>
135<td>
136                    <p>
137                      Strategy const &amp;
138                    </p>
139                  </td>
140<td>
141                    <p>
142                      Any type fulfilling a Centroid Strategy Concept
143                    </p>
144                  </td>
145<td>
146                    <p>
147                      strategy
148                    </p>
149                  </td>
150<td>
151                    <p>
152                      The strategy which will be used for centroid calculations
153                    </p>
154                  </td>
155</tr>
156</tbody>
157</table></div>
158<h6>
159<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h3"></a>
160            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.header"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.header">Header</a>
161          </h6>
162<p>
163            Either
164          </p>
165<p>
166            <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</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">&gt;</span></code>
167          </p>
168<p>
169            Or
170          </p>
171<p>
172            <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</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">centroid</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
173          </p>
174<h6>
175<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h4"></a>
176            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.conformance"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.conformance">Conformance</a>
177          </h6>
178<p>
179            The function centroid implements function Centroid from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC
180            Simple Feature Specification</a>.
181          </p>
182<h6>
183<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h5"></a>
184            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.behavior"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.behavior">Behavior</a>
185          </h6>
186<div class="informaltable"><table class="table">
187<colgroup>
188<col>
189<col>
190</colgroup>
191<thead><tr>
192<th>
193                    <p>
194                      Case
195                    </p>
196                  </th>
197<th>
198                    <p>
199                      Behavior
200                    </p>
201                  </th>
202</tr></thead>
203<tbody>
204<tr>
205<td>
206                    <p>
207                      Point
208                    </p>
209                  </td>
210<td>
211                    <p>
212                      Returns the point itself as the centroid
213                    </p>
214                  </td>
215</tr>
216<tr>
217<td>
218                    <p>
219                      Multi Point
220                    </p>
221                  </td>
222<td>
223                    <p>
224                      Calculates centroid (based on average)
225                    </p>
226                  </td>
227</tr>
228<tr>
229<td>
230                    <p>
231                      linear (e.g. linestring)
232                    </p>
233                  </td>
234<td>
235                    <p>
236                      Calculates centroid (based on weighted length)
237                    </p>
238                  </td>
239</tr>
240<tr>
241<td>
242                    <p>
243                      areal (e.g. polygon)
244                    </p>
245                  </td>
246<td>
247                    <p>
248                      Calculates centroid
249                    </p>
250                  </td>
251</tr>
252<tr>
253<td>
254                    <p>
255                      Empty (e.g. polygon without points)
256                    </p>
257                  </td>
258<td>
259                    <p>
260                      Throws a <a class="link" href="../../exceptions/centroid_exception.html" title="centroid_exception">centroid_exception</a>
261                    </p>
262                  </td>
263</tr>
264<tr>
265<td>
266                    <p>
267                      Cartesian
268                    </p>
269                  </td>
270<td>
271                    <p>
272                      Implemented
273                    </p>
274                  </td>
275</tr>
276<tr>
277<td>
278                    <p>
279                      Spherical
280                    </p>
281                  </td>
282<td>
283                    <p>
284                      Calculates the centroid as if based on Cartesian coordinates
285                    </p>
286                  </td>
287</tr>
288</tbody>
289</table></div>
290<h6>
291<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h6"></a>
292            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.supported_geometries"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.supported_geometries">Supported
293            geometries</a>
294          </h6>
295<div class="informaltable"><table class="table">
296<colgroup>
297<col>
298<col>
299<col>
300</colgroup>
301<thead><tr>
302<th>
303                  </th>
304<th>
305                    <p>
306                      2D
307                    </p>
308                  </th>
309<th>
310                    <p>
311                      3D
312                    </p>
313                  </th>
314</tr></thead>
315<tbody>
316<tr>
317<td>
318                    <p>
319                      Point
320                    </p>
321                  </td>
322<td>
323                    <p>
324                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
325                    </p>
326                  </td>
327<td>
328                    <p>
329                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
330                    </p>
331                  </td>
332</tr>
333<tr>
334<td>
335                    <p>
336                      Segment
337                    </p>
338                  </td>
339<td>
340                    <p>
341                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
342                    </p>
343                  </td>
344<td>
345                    <p>
346                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
347                    </p>
348                  </td>
349</tr>
350<tr>
351<td>
352                    <p>
353                      Box
354                    </p>
355                  </td>
356<td>
357                    <p>
358                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
359                    </p>
360                  </td>
361<td>
362                    <p>
363                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
364                    </p>
365                  </td>
366</tr>
367<tr>
368<td>
369                    <p>
370                      Linestring
371                    </p>
372                  </td>
373<td>
374                    <p>
375                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
376                    </p>
377                  </td>
378<td>
379                    <p>
380                      <span class="inlinemediaobject"><img src="../../../../img/nyi.png" alt="nyi"></span>
381                    </p>
382                  </td>
383</tr>
384<tr>
385<td>
386                    <p>
387                      Ring
388                    </p>
389                  </td>
390<td>
391                    <p>
392                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
393                    </p>
394                  </td>
395<td>
396                    <p>
397                      <span class="inlinemediaobject"><img src="../../../../img/nyi.png" alt="nyi"></span>
398                    </p>
399                  </td>
400</tr>
401<tr>
402<td>
403                    <p>
404                      Polygon
405                    </p>
406                  </td>
407<td>
408                    <p>
409                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
410                    </p>
411                  </td>
412<td>
413                    <p>
414                      <span class="inlinemediaobject"><img src="../../../../img/nyi.png" alt="nyi"></span>
415                    </p>
416                  </td>
417</tr>
418<tr>
419<td>
420                    <p>
421                      MultiPoint
422                    </p>
423                  </td>
424<td>
425                    <p>
426                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
427                    </p>
428                  </td>
429<td>
430                    <p>
431                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
432                    </p>
433                  </td>
434</tr>
435<tr>
436<td>
437                    <p>
438                      MultiLinestring
439                    </p>
440                  </td>
441<td>
442                    <p>
443                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
444                    </p>
445                  </td>
446<td>
447                    <p>
448                      <span class="inlinemediaobject"><img src="../../../../img/nyi.png" alt="nyi"></span>
449                    </p>
450                  </td>
451</tr>
452<tr>
453<td>
454                    <p>
455                      MultiPolygon
456                    </p>
457                  </td>
458<td>
459                    <p>
460                      <span class="inlinemediaobject"><img src="../../../../img/ok.png" alt="ok"></span>
461                    </p>
462                  </td>
463<td>
464                    <p>
465                      <span class="inlinemediaobject"><img src="../../../../img/nyi.png" alt="nyi"></span>
466                    </p>
467                  </td>
468</tr>
469</tbody>
470</table></div>
471<h6>
472<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h7"></a>
473            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.complexity"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.complexity">Complexity</a>
474          </h6>
475<p>
476            Linear
477          </p>
478<h6>
479<a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.h8"></a>
480            <span class="phrase"><a name="geometry.reference.algorithms.centroid.centroid_3_with_strategy.available_strategies"></a></span><a class="link" href="centroid_3_with_strategy.html#geometry.reference.algorithms.centroid.centroid_3_with_strategy.available_strategies">Available
481            Strategies</a>
482          </h6>
483<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
484                <a class="link" href="../../strategies/strategy_centroid_bashein_detmer.html" title="strategy::centroid::bashein_detmer">Bashein
485                Detmer (cartesian)</a>
486              </li></ul></div>
487</div>
488<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
489<td align="left"></td>
490<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
491      Wulkiewicz, Oracle and/or its affiliates<p>
492        Distributed under the Boost Software License, Version 1.0. (See accompanying
493        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>)
494      </p>
495</div></td>
496</tr></table>
497<hr>
498<div class="spirit-nav">
499<a accesskey="p" href="../centroid.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../centroid.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="centroid_2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
500</div>
501</body>
502</html>
503