| Home | Libraries | People | FAQ | More

##### BOOST_GEOMETRY_REGISTER_LINESTRING

Macro to register a linestring.

###### Description

The macro BOOST_GEOMETRY_REGISTER_LINESTRING registers a linestring such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type. The linestring may contain template parameters, which must be specified then.

###### Synopsis

    #define BOOST_GEOMETRY_REGISTER_LINESTRING(Linestring)

###### Parameters

Name | Description
--- | ---
Linestring | linestring type to be registered

###### Header

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

###### Example

Show the use of BOOST_GEOMETRY_REGISTER_LINESTRING

    #include <iostream>

    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/point_xy.hpp>
    #include <boost/geometry/geometries/register/linestring.hpp>

    typedef boost::geometry::model::d2::point_xy<double> point_2d;

    BOOST_GEOMETRY_REGISTER_LINESTRING(std::vector<point_2d>)

    int main()
    {
        // Normal usage of std::
        std::vector<point_2d> line;
        line.push_back(point_2d(1, 1));
        line.push_back(point_2d(2, 2));
        line.push_back(point_2d(3, 1));

        // Usage of Boost.Geometry's length and wkt functions
        std::cout << "Length: "
            << boost::geometry::length(line)
            << std::endl;

        std::cout << "WKT: "
            << boost::geometry::wkt(line)
            << std::endl;

        return 0;
    }

Output:

    Length: 2.82843
    WKT: LINESTRING(1 1,2 2,3 1)