]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/for_each_point_const.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / for_each_point_const.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//[for_each_point_const
11//` Sample using for_each_point, using a function to list coordinates
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
19
20template <typename Point>
21void list_coordinates(Point const& p)
22{
23 using boost::geometry::get;
24 std::cout << "x = " << get<0>(p) << " y = " << get<1>(p) << std::endl;
25}
26
27int main()
28{
29 typedef boost::geometry::model::d2::point_xy<double> point;
30 boost::geometry::model::polygon<point> poly;
31 boost::geometry::read_wkt("POLYGON((0 0,0 4,4 0,0 0))", poly);
32 boost::geometry::for_each_point(poly, list_coordinates<point>);
33 return 0;
34}
35
36//]
37
38
39//[for_each_point_const_output
40/*`
41Output:
42[pre
43x = 0 y = 0
44x = 0 y = 4
45x = 4 y = 0
46x = 0 y = 0
47]
48*/
49//]