• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>envelope</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="../envelope.html" title="envelope">
9<link rel="prev" href="envelope_3_with_strategy.html" title="envelope (with strategy)">
10<link rel="next" href="return_envelope_2_with_strategy.html" title="return_envelope (with strategy)">
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="envelope_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../envelope.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="return_envelope_2_with_strategy.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.envelope.envelope_2"></a><a class="link" href="envelope_2.html" title="envelope">envelope</a>
28</h5></div></div></div>
29<p>
30            <a class="indexterm" name="idm45635698317936"></a>
31Calculates the envelope of a geometry.
32          </p>
33<h6>
34<a name="geometry.reference.algorithms.envelope.envelope_2.h0"></a>
35            <span class="phrase"><a name="geometry.reference.algorithms.envelope.envelope_2.description"></a></span><a class="link" href="envelope_2.html#geometry.reference.algorithms.envelope.envelope_2.description">Description</a>
36          </h6>
37<p>
38            The free function envelope calculates the envelope (also known as axis
39            aligned bounding box, aabb, or minimum bounding rectangle, mbr) of a
40            geometry.
41          </p>
42<h6>
43<a name="geometry.reference.algorithms.envelope.envelope_2.h1"></a>
44            <span class="phrase"><a name="geometry.reference.algorithms.envelope.envelope_2.synopsis"></a></span><a class="link" href="envelope_2.html#geometry.reference.algorithms.envelope.envelope_2.synopsis">Synopsis</a>
45          </h6>
46<p>
47</p>
48<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">Box</span><span class="special">&gt;</span>
49<span class="keyword">void</span> <span class="identifier">envelope</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">Box</span> <span class="special">&amp;</span> <span class="identifier">mbr</span><span class="special">)</span></pre>
50<p>
51          </p>
52<h6>
53<a name="geometry.reference.algorithms.envelope.envelope_2.h2"></a>
54            <span class="phrase"><a name="geometry.reference.algorithms.envelope.envelope_2.parameters"></a></span><a class="link" href="envelope_2.html#geometry.reference.algorithms.envelope.envelope_2.parameters">Parameters</a>
55          </h6>
56<div class="informaltable"><table class="table">
57<colgroup>
58<col>
59<col>
60<col>
61<col>
62</colgroup>
63<thead><tr>
64<th>
65                    <p>
66                      Type
67                    </p>
68                  </th>
69<th>
70                    <p>
71                      Concept
72                    </p>
73                  </th>
74<th>
75                    <p>
76                      Name
77                    </p>
78                  </th>
79<th>
80                    <p>
81                      Description
82                    </p>
83                  </th>
84</tr></thead>
85<tbody>
86<tr>
87<td>
88                    <p>
89                      Geometry const &amp;
90                    </p>
91                  </td>
92<td>
93                    <p>
94                      Any type fulfilling a Geometry Concept
95                    </p>
96                  </td>
97<td>
98                    <p>
99                      geometry
100                    </p>
101                  </td>
102<td>
103                    <p>
104                      A model of the specified concept
105                    </p>
106                  </td>
107</tr>
108<tr>
109<td>
110                    <p>
111                      Box &amp;
112                    </p>
113                  </td>
114<td>
115                    <p>
116                      Any type fulfilling a Box Concept
117                    </p>
118                  </td>
119<td>
120                    <p>
121                      mbr
122                    </p>
123                  </td>
124<td>
125                    <p>
126                      A model of the specified Box Concept which is set to the envelope
127                    </p>
128                  </td>
129</tr>
130</tbody>
131</table></div>
132<h6>
133<a name="geometry.reference.algorithms.envelope.envelope_2.h3"></a>
134            <span class="phrase"><a name="geometry.reference.algorithms.envelope.envelope_2.header"></a></span><a class="link" href="envelope_2.html#geometry.reference.algorithms.envelope.envelope_2.header">Header</a>
135          </h6>
136<p>
137            Either
138          </p>
139<p>
140            <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>
141          </p>
142<p>
143            Or
144          </p>
145<p>
146            <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">envelope</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
147          </p>
148<h6>
149<a name="geometry.reference.algorithms.envelope.envelope_2.h4"></a>
150            <span class="phrase"><a name="geometry.reference.algorithms.envelope.envelope_2.conformance"></a></span><a class="link" href="envelope_2.html#geometry.reference.algorithms.envelope.envelope_2.conformance">Conformance</a>
151          </h6>
152<p>
153            The function envelope implements function Envelope from the <a href="http://www.opengeospatial.org/standards/sfa" target="_top">OGC
154            Simple Feature Specification</a>.
155          </p>
156<h6>
157<a name="geometry.reference.algorithms.envelope.envelope_2.h5"></a>
158            <span class="phrase"><a name="geometry.reference.algorithms.envelope.envelope_2.example"></a></span><a class="link" href="envelope_2.html#geometry.reference.algorithms.envelope.envelope_2.example">Example</a>
159          </h6>
160<p>
161            Shows how to calculate the bounding box of a polygon
162          </p>
163<p>
164</p>
165<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
166
167<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>
168<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">geometries</span><span class="special">/</span><span class="identifier">box</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
169<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">geometries</span><span class="special">/</span><span class="identifier">point_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
170<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">geometries</span><span class="special">/</span><span class="identifier">polygon</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
171
172
173<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
174<span class="special">{</span>
175    <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</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">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">point</span><span class="special">;</span>
176
177    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">polygon</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;</span> <span class="identifier">polygon</span><span class="special">;</span>
178
179    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">read_wkt</span><span class="special">(</span>
180        <span class="string">"POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)"</span>
181            <span class="string">"(4.0 2.0, 4.2 1.4, 4.8 1.9, 4.4 2.2, 4.0 2.0))"</span><span class="special">,</span> <span class="identifier">polygon</span><span class="special">);</span>
182
183    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">box</span><span class="special">&lt;</span><span class="identifier">point</span><span class="special">&gt;</span> <span class="identifier">box</span><span class="special">;</span>
184    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">envelope</span><span class="special">(</span><span class="identifier">polygon</span><span class="special">,</span> <span class="identifier">box</span><span class="special">);</span>
185
186    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"envelope:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dsv</span><span class="special">(</span><span class="identifier">box</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
187
188
189    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
190<span class="special">}</span>
191</pre>
192<p>
193          </p>
194<p>
195            Output:
196          </p>
197<pre class="programlisting">envelope:((2, 0.7), (5.4, 3))
198
199<img src="../../../../img/algorithms/envelope.png" alt="envelope">
200</pre>
201</div>
202<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
203<td align="left"></td>
204<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
205      Wulkiewicz, Oracle and/or its affiliates<p>
206        Distributed under the Boost Software License, Version 1.0. (See accompanying
207        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>)
208      </p>
209</div></td>
210</tr></table>
211<hr>
212<div class="spirit-nav">
213<a accesskey="p" href="envelope_3_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../envelope.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="return_envelope_2_with_strategy.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
214</div>
215</body>
216</html>
217