]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/simplify_insert.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / simplify_insert.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 //[simplify_inserter
11 //` Simplify a linestring using a back inserter
12
13 #include <iostream>
14
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/linestring.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
18
19 int main()
20 {
21 typedef boost::geometry::model::d2::point_xy<double> P;
22 typedef boost::geometry::model::linestring<P> L;
23
24 L line;
25 line.push_back(P(1.1, 1.1));
26 line.push_back(P(2.5, 2.1));
27 line.push_back(P(3.1, 3.1));
28 line.push_back(P(4.9, 1.1));
29 line.push_back(P(3.1, 1.9));
30
31 L simplified;
32 boost::geometry::simplify_inserter(line, std::back_inserter(simplified), 0.5);
33
34 std::cout
35 << " original: " << boost::geometry::dsv(line) << std::endl
36 << "simplified: " << boost::geometry::dsv(simplified) << std::endl;
37
38 return 0;
39 }
40
41 //]
42
43
44 //[simplify_inserter_output
45 /*`
46 Output:
47 [pre
48 original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
49 simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
50 ]
51 */
52 //]