]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/area_with_strategy.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / area_with_strategy.cpp
CommitLineData
7c673cae
FG
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//[area_with_strategy
11//` Calculate the area of a polygon
12
13#include <iostream>
14
15#include <boost/geometry.hpp>
16#include <boost/geometry/geometries/point_xy.hpp>
17#include <boost/geometry/geometries/polygon.hpp>
18
19namespace bg = boost::geometry; /*< Convenient namespace alias >*/
20
21int main()
22{
23 // Calculate the area of a cartesian polygon
24 bg::model::polygon<bg::model::d2::point_xy<double> > poly;
25 bg::read_wkt("POLYGON((0 0,0 7,4 2,2 0,0 0))", poly);
26 double area = bg::area(poly);
27 std::cout << "Area: " << area << std::endl;
28
29 // Calculate the area of a spherical polygon (for latitude: 0 at equator)
30 bg::model::polygon<bg::model::point<float, 2, bg::cs::spherical_equatorial<bg::degree> > > sph_poly;
31 bg::read_wkt("POLYGON((0 0,0 45,45 0,0 0))", sph_poly);
32 area = bg::area(sph_poly);
33 std::cout << "Area: " << area << std::endl;
34
35 return 0;
36}
37
38//]
39
40
41//[area_with_strategy_output
42/*`
43Output:
44[pre
45Area: 16
46Area: 0.339837
47]
48*/
49//]