...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The macro BOOST_GEOMETRY_REGISTER_RING registers a ring such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type. The ring may contain template parameters, which must be specified then.
#define BOOST_GEOMETRY_REGISTER_RING(Ring)
Name |
Description |
---|---|
Ring |
ring type to be registered |
#include <boost/geometry/geometries/register/ring.hpp>
Show the use of the macro BOOST_GEOMETRY_REGISTER_RING
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/register/ring.hpp> typedef boost::geometry::model::d2::point_xy<double> point_2d; BOOST_GEOMETRY_REGISTER_RING(std::vector<point_2d>) int main() { // Normal usage of std:: std::vector<point_2d> ring; ring.push_back(point_2d(1, 1)); ring.push_back(point_2d(2, 2)); ring.push_back(point_2d(2, 1)); // Usage of Boost.Geometry boost::geometry::correct(ring); std::cout << "Area: " << boost::geometry::area(ring) << std::endl; std::cout << "WKT: " << boost::geometry::wkt(ring) << std::endl; return 0; }
Output:
Area: 0.5 WKT: POLYGON((1 1,2 2,2 1,1 1))