• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Polygon Concept</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="../concepts.html" title="Concepts">
9<link rel="prev" href="concept_linestring.html" title="Linestring Concept">
10<link rel="next" href="concept_multi_point.html" title="MultiPoint Concept">
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="concept_linestring.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.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="concept_multi_point.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="geometry.reference.concepts.concept_polygon"></a><a class="link" href="concept_polygon.html" title="Polygon Concept">Polygon
28        Concept</a>
29</h4></div></div></div>
30<h6>
31<a name="geometry.reference.concepts.concept_polygon.h0"></a>
32          <span class="phrase"><a name="geometry.reference.concepts.concept_polygon.description"></a></span><a class="link" href="concept_polygon.html#geometry.reference.concepts.concept_polygon.description">Description</a>
33        </h6>
34<p>
35          The Polygon Concept describes the requirements for a polygon type. All
36          algorithms in Boost.Geometry will check any geometry arguments against
37          the concept requirements.
38        </p>
39<p>
40          A polygon is <span class="emphasis"><em>A polygon is a planar surface defined by one exterior
41          boundary and zero or more interior boundaries</em></span> (<a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC
42          Simple Feature Specification</a>).
43        </p>
44<p>
45          So the definition of a Boost.Geometry polygon differs a bit from e.g. Wiki,
46          where a polygon does not have holes. A polygon of Boost.Geometry is a polygon
47          with or without holes. <span class="emphasis"><em>(A polygon without holes is a <span class="emphasis"><em>helper
48          geometry</em></span> within Boost.Geometry, and referred to as a ring.)</em></span>
49        </p>
50<h6>
51<a name="geometry.reference.concepts.concept_polygon.h1"></a>
52          <span class="phrase"><a name="geometry.reference.concepts.concept_polygon.concept_definition"></a></span><a class="link" href="concept_polygon.html#geometry.reference.concepts.concept_polygon.concept_definition">Concept
53          Definition</a>
54        </h6>
55<p>
56          The Polygon Concept is defined as following:
57        </p>
58<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
59<li class="listitem">
60              there must be a specialization of <code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">tag</span></code>
61              defining <code class="computeroutput"><span class="identifier">polygon_tag</span></code>
62              as type
63            </li>
64<li class="listitem">
65              there must be a specialization of <code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">ring_type</span></code>
66              defining the type of its exterior ring and interior rings as type
67            </li>
68<li class="listitem">
69              this type defined by <code class="computeroutput"><span class="identifier">ring_type</span></code>
70              must fulfill the <a class="link" href="concept_ring.html" title="Ring Concept">Ring
71              Concept</a>
72            </li>
73<li class="listitem">
74              there must be a specialization of <code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">interior_type</span></code>
75              defining the type of the collection of its interior rings as type;
76              this collection itself must fulfill a Boost.Range Random Access Range
77              Concept
78            </li>
79<li class="listitem">
80              there must be a specialization of <code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">exterior_ring</span></code>
81              with two functions named <code class="computeroutput"><span class="identifier">get</span></code>,
82              returning the exterior ring, one being const, the other being non const
83            </li>
84<li class="listitem">
85              there must be a specialization of <code class="computeroutput"><span class="identifier">traits</span><span class="special">::</span><span class="identifier">interior_rings</span></code>
86              with two functions named <code class="computeroutput"><span class="identifier">get</span></code>,
87              returning the interior rings, one being const, the other being non
88              const
89            </li>
90</ul></div>
91<h6>
92<a name="geometry.reference.concepts.concept_polygon.h2"></a>
93          <span class="phrase"><a name="geometry.reference.concepts.concept_polygon.rules"></a></span><a class="link" href="concept_polygon.html#geometry.reference.concepts.concept_polygon.rules">Rules</a>
94        </h6>
95<p>
96          Besides the Concepts, which are checks on compile-time, there are some
97          other rules that valid polygons must fulfill. This follows the opengeospatial
98          rules (see link above).
99        </p>
100<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
101<li class="listitem">
102              Polygons are simple geometric objects (See also <a href="http://en.wikipedia.org/wiki/Simple_polygon" target="_top">wiki</a>
103              but holes are allowed in Boost.Geometry polygons).
104            </li>
105<li class="listitem">
106              If the polygons underlying <code class="computeroutput"><span class="identifier">ring_type</span></code>
107              is defined as clockwise, the exterior ring must have the clockwise
108              orientation, and any interior ring must be reversed w.r.t. the defined
109              orientation (so: counter clockwise for clockwise exterior rings). If
110              the <code class="computeroutput"><span class="identifier">ring_type</span></code> is defined
111              counter clockwise, it is vice versa.
112            </li>
113<li class="listitem">
114              If the polygons underlying <code class="computeroutput"><span class="identifier">ring_type</span></code>
115              is defined as closed, all rings must be closed: the first point must
116              be spatially equal to the last point.
117            </li>
118<li class="listitem">
119              The interior is a connected point set.
120            </li>
121<li class="listitem">
122              There should be no self intersections, but self tangencies (between
123              exterior/interior rings) are allowed (as long as the interior is a
124              connected point set.
125            </li>
126<li class="listitem">
127              There should be no cut lines, spikes or punctures.
128            </li>
129<li class="listitem">
130              The interior rings should be located within the exterior ring. Interior
131              rings may not be located within each other.
132            </li>
133</ul></div>
134<p>
135          The algorithms such as intersection, area, centroid, union, etc. do not
136          check validity. There will be an algorithm is_valid which checks for validity
137          against these rules, at runtime, and which can be called (by the library
138          user) before.
139        </p>
140<p>
141          If the input is invalid, the output might be invalid too. For example:
142          if a polygon which should be closed is not closed, the area will be incorrect.
143        </p>
144<h6>
145<a name="geometry.reference.concepts.concept_polygon.h3"></a>
146          <span class="phrase"><a name="geometry.reference.concepts.concept_polygon.available_models"></a></span><a class="link" href="concept_polygon.html#geometry.reference.concepts.concept_polygon.available_models">Available
147          Models</a>
148        </h6>
149<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
150<li class="listitem">
151              <a class="link" href="../models/model_polygon.html" title="model::polygon">polygon</a>
152            </li>
153<li class="listitem">
154              a Boost.Polygon polygon_with_holes_data (requires <code class="computeroutput"><span class="preprocessor">#include</span>
155              <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">adapted</span><span class="special">/</span><span class="identifier">boost_polygon</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>)
156            </li>
157</ul></div>
158</div>
159<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
160<td align="left"></td>
161<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
162      Wulkiewicz, Oracle and/or its affiliates<p>
163        Distributed under the Boost Software License, Version 1.0. (See accompanying
164        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>)
165      </p>
166</div></td>
167</tr></table>
168<hr>
169<div class="spirit-nav">
170<a accesskey="p" href="concept_linestring.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.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="concept_multi_point.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
171</div>
172</body>
173</html>
174