]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/register/ring.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
11 //` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/point_xy.hpp>
17 #include <boost/geometry/geometries/register/ring.hpp>
19 typedef boost::geometry::model::d2::point_xy
<double> point_2d
;
21 BOOST_GEOMETRY_REGISTER_RING(std::vector
<point_2d
>) /*< The magic: adapt vector to Boost.Geometry Ring Concept >*/
25 // Normal usage of std::
26 std::vector
<point_2d
> ring
;
27 ring
.push_back(point_2d(1, 1));
28 ring
.push_back(point_2d(2, 2));
29 ring
.push_back(point_2d(2, 1));
32 // Usage of Boost.Geometry
33 boost::geometry::correct(ring
);
34 std::cout
<< "Area: " << boost::geometry::area(ring
) << std::endl
;
35 std::cout
<< "WKT: " << boost::geometry::wkt(ring
) << std::endl
;
43 //[register_ring_output
48 WKT: POLYGON((1 1,2 2,2 1,1 1))