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