]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/set_operations/intersection/intersection_areal_areal_linear.cpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / set_operations / intersection / intersection_areal_areal_linear.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit test
3
4 // Copyright (c) 2015-2020, Oracle and/or its affiliates.
5
6 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
7 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8
9 // Licensed under the Boost Software License version 1.0.
10 // http://www.boost.org/users/license.html
11
12 #ifndef BOOST_TEST_MODULE
13 #define BOOST_TEST_MODULE test_intersection_linear_linear_areal
14 #endif
15
16 #ifdef BOOST_GEOMETRY_TEST_DEBUG
17 #define BOOST_GEOMETRY_DEBUG_TURNS
18 #define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
19 #endif
20
21 #include <boost/test/included/unit_test.hpp>
22
23 #include <boost/geometry/geometries/linestring.hpp>
24 #include <boost/geometry/geometries/multi_linestring.hpp>
25 #include <boost/geometry/geometries/ring.hpp>
26 #include <boost/geometry/geometries/polygon.hpp>
27 #include <boost/geometry/geometries/multi_polygon.hpp>
28
29 #include "test_intersection_linear_linear.hpp"
30
31 typedef bg::model::point<double,2,bg::cs::cartesian> point_type;
32 typedef bg::model::multi_linestring
33 <
34 bg::model::linestring<point_type>
35 > multi_linestring_type;
36
37 typedef bg::model::ring<point_type, true, false> open_ring_type;
38 typedef bg::model::polygon<point_type, true, false> open_polygon_type;
39 typedef bg::model::multi_polygon<open_polygon_type> open_multipolygon_type;
40
41 typedef bg::model::ring<point_type> closed_ring_type;
42 typedef bg::model::polygon<point_type> closed_polygon_type;
43 typedef bg::model::multi_polygon<closed_polygon_type> closed_multipolygon_type;
44
45
46 template
47 <
48 typename OpenAreal1,
49 typename OpenAreal2,
50 typename ClosedAreal1,
51 typename ClosedAreal2,
52 typename MultiLinestring
53 >
54 struct test_intersection_aal
55 {
56 static inline void apply(std::string const& case_id,
57 OpenAreal1 const& open_areal1,
58 OpenAreal2 const& open_areal2,
59 MultiLinestring const& expected1,
60 MultiLinestring const& expected2)
61 {
62 typedef test_intersection_of_geometries
63 <
64 OpenAreal1, OpenAreal2, MultiLinestring
65 > tester;
66
67 tester::apply(open_areal1, open_areal2, expected1, expected2, case_id);
68
69 ClosedAreal1 closed_areal1;
70 ClosedAreal2 closed_areal2;
71 bg::convert(open_areal1, closed_areal1);
72 bg::convert(open_areal2, closed_areal2);
73
74 typedef test_intersection_of_geometries
75 <
76 ClosedAreal1, ClosedAreal2, MultiLinestring
77 > tester_of_closed;
78
79 std::string case_id_closed = case_id + "-closed";
80
81 #ifdef BOOST_GEOMETRY_TEST_DEBUG
82 std::cout << "testing closed areal geometries..." << std::endl;
83 #endif
84 tester_of_closed::apply(closed_areal1, closed_areal2,
85 expected1, expected2, case_id_closed);
86 }
87
88 static inline void apply(std::string const& case_id,
89 OpenAreal1 const& open_areal1,
90 OpenAreal2 const& open_areal2,
91 MultiLinestring const& expected)
92 {
93 apply(case_id, open_areal1, open_areal2, expected, expected);
94 }
95 };
96
97
98 BOOST_AUTO_TEST_CASE( test_intersection_ring_ring_linestring )
99 {
100 #ifdef BOOST_GEOMETRY_TEST_DEBUG
101 std::cout << std::endl << std::endl << std::endl;
102 std::cout << "*** RING / RING / LINEAR INTERSECTION ***" << std::endl;
103 std::cout << std::endl;
104 #endif
105 typedef open_ring_type OG;
106 typedef closed_ring_type CG;
107 typedef multi_linestring_type ML;
108
109 typedef test_intersection_aal<OG, OG, CG, CG, ML> tester;
110
111 tester::apply
112 ("r-r-01",
113 from_wkt<OG>("POLYGON((0 0,0 2,2 2,2 0))"),
114 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
115 from_wkt<ML>("MULTILINESTRING((2 1,2 2),(2 0,1 0),(2 1,2 1))"),
116 from_wkt<ML>("MULTILINESTRING((2 2,2 1),(2 0,1 0),(2 1,2 1))")
117 );
118
119 tester::apply
120 ("r-r-02",
121 from_wkt<OG>("POLYGON(())"),
122 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
123 from_wkt<ML>("MULTILINESTRING()")
124 );
125
126 tester::apply
127 ("r-r-03",
128 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
129 from_wkt<OG>("POLYGON(())"),
130 from_wkt<ML>("MULTILINESTRING()")
131 );
132
133 tester::apply
134 ("r-r-04",
135 from_wkt<OG>("POLYGON(())"),
136 from_wkt<OG>("POLYGON(())"),
137 from_wkt<ML>("MULTILINESTRING()")
138 );
139 }
140
141
142 BOOST_AUTO_TEST_CASE( test_intersection_ring_polygon_linestring )
143 {
144 #ifdef BOOST_GEOMETRY_TEST_DEBUG
145 std::cout << std::endl << std::endl << std::endl;
146 std::cout << "*** RING / POLYGON / LINEAR INTERSECTION ***" << std::endl;
147 std::cout << std::endl;
148 #endif
149 typedef open_ring_type OG1;
150 typedef open_polygon_type OG2;
151 typedef closed_ring_type CG1;
152 typedef closed_polygon_type CG2;
153 typedef multi_linestring_type ML;
154
155 typedef test_intersection_aal<OG1, OG2, CG1, CG2, ML> tester;
156
157 tester::apply
158 ("r-pg-01",
159 from_wkt<OG1>("POLYGON((0 0,0 2,2 2,2 0))"),
160 from_wkt<OG2>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
161 from_wkt<ML>("MULTILINESTRING((2 1,2 2),(2 0,1 0),(2 1,2 1))"),
162 from_wkt<ML>("MULTILINESTRING((2 2,2 1),(2 0,1 0),(2 1,2 1))")
163 );
164 }
165
166
167 BOOST_AUTO_TEST_CASE( test_intersection_ring_multipolygon_linestring )
168 {
169 #ifdef BOOST_GEOMETRY_TEST_DEBUG
170 std::cout << std::endl << std::endl << std::endl;
171 std::cout << "*** RING / MULTIPOLYGON / LINEAR INTERSECTION ***"
172 << std::endl;
173 std::cout << std::endl;
174 #endif
175 typedef open_ring_type OG1;
176 typedef open_multipolygon_type OG2;
177 typedef closed_ring_type CG1;
178 typedef closed_multipolygon_type CG2;
179 typedef multi_linestring_type ML;
180
181 typedef test_intersection_aal<OG1, OG2, CG1, CG2, ML> tester;
182
183 tester::apply
184 ("r-mpg-01",
185 from_wkt<OG1>("POLYGON((0 0,0 2,2 2,2 0))"),
186 from_wkt<OG2>("MULTIPOLYGON(((2 1,2 4,4 4,4 0,1 0)))"),
187 from_wkt<ML>("MULTILINESTRING((2 1,2 2),(2 0,1 0),(2 1,2 1))"),
188 from_wkt<ML>("MULTILINESTRING((2 2,2 1),(2 0,1 0),(2 1,2 1))")
189 );
190 }
191
192
193 BOOST_AUTO_TEST_CASE( test_intersection_polygon_polygon_linestring )
194 {
195 #ifdef BOOST_GEOMETRY_TEST_DEBUG
196 std::cout << std::endl << std::endl << std::endl;
197 std::cout << "*** POLYGON / POLYGON / LINEAR INTERSECTION ***" << std::endl;
198 std::cout << std::endl;
199 #endif
200 typedef open_polygon_type OG;
201 typedef closed_polygon_type CG;
202 typedef multi_linestring_type ML;
203
204 typedef test_intersection_aal<OG, OG, CG, CG, ML> tester;
205
206 tester::apply
207 ("pg-pg-01",
208 from_wkt<OG>("POLYGON((0 0,0 2,2 2,2 0))"),
209 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
210 from_wkt<ML>("MULTILINESTRING((2 1,2 2),(2 0,1 0),(2 1,2 1))"),
211 from_wkt<ML>("MULTILINESTRING((2 2,2 1),(2 0,1 0),(2 1,2 1))")
212 );
213
214 tester::apply
215 ("pg-pg-02",
216 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
217 from_wkt<OG>("POLYGON((2 2,2 7,7 7,7 2))"),
218 from_wkt<ML>("MULTILINESTRING((2 2,2 2),(2 2,2 7,7 7,7 2,2 2),(2 2,2 2))"),
219 from_wkt<ML>("MULTILINESTRING((2 2,2 2),(2 2,7 2,7 7,2 7,2 2),(2 2,2 2))")
220 );
221
222 tester::apply
223 ("pg-pg-03",
224 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
225 from_wkt<OG>("POLYGON((2 3,2 6,6 6,6 3))"),
226 from_wkt<ML>("MULTILINESTRING((2 3,2 6),(2 3,2 3))")
227 );
228
229 tester::apply
230 ("pg-pg-04",
231 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
232 from_wkt<OG>("POLYGON((2 3,2 7,6 7,6 3))"),
233 from_wkt<ML>("MULTILINESTRING((2 3,2 7,6 7),(2 3,2 3))")
234 );
235
236 tester::apply
237 ("pg-pg-05",
238 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
239 from_wkt<OG>("POLYGON((2 3,2 7,7 7,7 3))"),
240 from_wkt<ML>("MULTILINESTRING((2 3,2 7,7 7,7 3),(2 3,2 3))")
241 );
242
243 tester::apply
244 ("pg-pg-06",
245 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
246 from_wkt<OG>("POLYGON((2 3,2 7,7 7,7 3))"),
247 from_wkt<ML>("MULTILINESTRING((2 3,2 7,7 7,7 3),(2 3,2 3))")
248 );
249
250 tester::apply
251 ("pg-pg-07",
252 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
253 from_wkt<OG>("POLYGON((2 5,5 7,7 5,5 2))"),
254 from_wkt<ML>("MULTILINESTRING((2 5,2 5),(5 7,5 7),(7 5,7 5),(5 2,5 2))")
255 );
256
257 tester::apply
258 ("pg-pg-08",
259 from_wkt<OG>("POLYGON((0 0,0 10,10 10,10 0),(2 2,7 2,7 7,2 7))"),
260 from_wkt<OG>("POLYGON((2 5,4 7,6 7,7 5,5 2))"),
261 from_wkt<ML>("MULTILINESTRING((2 5,2 5),(4 7,6 7),(7 5,7 5),(5 2,5 2))")
262 );
263
264 tester::apply
265 ("pg-pg-09",
266 from_wkt<OG>("POLYGON(())"),
267 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
268 from_wkt<ML>("MULTILINESTRING()")
269 );
270
271 tester::apply
272 ("pg-pg-10",
273 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0))"),
274 from_wkt<OG>("POLYGON(())"),
275 from_wkt<ML>("MULTILINESTRING()")
276 );
277
278 tester::apply
279 ("pg-pg-11",
280 from_wkt<OG>("POLYGON(())"),
281 from_wkt<OG>("POLYGON(())"),
282 from_wkt<ML>("MULTILINESTRING()")
283 );
284
285 tester::apply
286 ("pg-pg-12",
287 from_wkt<OG>("POLYGON((),())"),
288 from_wkt<OG>("POLYGON((),(),())"),
289 from_wkt<ML>("MULTILINESTRING()")
290 );
291
292 tester::apply
293 ("pg-pg-13",
294 from_wkt<OG>("POLYGON((2 1,2 4,4 4,4 0,1 0),())"),
295 from_wkt<OG>("POLYGON(())"),
296 from_wkt<ML>("MULTILINESTRING()")
297 );
298 }
299
300
301 BOOST_AUTO_TEST_CASE( test_intersection_polygon_multipolygon_linestring )
302 {
303 #ifdef BOOST_GEOMETRY_TEST_DEBUG
304 std::cout << std::endl << std::endl << std::endl;
305 std::cout << "*** POLYGON / MULTIPOLYGON / LINEAR INTERSECTION ***"
306 << std::endl;
307 std::cout << std::endl;
308 #endif
309 typedef open_polygon_type OG1;
310 typedef open_multipolygon_type OG2;
311 typedef closed_polygon_type CG1;
312 typedef closed_multipolygon_type CG2;
313 typedef multi_linestring_type ML;
314
315 typedef test_intersection_aal<OG1, OG2, CG1, CG2, ML> tester;
316
317 tester::apply
318 ("pg-mpg-01",
319 from_wkt<OG1>("POLYGON((0 0,0 2,2 2,2 0))"),
320 from_wkt<OG2>("MULTIPOLYGON(((2 1,2 4,4 4,4 0,1 0)))"),
321 from_wkt<ML>("MULTILINESTRING((2 1,2 2),(2 0,1 0),(2 1,2 1))"),
322 from_wkt<ML>("MULTILINESTRING((2 2,2 1),(2 0,1 0),(2 1,2 1))")
323 );
324 }
325
326
327 BOOST_AUTO_TEST_CASE( test_intersection_multipolygon_multipolygon_linestring )
328 {
329 #ifdef BOOST_GEOMETRY_TEST_DEBUG
330 std::cout << std::endl << std::endl << std::endl;
331 std::cout << "*** MULTIPOLYGON / MULTIPOLYGON / LINEAR INTERSECTION ***"
332 << std::endl;
333 std::cout << std::endl;
334 #endif
335 typedef open_multipolygon_type OG;
336 typedef closed_multipolygon_type CG;
337 typedef multi_linestring_type ML;
338
339 typedef test_intersection_aal<OG, OG, CG, CG, ML> tester;
340
341 tester::apply
342 ("mpg-mpg-01",
343 from_wkt<OG>("MULTIPOLYGON(((0 0,0 2,2 2,2 0)))"),
344 from_wkt<OG>("MULTIPOLYGON(((2 1,2 4,4 4,4 0,1 0)))"),
345 from_wkt<ML>("MULTILINESTRING((2 1,2 2),(2 0,1 0),(2 1,2 1))"),
346 from_wkt<ML>("MULTILINESTRING((2 2,2 1),(2 0,1 0),(2 1,2 1))")
347 );
348
349 tester::apply
350 ("mpg-mpg-02",
351 from_wkt<OG>("MULTIPOLYGON(((0 0,0 10,10 10,10 0),(2 2,8 2,8 8,2 8)))"),
352 from_wkt<OG>("MULTIPOLYGON(((2 4,2 6,8 6,8 4)))"),
353 from_wkt<ML>("MULTILINESTRING((2 4,2 4),(2 4,2 6),(8 6,8 4))")
354 );
355
356 tester::apply
357 ("mpg-mpg-03",
358 from_wkt<OG>("MULTIPOLYGON()"),
359 from_wkt<OG>("MULTIPOLYGON(((2 1,2 4,4 4,4 0,1 0)))"),
360 from_wkt<ML>("MULTILINESTRING()")
361 );
362
363 tester::apply
364 ("mpg-mpg-04",
365 from_wkt<OG>("MULTIPOLYGON(((2 1,2 4,4 4,4 0,1 0)))"),
366 from_wkt<OG>("MULTIPOLYGON()"),
367 from_wkt<ML>("MULTILINESTRING()")
368 );
369
370 tester::apply
371 ("mpg-mpg-05",
372 from_wkt<OG>("MULTIPOLYGON()"),
373 from_wkt<OG>("MULTIPOLYGON()"),
374 from_wkt<ML>("MULTILINESTRING()")
375 );
376
377 tester::apply
378 ("mpg-mpg-06",
379 from_wkt<OG>("MULTIPOLYGON((()),((),()))"),
380 from_wkt<OG>("MULTIPOLYGON()"),
381 from_wkt<ML>("MULTILINESTRING()")
382 );
383
384 tester::apply
385 ("mpg-mpg-07",
386 from_wkt<OG>("MULTIPOLYGON(((2 1,2 4,4 4,4 0,1 0),(),()))"),
387 from_wkt<OG>("MULTIPOLYGON()"),
388 from_wkt<ML>("MULTILINESTRING()")
389 );
390 }