...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Macro to register a linestring.
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.
#define BOOST_GEOMETRY_REGISTER_LINESTRING(Linestring)
Name |
Description |
---|---|
Linestring |
linestring type to be registered |
#include <boost/geometry/geometries/register/linestring.hpp>
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)