]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/disjoint/disjoint_multi.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / disjoint / disjoint_multi.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2012-2015 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
11 #include "test_disjoint.hpp"
12
13 #include <boost/geometry/strategies/strategies.hpp>
14
15 #include <boost/geometry/geometries/geometries.hpp>
16 #include <boost/geometry/geometries/point_xy.hpp>
17
18 #include <test_common/test_point.hpp>
19
20 #include <algorithms/predef_relop.hpp>
21
22
23 template <typename P>
24 void test_all()
25 {
26 typedef bg::model::linestring<P> ls;
27 typedef bg::model::multi_linestring<ls> mls;
28 typedef bg::model::polygon<P> polygon;
29 typedef bg::model::multi_polygon<polygon> mp;
30
31 test_disjoint<mp, mp>("",
32 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
33 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
34 false);
35
36 // True disjoint
37 test_disjoint<mp, mp>("",
38 "MULTIPOLYGON(((0 0,0 4,4 4,4 0,0 0)))",
39 "MULTIPOLYGON(((6 6,6 10,10 10,10 6,6 6)))",
40 true);
41
42 // Touch -> not disjoint
43 test_disjoint<mp, mp>("",
44 "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)))",
45 "MULTIPOLYGON(((5 5,5 10,10 10,10 5,5 5)))",
46 false);
47
48 // Not disjoint but no IP's
49 test_disjoint<mp, mp>("no_ips",
50 "MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))",
51 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((22 2,28 2,28 8,22 8,22 2)))",
52 false);
53
54 // Not disjoint and not inside each other (in first ring) but wrapped (in second rings)
55 test_disjoint<mp, mp>("no_ips2",
56 "MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))",
57 "MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))",
58 false);
59
60 test_disjoint<mp, mp>("no_ips2_rev",
61 "MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))",
62 "MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))",
63 false);
64
65
66 test_disjoint<P, mp>("point_mp1",
67 "POINT(0 0)",
68 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
69 false);
70
71 test_disjoint<P, mp>("point_mp2",
72 "POINT(5 5)",
73 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
74 false);
75
76 test_disjoint<P, mp>("point_mp1",
77 "POINT(11 11)",
78 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
79 true);
80
81 std::string polygon_inside_hole("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0), (2 2,8 2,8 8,2 8,2 2)),((4 4,4 6,6 6,6 4,4 4)))");
82 test_disjoint<P, mp>("point_mp_pih1",
83 "POINT(5 5)",
84 polygon_inside_hole,
85 false);
86
87 test_disjoint<P, mp>("point_mp_pih2",
88 "POINT(3 3)",
89 polygon_inside_hole,
90 true);
91
92 test_disjoint<mp, P>("point_mp1rev",
93 "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
94 "POINT(0 0)",
95 false);
96
97 // assertion failure in 1.57
98 test_disjoint<ls, mls>("point_l_ml_assert_1_57",
99 "LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
100 "MULTILINESTRING((20 100, 31 -97, -46 57, -20 -4))",
101 false);
102 test_disjoint<ls, mls>("point_l_ml_assert_1_57",
103 "LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
104 "MULTILINESTRING((20 100, 31 -97, -46 57, -20 -4),(-71 -4))",
105 false);
106 }
107
108 int test_main(int, char* [])
109 {
110 //test_all<bg::model::d2::point_xy<float> >();
111 test_all<bg::model::d2::point_xy<double> >();
112
113 #ifdef HAVE_TTMATH
114 test_all<bg::model::d2::point_xy<ttmath_big> >();
115 #endif
116
117 return 0;
118 }
119
120
121 /*
122 with viewy as
123 (
124 select geometry::STGeomFromText('MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))',0) as p
125 , geometry::STGeomFromText('MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))',0) as q
126 )
127 select p from viewy union all select q from viewy
128 -- select p.STDisjoint(q) from viewy
129 */