| Home | Libraries | People | FAQ | More

#### model::multi_linestring

multi_line, a collection of linestring

###### Description

Multi-linestring can be used to group lines belonging to each other, e.g. a highway (with interruptions)

###### Model of

MultiLineString Concept

###### Synopsis

    template<typename LineString, template< typename, typename > class Container, template< typename > class Allocator>
    class model::multi_linestring
          : public Container< LineString, Allocator< LineString > >
    {
      // ...
    };

###### Template parameter(s)

Parameter | Default | Description
--- | --- | ---
typename LineString |  |
template< typename, typename > class Container | std::vector |
template< typename > class Allocator | std::allocator |

###### Constructor(s)

Function | Description | Parameters
--- | --- | ---
    multi_linestring()
| Default constructor, creating an empty multi_linestring. |
    multi_linestring(std::initializer_list< LineString > l)
| Constructor taking std::initializer_list, filling the multi_linestring. | std::initializer_list< LineString >: l:

###### Header

Either

`#include <boost/geometry/geometries/geometries.hpp>`

Or

`#include <boost/geometry/geometries/multi_linestring.hpp>`

###### Examples

Declaration and use of the Boost.Geometry model::multi_linestring, modelling the MultiLinestring Concept

    #include <iostream>
    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/geometries.hpp>

    namespace bg = boost::geometry;

    int main()
    {
        typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
        typedef bg::model::linestring<point_t> linestring_t;
        typedef bg::model::multi_linestring<linestring_t> mlinestring_t;

        mlinestring_t mls1;

    #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
     && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)

        mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}},
                           {{1.0, 0.0}, {2.0, 0.0}}};

    #endif

        mls1.resize(2);

        bg::append(mls1[0], point_t(0.0, 0.0));
        bg::append(mls1[0], point_t(0.0, 1.0));
        bg::append(mls1[0], point_t(2.0, 1.0));

        bg::append(mls1[1], point_t(1.0, 0.0));
        bg::append(mls1[1], point_t(2.0, 0.0));

        double l = bg::length(mls1);

        std::cout << l << std::endl;

        return 0;
    }

| Default-construct a multi_linestring.
| Construct a multi_linestring containing two linestrings, using C++11 unified initialization syntax.
| Resize a multi_linestring, store two linestrings.
| Append point to the first linestring.
| Append point to the second linestring.

Output:

    4