]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/doc/src/examples/algorithms/simplify.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / doc / src / examples / algorithms / simplify.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//[simplify
11//` Example showing how to simplify a linestring
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/*< For this example we use Boost.Assign to add points >*/
20#include <boost/assign.hpp>
21
22using namespace boost::assign;
23
24
25int main()
26{
27 typedef boost::geometry::model::d2::point_xy<double> xy;
28
29 boost::geometry::model::linestring<xy> line;
30 line += xy(1.1, 1.1), xy(2.5, 2.1), xy(3.1, 3.1), xy(4.9, 1.1), xy(3.1, 1.9); /*< With Boost.Assign >*/
31
32 // Simplify it, using distance of 0.5 units
33 boost::geometry::model::linestring<xy> simplified;
34 boost::geometry::simplify(line, simplified, 0.5);
35 std::cout
36 << " original: " << boost::geometry::dsv(line) << std::endl
37 << "simplified: " << boost::geometry::dsv(simplified) << std::endl;
38
39
40 return 0;
41}
42
43//]
44
45
46//[simplify_output
47/*`
48Output:
49[pre
50 original: ((1.1, 1.1), (2.5, 2.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
51simplified: ((1.1, 1.1), (3.1, 3.1), (4.9, 1.1), (3.1, 1.9))
52]
53*/
54//]