]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/convert.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 //` Shows how to convert a geometry into another geometry
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/box.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18 #include <boost/geometry/geometries/polygon.hpp>
19 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
21 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
25 typedef boost::geometry::model::d2::point_xy
<double> point
;
26 typedef boost::geometry::model::box
<point
> box
;
27 typedef boost::geometry::model::polygon
<point
> polygon
;
30 box bx
= boost::geometry::make
<box
>(1, 1, 2, 2);
32 // Assign a box to a polygon (conversion box->poly)
34 boost::geometry::convert(bx
, poly
);
36 // Convert a point to another point type (conversion of point-type)
37 boost::tuple
<double, double> p2
;
38 boost::geometry::convert(p1
, p2
); // source -> target
40 using boost::geometry::dsv
;
42 << "box: " << dsv(bx
) << std::endl
43 << "polygon: " << dsv(poly
) << std::endl
44 << "point: " << dsv(p1
) << std::endl
45 << "point tuples: " << dsv(p2
) << std::endl
59 polygon: (((1, 1), (1, 2), (2, 2), (2, 1), (1, 1)))