| Home | Libraries | People | FAQ | More

#### model::linestring

A linestring (named so by OGC) is a collection (default a vector) of points.

###### Model of

Linestring Concept

###### Synopsis

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

###### Template parameter(s)

Parameter | Default | Description
--- | --- | ---
typename Point |  | Any type fulfilling a Point Concept
template< typename, typename > class Container | std::vector | container type, for example std::vector, std::deque
template< typename > class Allocator | std::allocator | container-allocator-type

###### Constructor(s)

Function | Description | Parameters
--- | --- | ---
    linestring()
| Default constructor, creating an empty linestring. |
    template<typename Iterator>
    linestring(Iterator begin, Iterator end)
| Constructor with begin and end, filling the linestring. | Iterator: begin: Iterator: end:
    linestring(std::initializer_list< Point > l)
| Constructor taking std::initializer_list, filling the linestring. | std::initializer_list< Point >: l:

###### Header

Either

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

Or

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

###### Examples

Declaration and use of the Boost.Geometry model::linestring, modelling the Linestring 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;

        linestring_t ls1;

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

        linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}};

    #endif

        bg::append(ls1, point_t(0.0, 0.0));
        bg::append(ls1, point_t(1.0, 0.0));
        bg::append(ls1, point_t(1.0, 2.0));

        double l = bg::length(ls1);

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

        return 0;
    }

| Default-construct a linestring.
| Construct a linestring containing three points, using C++11 unified initialization syntax.
| Append point.

Output:

    3