]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/correct_multi.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / correct_multi.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 //
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Use, modification and distribution is subject to the Boost Software License,
5 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7
8 #include <geometry_test_common.hpp>
9
10 #include <boost/geometry/algorithms/correct.hpp>
11
12 #include <boost/geometry/strategies/strategies.hpp>
13
14 #include <boost/geometry/io/wkt/wkt.hpp>
15
16 #include <boost/geometry/geometries/box.hpp>
17 #include <boost/geometry/geometries/ring.hpp>
18 #include <boost/geometry/geometries/linestring.hpp>
19 #include <boost/geometry/geometries/point_xy.hpp>
20 #include <boost/geometry/geometries/point.hpp>
21 #include <boost/geometry/geometries/polygon.hpp>
22 #include <boost/geometry/geometries/multi_polygon.hpp>
23
24
25 template <typename Geometry>
26 void test_geometry(std::string const& wkt, std::string const& expected)
27 {
28 Geometry geometry;
29
30 bg::read_wkt(wkt, geometry);
31 bg::correct(geometry);
32
33 std::ostringstream out;
34 out << bg::wkt(geometry);
35
36 BOOST_CHECK_EQUAL(out.str(), expected);
37 }
38
39 template <typename P>
40 void test_all()
41 {
42 typedef bg::model::multi_polygon<bg::model::polygon<P> > cw_type;
43 std::string cw_mp =
44 "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))";
45 test_geometry<cw_type>(cw_mp, cw_mp);
46
47 test_geometry<cw_type>("MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))",
48 cw_mp);
49 }
50
51 int test_main( int , char* [] )
52 {
53 test_all<bg::model::d2::point_xy<double> >();
54
55 return 0;
56 }