1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>line_interpolate</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_4_with_strategy.html" title="line_interpolate (with strategy)"> 10<link rel="next" href="../make.html" title="make"> 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_4_with_strategy.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="../make.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_3"></a><a class="link" href="line_interpolate_3.html" title="line_interpolate">line_interpolate</a> 28</h5></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635692602720"></a> 31Returns one or more points interpolated along a LineString. 32 </p> 33<h6> 34<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h0"></a> 35 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.synopsis"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_3.synopsis">Synopsis</a> 36 </h6> 37<p> 38</p> 39<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> 40<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></pre> 41<p> 42 </p> 43<h6> 44<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h1"></a> 45 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.parameters"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_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 & 81 </p> 82 </td> 83<td> 84 <p> 85 Any type fulfilling a LineString concept 86 </p> 87 </td> 88<td> 89 <p> 90 geometry 91 </p> 92 </td> 93<td> 94 <p> 95 Input geometry 96 </p> 97 </td> 98</tr> 99<tr> 100<td> 101 <p> 102 Distance const & 103 </p> 104 </td> 105<td> 106 <p> 107 A numerical distance measure 108 </p> 109 </td> 110<td> 111 <p> 112 max_distance 113 </p> 114 </td> 115<td> 116 <p> 117 Distance threshold (in units depending on coordinate system) 118 representing the spacing between the points 119 </p> 120 </td> 121</tr> 122<tr> 123<td> 124 <p> 125 Pointlike & 126 </p> 127 </td> 128<td> 129 <p> 130 Any type fulfilling Point or Multipoint concept 131 </p> 132 </td> 133<td> 134 <p> 135 pointlike 136 </p> 137 </td> 138<td> 139 <p> 140 Output: either a Point (exactly one point will be constructed) 141 or a MultiPoint (depending on the max_distance one or more 142 points will be constructed) 143 </p> 144 </td> 145</tr> 146</tbody> 147</table></div> 148<h6> 149<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h2"></a> 150 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.header"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_3.header">Header</a> 151 </h6> 152<p> 153 Either 154 </p> 155<p> 156 <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> 157 </p> 158<p> 159 Or 160 </p> 161<p> 162 <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> 163 </p> 164<h6> 165<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h3"></a> 166 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.conformance"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_3.conformance">Conformance</a> 167 </h6> 168<p> 169 The function line_interpolate_point is not defined by OGC. 170 </p> 171<div class="note"><table border="0" summary="Note"> 172<tr> 173<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../../doc/src/images/note.png"></td> 174<th align="left">Note</th> 175</tr> 176<tr><td align="left" valign="top"><p> 177 PostGIS contains an algorithm ST_LineInterpolatePoints with similar 178 functionality. See the <a href="https://postgis.net/docs/ST_LineInterpolatePoints.html" target="_top">PostGIS 179 documentation</a>. 180 </p></td></tr> 181</table></div> 182<h6> 183<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h4"></a> 184 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.behavior"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_3.behavior">Behavior</a> 185 </h6> 186<p> 187 The algorithm iterates among segments of the linestring and computes 188 interpolation points if needed. 189 </p> 190<h6> 191<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h5"></a> 192 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.example"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_3.example">Example</a> 193 </h6> 194<p> 195 Shows how to interpolate points on a linestring 196 </p> 197<p> 198</p> 199<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 200 201<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> 202<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> 203 204<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> 205 206<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 207<span class="special">{</span> 208 <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"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">point_type</span><span class="special">;</span> 209 <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> 210 <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> 211 <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> 212 213 <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> 214 <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">0</span><span class="special">},</span> <span class="special">{</span><span class="number">1</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><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">0</span><span class="special">,</span> <span class="number">2</span><span class="special">}</span> <span class="special">};</span> 215 <span class="identifier">point_type</span> <span class="identifier">p</span><span class="special">;</span> 216 <span class="identifier">multipoint_type</span> <span class="identifier">mp</span><span class="special">;</span> 217 218 <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> 219 220 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">sqrt</span><span class="special">(</span><span class="number">2</span><span class="special">)/</span><span class="number">4</span><span class="special">,</span> <span class="identifier">p</span><span class="special">);</span> 221 <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> 222 223 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">l</span><span class="special">,</span> <span class="number">1.4</span><span class="special">,</span> <span class="identifier">p</span><span class="special">);</span> 224 <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> 225 226 <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> 227 228 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">sqrt</span><span class="special">(</span><span class="number">2</span><span class="special">)/</span><span class="number">4</span><span class="special">,</span> <span class="identifier">mp</span><span class="special">);</span> 229 <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> 230 231 <span class="identifier">mp</span><span class="special">=</span><span class="identifier">multipoint_type</span><span class="special">();</span> 232 <span class="identifier">line_interpolate</span><span class="special">(</span><span class="identifier">l</span><span class="special">,</span> <span class="number">1.4</span><span class="special">,</span> <span class="identifier">mp</span><span class="special">);</span> 233 <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> 234 235 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 236<span class="special">}</span> 237</pre> 238<p> 239 </p> 240<p> 241 Output: 242 </p> 243<pre class="programlisting">point interpolation 244on segment : POINT(0.25 0.25) 245on linestring : POINT(1 0.4) 246 247multipoint interpolation 248on segment : MULTIPOINT((0.25 0.25),(0.5 0.5),(0.75 0.75),(1 1)) 249on linestring : MULTIPOINT((1 0.4),(0.2 1)) 250</pre> 251<h6> 252<a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.h6"></a> 253 <span class="phrase"><a name="geometry.reference.algorithms.line_interpolate.line_interpolate_3.see_also"></a></span><a class="link" href="line_interpolate_3.html#geometry.reference.algorithms.line_interpolate.line_interpolate_3.see_also">See 254 also</a> 255 </h6> 256<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"> 257 <a class="link" href="../densify.html" title="densify">densify</a> 258 </li></ul></div> 259</div> 260<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 261<td align="left"></td> 262<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 263 Wulkiewicz, Oracle and/or its affiliates<p> 264 Distributed under the Boost Software License, Version 1.0. (See accompanying 265 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>) 266 </p> 267</div></td> 268</tr></table> 269<hr> 270<div class="spirit-nav"> 271<a accesskey="p" href="line_interpolate_4_with_strategy.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="../make.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 272</div> 273</body> 274</html> 275