]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014-2015, Oracle and/or its affiliates.
5 // Licensed under the Boost Software License version 1.0.
6 // http://www.boost.org/users/license.html
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 #ifndef BOOST_TEST_MODULE
12 #define BOOST_TEST_MODULE test_disjoint_coverage
15 // unit test to test disjoint for all geometry combinations
19 #include <boost/test/included/unit_test.hpp>
21 #include <boost/geometry/core/tag.hpp>
22 #include <boost/geometry/core/tags.hpp>
24 #include <boost/geometry/strategies/strategies.hpp>
26 #include <boost/geometry/io/wkt/wkt.hpp>
27 #include <boost/geometry/io/dsv/write.hpp>
29 #include <boost/geometry/geometries/geometries.hpp>
31 #include <boost/geometry/algorithms/disjoint.hpp>
33 #include <from_wkt.hpp>
37 #include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
40 namespace bg
= ::boost::geometry
;
42 //============================================================================
46 template <typename Geometry1
, typename Geometry2
>
47 static inline void apply(std::string
const& case_id
,
48 Geometry1
const& geometry1
,
49 Geometry2
const& geometry2
,
52 bool result
= bg::disjoint(geometry1
, geometry2
);
53 BOOST_CHECK_MESSAGE(result
== expected_result
,
54 "case ID: " << case_id
<< ", G1: " << bg::wkt(geometry1
)
55 << ", G2: " << bg::wkt(geometry2
) << " -> Expected: "
56 << expected_result
<< ", detected: " << result
);
58 result
= bg::disjoint(geometry2
, geometry1
);
59 BOOST_CHECK_MESSAGE(result
== expected_result
,
60 "case ID: " << case_id
<< ", G1: " << bg::wkt(geometry2
)
61 << ", G2: " << bg::wkt(geometry1
) << " -> Expected: "
62 << expected_result
<< ", detected: " << result
);
64 #ifdef BOOST_GEOMETRY_TEST_DEBUG
65 std::cout
<< "case ID: " << case_id
<< "; G1 - G2: ";
66 std::cout
<< bg::wkt(geometry1
) << " - ";
67 std::cout
<< bg::wkt(geometry2
) << std::endl
;
68 std::cout
<< std::boolalpha
;
69 std::cout
<< "expected/computed result: "
70 << expected_result
<< " / " << result
<< std::endl
;
71 std::cout
<< std::endl
;
72 std::cout
<< std::noboolalpha
;
77 //============================================================================
79 // pointlike-areal geometries
81 inline void test_point_box()
83 typedef test_disjoint tester
;
84 typedef bg::model::box
<P
> B
;
86 tester::apply("p-b-01",
87 from_wkt
<P
>("POINT(0 0)"),
88 from_wkt
<B
>("BOX(0 0,1 1)"),
91 tester::apply("p-b-02",
92 from_wkt
<P
>("POINT(2 2)"),
93 from_wkt
<B
>("BOX(0 0,1 0)"),
98 inline void test_point_ring()
100 typedef bg::model::ring
<P
, false, false> R
; // ccw, open
102 typedef test_disjoint tester
;
104 tester::apply("p-r-01",
105 from_wkt
<P
>("POINT(0 0)"),
106 from_wkt
<R
>("POLYGON((0 0,1 0,0 1))"),
109 tester::apply("p-r-02",
110 from_wkt
<P
>("POINT(1 1)"),
111 from_wkt
<R
>("POLYGON((0 0,1 0,0 1))"),
115 template <typename P
>
116 inline void test_point_polygon()
118 typedef bg::model::polygon
<P
, false, false> PL
; // ccw, open
120 typedef test_disjoint tester
;
122 tester::apply("p-pg-01",
123 from_wkt
<P
>("POINT(0 0)"),
124 from_wkt
<PL
>("POLYGON((0 0,1 0,0 1))"),
127 tester::apply("p-pg-02",
128 from_wkt
<P
>("POINT(1 1)"),
129 from_wkt
<PL
>("POLYGON((0 0,1 0,0 1))"),
133 template <typename P
>
134 inline void test_point_multipolygon()
136 typedef bg::model::polygon
<P
, false, false> PL
; // ccw, open
137 typedef bg::model::multi_polygon
<PL
> MPL
;
139 typedef test_disjoint tester
;
141 tester::apply("p-mpg-01",
142 from_wkt
<P
>("POINT(0 0)"),
143 from_wkt
<MPL
>("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"),
146 tester::apply("p-mpg-02",
147 from_wkt
<P
>("POINT(1 1)"),
148 from_wkt
<MPL
>("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"),
152 template <typename P
>
153 inline void test_multipoint_box()
155 typedef test_disjoint tester
;
156 typedef bg::model::multi_point
<P
> MP
;
157 typedef bg::model::box
<P
> B
;
159 tester::apply("mp-b-01",
160 from_wkt
<MP
>("MULTIPOINT(0 0,1 1)"),
161 from_wkt
<B
>("BOX(0 0,2 2)"),
164 tester::apply("mp-b-02",
165 from_wkt
<MP
>("MULTIPOINT(1 1,3 3)"),
166 from_wkt
<B
>("BOX(0 0,2 2)"),
169 tester::apply("mp-b-03",
170 from_wkt
<MP
>("MULTIPOINT(3 3,4 4)"),
171 from_wkt
<B
>("BOX(0 0,2 2)"),
174 tester::apply("mp-b-04",
175 from_wkt
<MP
>("MULTIPOINT()"),
176 from_wkt
<B
>("BOX(0 0,2 2)"),
180 template <typename P
>
181 inline void test_multipoint_ring()
183 typedef bg::model::multi_point
<P
> MP
;
184 typedef bg::model::ring
<P
, false, false> R
; // ccw, open
186 typedef test_disjoint tester
;
188 tester::apply("mp-r-01",
189 from_wkt
<MP
>("MULTIPOINT(0 0,1 0)"),
190 from_wkt
<R
>("POLYGON((0 0,1 0,0 1))"),
193 tester::apply("mp-r-02",
194 from_wkt
<MP
>("MULTIPOINT(1 0,1 1)"),
195 from_wkt
<R
>("POLYGON((0 0,1 0,0 1))"),
198 tester::apply("mp-r-03",
199 from_wkt
<MP
>("MULTIPOINT(1 1,2 2)"),
200 from_wkt
<R
>("POLYGON((0 0,1 0,0 1))"),
204 template <typename P
>
205 inline void test_multipoint_polygon()
207 typedef bg::model::multi_point
<P
> MP
;
208 typedef bg::model::polygon
<P
, false, false> PL
; // ccw, open
210 typedef test_disjoint tester
;
212 tester::apply("mp-pg-01",
213 from_wkt
<MP
>("MULTIPOINT(0 0,1 0)"),
214 from_wkt
<PL
>("POLYGON(((0 0,1 0,0 1)))"),
217 tester::apply("mp-pg-02",
218 from_wkt
<MP
>("MULTIPOINT(0 0,2 0)"),
219 from_wkt
<PL
>("POLYGON(((0 0,1 0,0 1)))"),
222 tester::apply("mp-pg-03",
223 from_wkt
<MP
>("MULTIPOINT(1 1,2 0)"),
224 from_wkt
<PL
>("POLYGON(((0 0,1 0,0 1)))"),
227 tester::apply("mp-pg-04",
228 from_wkt
<MP
>("MULTIPOINT(1 1,2 3)"),
229 from_wkt
<PL
>("POLYGON(((0 0,1 0,0 1)))"),
233 template <typename P
>
234 inline void test_multipoint_multipolygon()
236 typedef bg::model::multi_point
<P
> MP
;
237 typedef bg::model::polygon
<P
, false, false> PL
; // ccw, open
238 typedef bg::model::multi_polygon
<PL
> MPL
;
240 typedef test_disjoint tester
;
242 tester::apply("mp-mp-01",
243 from_wkt
<MP
>("MULTIPOINT(0 0,2 0)"),
244 from_wkt
<MPL
>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
247 tester::apply("mp-mp-02",
248 from_wkt
<MP
>("MULTIPOINT(0 0,1 0)"),
249 from_wkt
<MPL
>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
252 tester::apply("mp-mp-03",
253 from_wkt
<MP
>("MULTIPOINT(1 1,2 0)"),
254 from_wkt
<MPL
>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
257 tester::apply("mp-mp-04",
258 from_wkt
<MP
>("MULTIPOINT(1 1,2 3)"),
259 from_wkt
<MPL
>("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"),
263 //============================================================================
265 template <typename CoordinateType
>
266 inline void test_pointlike_areal()
268 typedef bg::model::point
<CoordinateType
, 2, bg::cs::cartesian
> point_type
;
270 test_point_polygon
<point_type
>();
271 test_point_multipolygon
<point_type
>();
272 test_point_ring
<point_type
>();
273 test_point_box
<point_type
>();
275 // not implemented yet
276 // test_multipoint_polygon<point_type>();
277 // test_multipoint_multipolygon<point_type>();
278 // test_multipoint_ring<point_type>();
279 test_multipoint_box
<point_type
>();
282 //============================================================================
284 BOOST_AUTO_TEST_CASE( test_pointlike_areal_all
)
286 test_pointlike_areal
<double>();
287 test_pointlike_areal
<int>();
289 test_pointlike_areal
<ttmath_big
>();