]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/for_each_point_const.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)
10 //[for_each_point_const
11 //` Sample using for_each_point, using a function to list coordinates
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/point_xy.hpp>
17 #include <boost/geometry/geometries/polygon.hpp>
20 template <typename Point
>
21 void list_coordinates(Point
const& p
)
23 using boost::geometry::get
;
24 std::cout
<< "x = " << get
<0>(p
) << " y = " << get
<1>(p
) << std::endl
;
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
>);
39 //[for_each_point_const_output