]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/register/multi_polygon.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / geometries / register / multi_polygon.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // QuickBook Example
3
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5
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)
9
10 //[register_multi_polygon
11 //` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POLYGON
12
13 #include <iostream>
14
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/polygon.hpp>
17 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
18 #include <boost/geometry/geometries/register/multi_polygon.hpp>
19
20 typedef boost::geometry::model::polygon
21 <
22 boost::tuple<float, float>
23 > polygon_type;
24
25 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
26 BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(std::vector<polygon_type>)
27
28 int main()
29 {
30 // Normal usage of std::
31 std::vector<polygon_type> polygons(2);
32 boost::geometry::read_wkt("POLYGON((0 0,0 1,1 1,1 0,0 0))", polygons[0]);
33 boost::geometry::read_wkt("POLYGON((3 0,3 1,4 1,4 0,3 0))", polygons[1]);
34
35 // Usage of Boost.Geometry
36 std::cout << "AREA: " << boost::geometry::area(polygons) << std::endl;
37
38 return 0;
39 }
40
41 //]
42
43
44 //[register_multi_polygon_output
45 /*`
46 Output:
47 [pre
48 AREA: 2
49 ]
50 */
51 //]