]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/simplify_insert_with_strategy.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)
11 //` Simplify a linestring using an output iterator
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/linestring.hpp>
17 #include <boost/geometry/geometries/point_xy.hpp>
21 typedef boost::geometry::model::d2::point_xy
<double> P
;
22 typedef boost::geometry::model::linestring
<P
> L
;
25 boost::geometry::read_wkt("linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", line
);
27 typedef boost::geometry::strategy::distance::projected_point
<P
, P
> DS
;
28 typedef boost::geometry::strategy::simplify::douglas_peucker
<P
, DS
> simplification
;
31 boost::geometry::simplify_inserter(line
, std::back_inserter(simplified
), 0.5, simplification()); //std::ostream_iterator<P>(std::cout, "\n"), 0.5);//);
32 //std::cout << simplified[0];
33 //boost::geometry::simplify_inserter(line, std::ostream_iterator<P>(std::cout, "\n"), 0.5);//, simplification());
35 std::ostream_iterator
<P
> out(std::cout
, "\n");
36 std::copy(simplified
.begin(), simplified
.end(), out
);
39 << " original: " << boost::geometry::dsv(line
) << std::endl
40 << "simplified: " << boost::geometry::dsv(simplified
) << std::endl
;
48 //[simplify_inserter_output
53 simplify_inserter: 0.339837
59 POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
60 simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
64 POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
65 simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
69 POINT(1.1 1.1) original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
70 simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))