1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>model::multi_linestring</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="../models.html" title="Models"> 9<link rel="prev" href="model_multi_point.html" title="model::multi_point"> 10<link rel="next" href="model_multi_polygon.html" title="model::multi_polygon"> 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="model_multi_point.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../models.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="model_multi_polygon.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="geometry.reference.models.model_multi_linestring"></a><a class="link" href="model_multi_linestring.html" title="model::multi_linestring">model::multi_linestring</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635679395632"></a><a class="indexterm" name="idm45635679394944"></a> 31multi_line, a collection of linestring 32 </p> 33<h6> 34<a name="geometry.reference.models.model_multi_linestring.h0"></a> 35 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.description"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.description">Description</a> 36 </h6> 37<p> 38 Multi-linestring can be used to group lines belonging to each other, e.g. 39 a highway (with interruptions) 40 </p> 41<h6> 42<a name="geometry.reference.models.model_multi_linestring.h1"></a> 43 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.model_of"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.model_of">Model 44 of</a> 45 </h6> 46<p> 47 <a class="link" href="../concepts/concept_multi_linestring.html" title="MultiLinestring Concept">MultiLineString 48 Concept</a> 49 </p> 50<h6> 51<a name="geometry.reference.models.model_multi_linestring.h2"></a> 52 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.synopsis"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.synopsis">Synopsis</a> 53 </h6> 54<p> 55</p> 56<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">LineString</span><span class="special">,</span> <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span><span class="special">,</span> <span class="keyword">typename</span> <span class="special">></span> <span class="keyword">class</span> <span class="identifier">Container</span><span class="special">,</span> <span class="keyword">template</span><span class="special"><</span> <span class="keyword">typename</span> <span class="special">></span> <span class="keyword">class</span> <span class="identifier">Allocator</span><span class="special">></span> 57<span class="keyword">class</span> <span class="identifier">model</span><span class="special">::</span><span class="identifier">multi_linestring</span> 58 <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">Container</span><span class="special"><</span> <span class="identifier">LineString</span><span class="special">,</span> <span class="identifier">Allocator</span><span class="special"><</span> <span class="identifier">LineString</span> <span class="special">></span> <span class="special">></span> 59<span class="special">{</span> 60 <span class="comment">// ...</span> 61<span class="special">};</span> 62</pre> 63<p> 64 </p> 65<h6> 66<a name="geometry.reference.models.model_multi_linestring.h3"></a> 67 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.template_parameter_s_"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.template_parameter_s_">Template 68 parameter(s)</a> 69 </h6> 70<div class="informaltable"><table class="table"> 71<colgroup> 72<col> 73<col> 74<col> 75</colgroup> 76<thead><tr> 77<th> 78 <p> 79 Parameter 80 </p> 81 </th> 82<th> 83 <p> 84 Default 85 </p> 86 </th> 87<th> 88 <p> 89 Description 90 </p> 91 </th> 92</tr></thead> 93<tbody> 94<tr> 95<td> 96 <p> 97 typename LineString 98 </p> 99 </td> 100<td> 101 </td> 102<td> 103 </td> 104</tr> 105<tr> 106<td> 107 <p> 108 template< typename, typename > class Container 109 </p> 110 </td> 111<td> 112 <p> 113 std::vector 114 </p> 115 </td> 116<td> 117 </td> 118</tr> 119<tr> 120<td> 121 <p> 122 template< typename > class Allocator 123 </p> 124 </td> 125<td> 126 <p> 127 std::allocator 128 </p> 129 </td> 130<td> 131 </td> 132</tr> 133</tbody> 134</table></div> 135<h6> 136<a name="geometry.reference.models.model_multi_linestring.h4"></a> 137 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.constructor_s_"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.constructor_s_">Constructor(s)</a> 138 </h6> 139<div class="informaltable"><table class="table"> 140<colgroup> 141<col> 142<col> 143<col> 144</colgroup> 145<thead><tr> 146<th> 147 <p> 148 Function 149 </p> 150 </th> 151<th> 152 <p> 153 Description 154 </p> 155 </th> 156<th> 157 <p> 158 Parameters 159 </p> 160 </th> 161</tr></thead> 162<tbody> 163<tr> 164<td> 165 <p> 166</p> 167<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">multi_linestring</span><span class="special">()</span></pre> 168<p> 169 </p> 170 </td> 171<td> 172 <p> 173 Default constructor, creating an empty multi_linestring. 174 </p> 175 </td> 176<td> 177 </td> 178</tr> 179<tr> 180<td> 181 <p> 182</p> 183<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">multi_linestring</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special"><</span> <span class="identifier">LineString</span> <span class="special">></span> <span class="identifier">l</span><span class="special">)</span></pre> 184<p> 185 </p> 186 </td> 187<td> 188 <p> 189 Constructor taking std::initializer_list, filling the multi_linestring. 190 </p> 191 </td> 192<td> 193 <p> 194 <span class="bold"><strong>std::initializer_list< LineString ></strong></span>: 195 <span class="emphasis"><em>l</em></span>: 196 </p> 197 </td> 198</tr> 199</tbody> 200</table></div> 201<h6> 202<a name="geometry.reference.models.model_multi_linestring.h5"></a> 203 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.header"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.header">Header</a> 204 </h6> 205<p> 206 Either 207 </p> 208<p> 209 <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">geometries</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 210 </p> 211<p> 212 Or 213 </p> 214<p> 215 <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">geometries</span><span class="special">/</span><span class="identifier">multi_linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 216 </p> 217<h6> 218<a name="geometry.reference.models.model_multi_linestring.h6"></a> 219 <span class="phrase"><a name="geometry.reference.models.model_multi_linestring.examples"></a></span><a class="link" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.examples">Examples</a> 220 </h6> 221<p> 222 Declaration and use of the Boost.Geometry model::multi_linestring, modelling 223 the MultiLinestring Concept 224 </p> 225<p> 226</p> 227<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 228<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> 229<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">geometries</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 230 231<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> 232 233<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 234<span class="special">{</span> 235 <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">cartesian</span><span class="special">></span> <span class="identifier">point_t</span><span class="special">;</span> 236 <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_t</span><span class="special">></span> <span class="identifier">linestring_t</span><span class="special">;</span> 237 <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">multi_linestring</span><span class="special"><</span><span class="identifier">linestring_t</span><span class="special">></span> <span class="identifier">mlinestring_t</span><span class="special">;</span> 238 239 <span class="identifier">mlinestring_t</span> <span class="identifier">mls1</span><span class="special">;</span> <a class="co" name="geometry.reference.models.model_multi_linestring.c0" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.c1"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> 240 241<span class="preprocessor">#if</span> <span class="special">!</span><span class="identifier">defined</span><span class="special">(</span><span class="identifier">BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX</span><span class="special">)</span> <span class="special">\</span> 242 <span class="special">&&</span> <span class="special">!</span><span class="identifier">defined</span><span class="special">(</span><span class="identifier">BOOST_NO_CXX11_HDR_INITIALIZER_LIST</span><span class="special">)</span> 243 244 <span class="identifier">mlinestring_t</span> <span class="identifier">mls2</span><span class="special">{{{</span><span class="number">0.0</span><span class="special">,</span> <span class="number">0.0</span><span class="special">},</span> <span class="special">{</span><span class="number">0.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">},</span> <span class="special">{</span><span class="number">2.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">}},</span> 245 <span class="special">{{</span><span class="number">1.0</span><span class="special">,</span> <span class="number">0.0</span><span class="special">},</span> <span class="special">{</span><span class="number">2.0</span><span class="special">,</span> <span class="number">0.0</span><span class="special">}}};</span> <a class="co" name="geometry.reference.models.model_multi_linestring.c2" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.c3"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> 246 247<span class="preprocessor">#endif</span> 248 249 <span class="identifier">mls1</span><span class="special">.</span><span class="identifier">resize</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> <a class="co" name="geometry.reference.models.model_multi_linestring.c4" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.c5"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> 250 251 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">append</span><span class="special">(</span><span class="identifier">mls1</span><span class="special">[</span><span class="number">0</span><span class="special">],</span> <span class="identifier">point_t</span><span class="special">(</span><span class="number">0.0</span><span class="special">,</span> <span class="number">0.0</span><span class="special">));</span> <a class="co" name="geometry.reference.models.model_multi_linestring.c6" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.c7"><img src="../../../../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a> 252 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">append</span><span class="special">(</span><span class="identifier">mls1</span><span class="special">[</span><span class="number">0</span><span class="special">],</span> <span class="identifier">point_t</span><span class="special">(</span><span class="number">0.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">));</span> 253 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">append</span><span class="special">(</span><span class="identifier">mls1</span><span class="special">[</span><span class="number">0</span><span class="special">],</span> <span class="identifier">point_t</span><span class="special">(</span><span class="number">2.0</span><span class="special">,</span> <span class="number">1.0</span><span class="special">));</span> 254 255 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">append</span><span class="special">(</span><span class="identifier">mls1</span><span class="special">[</span><span class="number">1</span><span class="special">],</span> <span class="identifier">point_t</span><span class="special">(</span><span class="number">1.0</span><span class="special">,</span> <span class="number">0.0</span><span class="special">));</span> <a class="co" name="geometry.reference.models.model_multi_linestring.c8" href="model_multi_linestring.html#geometry.reference.models.model_multi_linestring.c9"><img src="../../../../../../../doc/src/images/callouts/5.png" alt="5" border="0"></a> 256 <span class="identifier">bg</span><span class="special">::</span><span class="identifier">append</span><span class="special">(</span><span class="identifier">mls1</span><span class="special">[</span><span class="number">1</span><span class="special">],</span> <span class="identifier">point_t</span><span class="special">(</span><span class="number">2.0</span><span class="special">,</span> <span class="number">0.0</span><span class="special">));</span> 257 258 <span class="keyword">double</span> <span class="identifier">l</span> <span class="special">=</span> <span class="identifier">bg</span><span class="special">::</span><span class="identifier">length</span><span class="special">(</span><span class="identifier">mls1</span><span class="special">);</span> 259 260 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">l</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 261 262 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 263<span class="special">}</span> 264</pre> 265<p> 266 </p> 267<div class="calloutlist"><table border="0" summary="Callout list"> 268<tr> 269<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_multi_linestring.c1"></a><a href="#geometry.reference.models.model_multi_linestring.c0"><img src="../../../../../../../doc/src/images/callouts/1.png" alt="1" border="0"></a> </p></td> 270<td valign="top" align="left"><p> 271 Default-construct a multi_linestring. 272 </p></td> 273</tr> 274<tr> 275<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_multi_linestring.c3"></a><a href="#geometry.reference.models.model_multi_linestring.c2"><img src="../../../../../../../doc/src/images/callouts/2.png" alt="2" border="0"></a> </p></td> 276<td valign="top" align="left"><p> 277 Construct a multi_linestring containing two linestrings, using C++11 278 unified initialization syntax. 279 </p></td> 280</tr> 281<tr> 282<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_multi_linestring.c5"></a><a href="#geometry.reference.models.model_multi_linestring.c4"><img src="../../../../../../../doc/src/images/callouts/3.png" alt="3" border="0"></a> </p></td> 283<td valign="top" align="left"><p> 284 Resize a multi_linestring, store two linestrings. 285 </p></td> 286</tr> 287<tr> 288<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_multi_linestring.c7"></a><a href="#geometry.reference.models.model_multi_linestring.c6"><img src="../../../../../../../doc/src/images/callouts/4.png" alt="4" border="0"></a> </p></td> 289<td valign="top" align="left"><p> 290 Append point to the first linestring. 291 </p></td> 292</tr> 293<tr> 294<td width="5%" valign="top" align="left"><p><a name="geometry.reference.models.model_multi_linestring.c9"></a><a href="#geometry.reference.models.model_multi_linestring.c8"><img src="../../../../../../../doc/src/images/callouts/5.png" alt="5" border="0"></a> </p></td> 295<td valign="top" align="left"><p> 296 Append point to the second linestring. 297 </p></td> 298</tr> 299</table></div> 300<p> 301 Output: 302 </p> 303<pre class="programlisting">4 304</pre> 305</div> 306<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 307<td align="left"></td> 308<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 309 Wulkiewicz, Oracle and/or its affiliates<p> 310 Distributed under the Boost Software License, Version 1.0. (See accompanying 311 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>) 312 </p> 313</div></td> 314</tr></table> 315<hr> 316<div class="spirit-nav"> 317<a accesskey="p" href="model_multi_point.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../models.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="model_multi_polygon.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 318</div> 319</body> 320</html> 321