• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>densify</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="../densify.html" title="densify">
9<link rel="prev" href="densify_4_with_strategy.html" title="densify (with strategy)">
10<link rel="next" href="../difference.html" title="difference">
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="densify_4_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../densify.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="../difference.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.densify.densify_3"></a><a class="link" href="densify_3.html" title="densify">densify</a>
28</h5></div></div></div>
29<p>
30            <a class="indexterm" name="idm45635701769072"></a>
31Densify a geometry.
32          </p>
33<h6>
34<a name="geometry.reference.algorithms.densify.densify_3.h0"></a>
35            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.synopsis"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.synopsis">Synopsis</a>
36          </h6>
37<p>
38</p>
39<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">Distance</span><span class="special">&gt;</span>
40<span class="keyword">void</span> <span class="identifier">densify</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">Geometry</span> <span class="special">&amp;</span> <span class="identifier">out</span><span class="special">,</span> <span class="identifier">Distance</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">max_distance</span><span class="special">)</span></pre>
41<p>
42          </p>
43<h6>
44<a name="geometry.reference.algorithms.densify.densify_3.h1"></a>
45            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.parameters"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.parameters">Parameters</a>
46          </h6>
47<div class="informaltable"><table class="table">
48<colgroup>
49<col>
50<col>
51<col>
52<col>
53</colgroup>
54<thead><tr>
55<th>
56                    <p>
57                      Type
58                    </p>
59                  </th>
60<th>
61                    <p>
62                      Concept
63                    </p>
64                  </th>
65<th>
66                    <p>
67                      Name
68                    </p>
69                  </th>
70<th>
71                    <p>
72                      Description
73                    </p>
74                  </th>
75</tr></thead>
76<tbody>
77<tr>
78<td>
79                    <p>
80                      Geometry const &amp;
81                    </p>
82                  </td>
83<td>
84                    <p>
85                      Any type fulfilling a Geometry Concept
86                    </p>
87                  </td>
88<td>
89                    <p>
90                      geometry
91                    </p>
92                  </td>
93<td>
94                    <p>
95                      Input geometry, to be densified
96                    </p>
97                  </td>
98</tr>
99<tr>
100<td>
101                    <p>
102                      Geometry &amp;
103                    </p>
104                  </td>
105<td>
106                    <p>
107                      Any type fulfilling a Geometry Concept
108                    </p>
109                  </td>
110<td>
111                    <p>
112                      out
113                    </p>
114                  </td>
115<td>
116                    <p>
117                      Output geometry, densified version of the input geometry
118                    </p>
119                  </td>
120</tr>
121<tr>
122<td>
123                    <p>
124                      Distance const &amp;
125                    </p>
126                  </td>
127<td>
128                    <p>
129                      A numerical distance measure
130                    </p>
131                  </td>
132<td>
133                    <p>
134                      max_distance
135                    </p>
136                  </td>
137<td>
138                    <p>
139                      Distance threshold (in units depending on coordinate system)
140                    </p>
141                  </td>
142</tr>
143</tbody>
144</table></div>
145<h6>
146<a name="geometry.reference.algorithms.densify.densify_3.h2"></a>
147            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.header"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.header">Header</a>
148          </h6>
149<p>
150            Either
151          </p>
152<p>
153            <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>
154          </p>
155<p>
156            Or
157          </p>
158<p>
159            <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">densify</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
160          </p>
161<h6>
162<a name="geometry.reference.algorithms.densify.densify_3.h3"></a>
163            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.conformance"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.conformance">Conformance</a>
164          </h6>
165<p>
166            The function densify is not defined by OGC.
167          </p>
168<div class="note"><table border="0" summary="Note">
169<tr>
170<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td>
171<th align="left">Note</th>
172</tr>
173<tr><td align="left" valign="top"><p>
174              PostGIS contains an algorithm ST_Segmentize with the same functionality.
175              See the <a href="http://www.postgis.org/docs/ST_Segmentize.html" target="_top">PostGIS
176              documentation</a>.
177            </p></td></tr>
178</table></div>
179<h6>
180<a name="geometry.reference.algorithms.densify.densify_3.h4"></a>
181            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.behavior"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.behavior">Behavior</a>
182          </h6>
183<p>
184            The algorithm divides segments of a geometry if they are longer than
185            passed distance into smaller segments.
186          </p>
187<div class="note"><table border="0" summary="Note">
188<tr>
189<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td>
190<th align="left">Note</th>
191</tr>
192<tr><td align="left" valign="top"><p>
193              The units of the distance depends on strategy. In order to change the
194              default behavior a user has to create a strategy and pass it explicitly
195              into the algorithm.
196            </p></td></tr>
197</table></div>
198<h6>
199<a name="geometry.reference.algorithms.densify.densify_3.h5"></a>
200            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.example"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.example">Example</a>
201          </h6>
202<p>
203            Shows how to densify a polygon
204          </p>
205<p>
206</p>
207<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
208
209<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>
210<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>
211<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>
212
213<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
214<span class="special">{</span>
215    <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_type</span><span class="special">;</span>
216    <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">polygon</span><span class="special">&lt;</span><span class="identifier">point_type</span><span class="special">&gt;</span> <span class="identifier">polygon_type</span><span class="special">;</span>
217
218    <span class="identifier">polygon_type</span> <span class="identifier">poly</span><span class="special">;</span>
219    <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>
220        <span class="string">"POLYGON((0 0,0 10,10 10,10 0,0 0),(1 1,4 1,4 4,1 4,1 1))"</span><span class="special">,</span> <span class="identifier">poly</span><span class="special">);</span>
221
222    <span class="identifier">polygon_type</span> <span class="identifier">res</span><span class="special">;</span>
223
224    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">densify</span><span class="special">(</span><span class="identifier">poly</span><span class="special">,</span> <span class="identifier">res</span><span class="special">,</span> <span class="number">6.0</span><span class="special">);</span>
225
226    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"densified: "</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">wkt</span><span class="special">(</span><span class="identifier">res</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>
227
228    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
229<span class="special">}</span>
230</pre>
231<p>
232          </p>
233<p>
234            Output:
235          </p>
236<pre class="programlisting">densified: POLYGON((0 0,0 5,0 10,5 10,10 10,10 5,10 0,5 0,0 0),(1 1,4 1,4 4,1 4,1 1))
237</pre>
238<h6>
239<a name="geometry.reference.algorithms.densify.densify_3.h6"></a>
240            <span class="phrase"><a name="geometry.reference.algorithms.densify.densify_3.see_also"></a></span><a class="link" href="densify_3.html#geometry.reference.algorithms.densify.densify_3.see_also">See
241            also</a>
242          </h6>
243<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
244                <a class="link" href="../line_interpolate.html" title="line_interpolate">line_interpolate</a>
245              </li></ul></div>
246</div>
247<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
248<td align="left"></td>
249<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam
250      Wulkiewicz, Oracle and/or its affiliates<p>
251        Distributed under the Boost Software License, Version 1.0. (See accompanying
252        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>)
253      </p>
254</div></td>
255</tr></table>
256<hr>
257<div class="spirit-nav">
258<a accesskey="p" href="densify_4_with_strategy.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../densify.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="../difference.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
259</div>
260</body>
261</html>
262