1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>line_interpolate (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="../line_interpolate.html" title="line_interpolate"> 9<link rel="prev" href="../line_interpolate.html" title="line_interpolate"> 10<link rel="next" href="line_interpolate_3.html" title="line_interpolate"> 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="../line_interpolate.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../line_interpolate.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="line_interpolate_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.line_interpolate.line_interpolate_4_with_strategy"></a><a class="link" href="line_interpolate_4_with_strategy.html" title="line_interpolate (with strategy)">line_interpolate 28 (with strategy)</a> 29</h5></div></div></div> 30<p> 31 <a class="indexterm" name="idm45635692878192"></a> 32Returns one or more points interpolated along a LineString using the 33 specified strategy. 34 </p> 35<h6> 36<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h0"></a> 37 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.synopsis"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.synopsis">Synopsis</a> 38 </h6> 39<p> 40</p> 41<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">Pointlike</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Strategy</span><span class="special">></span> 42<span class="keyword">void</span> <span class="identifier">line_interpolate</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">Distance</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">max_distance</span><span class="special">,</span> <span class="identifier">Pointlike</span> <span class="special">&</span> <span class="identifier">pointlike</span><span class="special">,</span> 43 <span class="identifier">Strategy</span> <span class="keyword">const</span> <span class="special">&</span> <span class="identifier">strategy</span><span class="special">)</span></pre> 44<p> 45 </p> 46<h6> 47<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h1"></a> 48 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.parameters"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.parameters">Parameters</a> 49 </h6> 50<div class="informaltable"><table class="table"> 51<colgroup> 52<col> 53<col> 54<col> 55<col> 56</colgroup> 57<thead><tr> 58<th> 59 <p> 60 Type 61 </p> 62 </th> 63<th> 64 <p> 65 Concept 66 </p> 67 </th> 68<th> 69 <p> 70 Name 71 </p> 72 </th> 73<th> 74 <p> 75 Description 76 </p> 77 </th> 78</tr></thead> 79<tbody> 80<tr> 81<td> 82 <p> 83 Geometry const & 84 </p> 85 </td> 86<td> 87 <p> 88 Any type fulfilling a LineString concept 89 </p> 90 </td> 91<td> 92 <p> 93 geometry 94 </p> 95 </td> 96<td> 97 <p> 98 Input geometry 99 </p> 100 </td> 101</tr> 102<tr> 103<td> 104 <p> 105 Distance const & 106 </p> 107 </td> 108<td> 109 <p> 110 A numerical distance measure 111 </p> 112 </td> 113<td> 114 <p> 115 max_distance 116 </p> 117 </td> 118<td> 119 <p> 120 Distance threshold (in units depending on coordinate system) 121 representing the spacing between the points 122 </p> 123 </td> 124</tr> 125<tr> 126<td> 127 <p> 128 Pointlike & 129 </p> 130 </td> 131<td> 132 <p> 133 Any type fulfilling Point or Multipoint concept 134 </p> 135 </td> 136<td> 137 <p> 138 pointlike 139 </p> 140 </td> 141<td> 142 <p> 143 Output: either a Point (exactly one point will be constructed) 144 or a MultiPoint (depending on the max_distance one or more 145 points will be constructed) 146 </p> 147 </td> 148</tr> 149<tr> 150<td> 151 <p> 152 Strategy const & 153 </p> 154 </td> 155<td> 156 <p> 157 A type fulfilling a LineInterpolatePointStrategy concept 158 </p> 159 </td> 160<td> 161 <p> 162 strategy 163 </p> 164 </td> 165<td> 166 <p> 167 line_interpolate strategy to be used for interpolation of points 168 </p> 169 </td> 170</tr> 171</tbody> 172</table></div> 173<h6> 174<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h2"></a> 175 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.header"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.header">Header</a> 176 </h6> 177<p> 178 Either 179 </p> 180<p> 181 <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> 182 </p> 183<p> 184 Or 185 </p> 186<p> 187 <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">line_interpolate</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 188 </p> 189<h6> 190<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h3"></a> 191 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.conformance"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.conformance">Conformance</a> 192 </h6> 193<p> 194 The function line_interpolate_point is not defined by OGC. 195 </p> 196<div class="note"><table border="0" summary="Note"> 197<tr> 198<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td> 199<th align="left">Note</th> 200</tr> 201<tr><td align="left" valign="top"><p> 202 PostGIS contains an algorithm ST_LineInterpolatePoints with similar 203 functionality. See the <a href="https://postgis.net/docs/ST_LineInterpolatePoints.html" target="_top">PostGIS 204 documentation</a>. 205 </p></td></tr> 206</table></div> 207<h6> 208<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h4"></a> 209 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.behavior"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.behavior">Behavior</a> 210 </h6> 211<p> 212 The algorithm iterates among segments of the linestring and computes 213 interpolation points if needed. 214 </p> 215<h6> 216<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h5"></a> 217 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.available_strategies"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.available_strategies">Available 218 Strategies</a> 219 </h6> 220<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 221<li class="listitem"> 222 <a class="link" href="../../strategies/strategy_line_interpolate_cartesian.html" title="strategy::line_interpolate::cartesian">Cartesian</a> 223 </li> 224<li class="listitem"> 225 <a class="link" href="../../strategies/strategy_line_interpolate_spherical.html" title="strategy::line_interpolate::spherical">Spherical</a> 226 </li> 227<li class="listitem"> 228 <a class="link" href="../../strategies/strategy_line_interpolate_geographic.html" title="strategy::line_interpolate::geographic">Geographic</a> 229 </li> 230</ul></div> 231<h6> 232<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h6"></a> 233 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.example"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.example">Example</a> 234 </h6> 235<p> 236 Shows how to interpolate points on a linestring in geographic coordinate 237 system 238 </p> 239<p> 240</p> 241<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 242 243<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> 244<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_xy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 245 246<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">;</span> 247 248<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 249<span class="special">{</span> 250 <span class="keyword">typedef</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"><</span><span class="keyword">double</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">degree</span><span class="special">></span> <span class="special">></span> <span class="identifier">point_type</span><span class="special">;</span> 251 <span class="keyword">using</span> <span class="identifier">segment_type</span> <span class="special">=</span> <span class="identifier">model</span><span class="special">::</span><span class="identifier">segment</span><span class="special"><</span><span class="identifier">point_type</span><span class="special">>;</span> 252 <span class="keyword">using</span> <span class="identifier">linestring_type</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> 253 <span class="keyword">using</span> <span class="identifier">multipoint_type</span> <span class="special">=</span> <span class="identifier">model</span><span class="special">::</span><span class="identifier">multi_point</span><span class="special"><</span><span class="identifier">point_type</span><span class="special">>;</span> 254 255 <span class="identifier">segment_type</span> <span class="keyword">const</span> <span class="identifier">s</span> <span class="special">{</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span> <span class="number">0</span><span class="special">},</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">1</span><span class="special">}</span> <span class="special">};</span> 256 <span class="identifier">linestring_type</span> <span class="keyword">const</span> <span class="identifier">l</span> <span class="special">{</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span> <span class="number">1</span><span class="special">},</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">1</span><span class="special">},</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">},</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span> <span class="number">2</span><span class="special">},</span> <span class="special">{</span><span class="number">0</span><span class="special">,</span> <span class="number">3</span><span class="special">}</span> <span class="special">};</span> 257 <span class="identifier">point_type</span> <span class="identifier">p</span><span class="special">;</span> 258 <span class="identifier">multipoint_type</span> <span class="identifier">mp</span><span class="special">;</span> 259 <span class="keyword">double</span> <span class="identifier">distance</span> <span class="special">=</span> <span class="number">50000</span><span class="special">;</span> 260 261 <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> 262 <span class="identifier">strategy</span><span class="special">::</span><span class="identifier">line_interpolate</span> 263 <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">vincenty</span><span class="special">></span> <span class="identifier">str</span><span class="special">(</span><span class="identifier">spheroid</span><span class="special">);</span> 264 265 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"point interpolation"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 266 267 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">distance</span><span class="special">,</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">str</span><span class="special">);</span> 268 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"on segment : "</span> <span class="special"><<</span> <span class="identifier">wkt</span><span class="special">(</span><span class="identifier">p</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> 269 270 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">l</span><span class="special">,</span> <span class="identifier">distance</span><span class="special">,</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">str</span><span class="special">);</span> 271 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"on linestring : "</span> <span class="special"><<</span> <span class="identifier">wkt</span><span class="special">(</span><span class="identifier">p</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> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 272 273 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"multipoint interpolation"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 274 275 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">distance</span><span class="special">,</span> <span class="identifier">mp</span><span class="special">,</span> <span class="identifier">str</span><span class="special">);</span> 276 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"on segment : "</span> <span class="special"><<</span> <span class="identifier">wkt</span><span class="special">(</span><span class="identifier">mp</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> 277 278 <span class="identifier">mp</span><span class="special">=</span><span class="identifier">multipoint_type</span><span class="special">();</span> 279 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">l</span><span class="special">,</span><span class="identifier">distance</span><span class="special">,</span> <span class="identifier">mp</span><span class="special">,</span> <span class="identifier">str</span><span class="special">);</span> 280 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"on linestring : "</span> <span class="special"><<</span> <span class="identifier">wkt</span><span class="special">(</span><span class="identifier">mp</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> 281 282 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 283<span class="special">}</span> 284</pre> 285<p> 286 </p> 287<p> 288 Output: 289 </p> 290<pre class="programlisting">point interpolation 291on segment : POINT(0.318646 0.31869) 292on linestring : POINT(0.449226 1.00004) 293 294multipoint interpolation 295on segment : MULTIPOINT((0.318646 0.31869),(0.637312 0.63737),(0.956017 0.95603)) 296on linestring : MULTIPOINT((0.449226 1.00004),(0.898451 1.00001),(1 1.34997), 297(1 1.80215),(0.74722 2.00006),(0.297791 2.00006),(0 2.15257),(0 2.60474)) 298</pre> 299<h6> 300<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.h7"></a> 301 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.see_also"></a></span><a class="link" href="line_interpolate_4_with_strategy.html#geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy.see_also">See 302 also</a> 303 </h6> 304<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 305 <a class="link" href="../densify.html" title="densify">densify</a> 306 </li></ul></div> 307</div> 308<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 309<td align="left"></td> 310<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 311 Wulkiewicz, Oracle and/or its affiliates<p> 312 Distributed under the Boost Software License, Version 1.0. (See accompanying 313 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>) 314 </p> 315</div></td> 316</tr></table> 317<hr> 318<div class="spirit-nav"> 319<a accesskey="p" href="../line_interpolate.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../line_interpolate.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="line_interpolate_3.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 320</div> 321</body> 322</html> 323