...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 templated linestring.
The macro BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED registers a templated linestring such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type. The type must have one template parameter, which should be a point type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated linestring are registered, regardless of their point type.
#define BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(Linestring)
Name |
Description |
---|---|
Linestring |
linestring (without template parameters) type to be registered |
#include <boost/geometry/geometries/register/linestring.hpp>
Show the use of the macro BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED
#include <iostream> #include <deque> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/register/linestring.hpp> // Adapt any deque to Boost.Geometry Linestring Concept BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque) int main() { std::deque<boost::geometry::model::d2::point_xy<double> > line(2); boost::geometry::assign_values(line[0], 1, 1); boost::geometry::assign_values(line[1], 2, 2); // Boost.Geometry algorithms work on any deque now std::cout << "Length: " << boost::geometry::length(line) << std::endl; std::cout << "Line: " << boost::geometry::dsv(line) << std::endl; return 0; }
Output:
Length: 1.41421 Line: ((1, 1), (2, 2))