]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/set_operations/intersection/intersection_multi.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / set_operations / intersection / intersection_multi.cpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands.
5
6// This file was modified by Oracle on 2016.
7// Modifications copyright (c) 2016, Oracle and/or its affiliates.
8// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#include <iostream>
15#include <string>
16
17#include "test_intersection.hpp"
18#include <algorithms/test_overlay.hpp>
19#include <algorithms/overlay/multi_overlay_cases.hpp>
20
21#include <boost/geometry/algorithms/correct.hpp>
22#include <boost/geometry/algorithms/intersection.hpp>
23
24#include <boost/geometry/geometries/point_xy.hpp>
25#include <boost/geometry/geometries/multi_point.hpp>
26#include <boost/geometry/geometries/multi_linestring.hpp>
27#include <boost/geometry/geometries/multi_polygon.hpp>
28
29#include <boost/geometry/io/wkt/read.hpp>
30
b32b8144
FG
31#define TEST_INTERSECTION(caseid, clips, points, area) \
32 (test_one<Polygon, MultiPolygon, MultiPolygon>) \
33 ( #caseid, caseid[0], caseid[1], clips, points, area)
34
92f5a8d4
TL
35#define TEST_INTERSECTION_REV(caseid, clips, points, area) \
36 (test_one<Polygon, MultiPolygon, MultiPolygon>) \
37 ( #caseid "_rev", caseid[1], caseid[0], clips, points, area)
38
b32b8144 39#define TEST_INTERSECTION_IGNORE(caseid, clips, points, area) \
20effc67 40 { ut_settings ignore_validity; ignore_validity.set_test_validity(false); \
b32b8144
FG
41 (test_one<Polygon, MultiPolygon, MultiPolygon>) \
42 ( #caseid, caseid[0], caseid[1], clips, points, area, ignore_validity); }
43
7c673cae
FG
44template <typename Ring, typename Polygon, typename MultiPolygon>
45void test_areal()
46{
7c673cae
FG
47 test_one<Polygon, MultiPolygon, MultiPolygon>("simplex_multi",
48 case_multi_simplex[0], case_multi_simplex[1],
49 2, 12, 6.42);
50
51 test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_no_ip",
52 case_multi_no_ip[0], case_multi_no_ip[1],
53 2, 8, 8.5);
54 test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_2",
55 case_multi_2[0], case_multi_2[1],
56 3, 12, 5.9);
57
58 test_one<Polygon, MultiPolygon, Polygon>("simplex_multi_mp_p",
59 case_multi_simplex[0], case_single_simplex,
60 2, 12, 6.42);
61
62 test_one<Polygon, Ring, MultiPolygon>("simplex_multi_r_mp",
63 case_single_simplex, case_multi_simplex[0],
64 2, 12, 6.42);
65 test_one<Ring, MultiPolygon, Polygon>("simplex_multi_mp_r",
66 case_multi_simplex[0], case_single_simplex,
67 2, 12, 6.42);
68
69 test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_a",
70 case_58_multi[0], case_58_multi[3],
71 3, 12, 0.666666667);
72 test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b",
73 case_58_multi[1], case_58_multi[2],
74 1, 19, 11.16666666667);
75 test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b4",
76 case_58_multi[4], case_58_multi[2],
77 1, 13, 12.66666666);
78 test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b5",
79 case_58_multi[5], case_58_multi[2],
80 1, 13, 13.25);
81 test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b6",
82 case_58_multi[6], case_58_multi[2],
83 1, 13, 13.25);
84 test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b7",
85 case_58_multi[7], case_58_multi[2],
86 1, 16, 12.5);
87
88 // Constructed cases for multi/touch/equal/etc
89 test_one<Polygon, MultiPolygon, MultiPolygon>("case_61_multi",
90 case_61_multi[0], case_61_multi[1],
91 0, 0, 0.0);
92 test_one<Polygon, MultiPolygon, MultiPolygon>("case_62_multi",
93 case_62_multi[0], case_62_multi[1],
94 1, 5, 1.0);
95 test_one<Polygon, MultiPolygon, MultiPolygon>("case_63_multi",
96 case_63_multi[0], case_63_multi[1],
97 1, 5, 1.0);
98 test_one<Polygon, MultiPolygon, MultiPolygon>("case_64_multi",
99 case_64_multi[0], case_64_multi[1],
100 1, 5, 1.0);
101 test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi",
102 case_65_multi[0], case_65_multi[1],
103 1, 5, 1.0);
104 test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi_inv_a",
105 case_65_multi[0], case_65_multi[3],
106 0, 0, 0.0);
107 test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi_inv_b",
108 case_65_multi[1], case_65_multi[2],
109 2, 10, 3.0);
110 test_one<Polygon, MultiPolygon, MultiPolygon>("case_72_multi",
111 case_72_multi[0], case_72_multi[1],
112 3, 14, 2.85);
113 test_one<Polygon, MultiPolygon, MultiPolygon>("case_72_multi_inv_b",
114 case_72_multi[1], case_72_multi[2],
b32b8144 115 3, 16, 6.15);
7c673cae
FG
116 test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi",
117 case_77_multi[0], case_77_multi[1],
11fdf7f2 118 5, 27, 9.0);
7c673cae
FG
119 test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
120 case_78_multi[0], case_78_multi[1],
b32b8144 121 1, 16, 22.0);
7c673cae
FG
122 test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
123 case_101_multi[0], case_101_multi[1],
124 4, 22, 4.75);
125 test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi",
126 case_102_multi[0], case_102_multi[1],
127 3, 26, 19.75);
128 test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi_inv_b",
129 case_102_multi[1], case_102_multi[2],
b32b8144 130 6, 25, 3.75);
7c673cae
FG
131 test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi",
132 case_107_multi[0], case_107_multi[1],
133 2, 10, 1.5);
134 test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi_inv_b",
135 case_107_multi[1], case_107_multi[2],
136 3, 13, 3.0);
137
92f5a8d4 138#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
b32b8144 139 {
92f5a8d4 140 // Rescaling misses one intersection
b32b8144
FG
141 test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi",
142 case_108_multi[0], case_108_multi[1],
92f5a8d4 143 7, -1, 7.5);
b32b8144 144 }
7c673cae 145#endif
b32b8144
FG
146
147 TEST_INTERSECTION(case_123_multi, 3, 13, 1.875);
148 TEST_INTERSECTION(case_124_multi, 2, 13, 2.0625);
149 TEST_INTERSECTION(case_125_multi, 3, 17, 2.1);
b32b8144 150 TEST_INTERSECTION(case_126_multi, 5, 27, 9.0);
b32b8144
FG
151 TEST_INTERSECTION(case_127_multi, 3, 19, 24.0);
152 TEST_INTERSECTION(case_128_multi, 2, 26, 75.5);
153 TEST_INTERSECTION(case_129_multi, 1, 20, 20.5);
154 TEST_INTERSECTION(case_130_multi, 2, 30, 39.0);
155
156 TEST_INTERSECTION(case_133_multi, 2, 23, 40.625);
157 TEST_INTERSECTION(case_134_multi, 1, 23, 42.0);
11fdf7f2
TL
158 TEST_INTERSECTION(case_135_multi, 1, 12, 7.0);
159 TEST_INTERSECTION(case_136_multi, 1, 12, 6.5);
160 TEST_INTERSECTION(case_137_multi, 1, 12, 6.5);
b32b8144
FG
161
162 TEST_INTERSECTION(case_138_multi, 2, 23, 40.4);
163 TEST_INTERSECTION(case_139_multi, 2, 23, 40.546875);
164 TEST_INTERSECTION(case_140_multi, 2, 23, 40.546875);
11fdf7f2 165 TEST_INTERSECTION(case_141_multi, 3, -1, 74.5);
b32b8144 166
11fdf7f2 167 TEST_INTERSECTION(case_recursive_boxes_1, 10, 89, 47.0);
b32b8144 168
7c673cae
FG
169 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_2",
170 case_recursive_boxes_2[0], case_recursive_boxes_2[1],
b32b8144 171 1, 50, 90.0); // Area from SQL Server
7c673cae
FG
172 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3",
173 case_recursive_boxes_3[0], case_recursive_boxes_3[1],
11fdf7f2 174 19, 84, 12.5); // Area from SQL Server
7c673cae 175
11fdf7f2 176 TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 13, 158, 67.0);
7c673cae
FG
177
178 // Fixed by replacing handle_tangencies in less_by_segment_ratio sort order
b32b8144 179 // Should contain 6 output polygons
7c673cae
FG
180 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6",
181 case_recursive_boxes_6[0], case_recursive_boxes_6[1],
11fdf7f2 182 6, 42, 19.0);
7c673cae
FG
183
184 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7",
185 case_recursive_boxes_7[0], case_recursive_boxes_7[1],
186 2, 9, 1.5);
187
188 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_8",
189 case_recursive_boxes_8[0], case_recursive_boxes_8[1],
190 3, 19, 3.75);
191
192 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_9",
193 case_recursive_boxes_9[0], case_recursive_boxes_9[1],
194 5, 27, 4.25);
195 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_10",
196 case_recursive_boxes_10[0], case_recursive_boxes_10[1],
197 2, 8, 0.75);
198 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_11",
199 case_recursive_boxes_11[0], case_recursive_boxes_11[1],
200 2, 8, 1.0);
201 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_12",
202 case_recursive_boxes_12[0], case_recursive_boxes_12[1],
203 1, 4, 0.5);
204 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_13",
205 case_recursive_boxes_13[0], case_recursive_boxes_13[1],
206 0, 0, 0.0);
207 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_14",
208 case_recursive_boxes_14[0], case_recursive_boxes_14[1],
209 0, 0, 0.0);
210 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_15",
211 case_recursive_boxes_15[0], case_recursive_boxes_15[1],
212 1, 4, 0.5);
213 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_16",
214 case_recursive_boxes_16[0], case_recursive_boxes_16[1],
215 9, 43, 10.0);
216 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_17",
217 case_recursive_boxes_17[0], case_recursive_boxes_17[1],
218 7, -1, 7.75);
219 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_18",
220 case_recursive_boxes_18[0], case_recursive_boxes_18[1],
221 0, 0, 0.0);
222 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_19",
223 case_recursive_boxes_19[0], case_recursive_boxes_19[1],
224 0, 0, 0.0);
225 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_20",
226 case_recursive_boxes_20[0], case_recursive_boxes_20[1],
227 2, 0, 1.0);
228 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_21",
229 case_recursive_boxes_21[0], case_recursive_boxes_21[1],
230 1, 0, 0.5);
231 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_22",
232 case_recursive_boxes_22[0], case_recursive_boxes_22[1],
233 0, 0, 0.0);
234 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_23",
235 case_recursive_boxes_23[0], case_recursive_boxes_23[1],
236 1, 0, 0.5);
237 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_24",
238 case_recursive_boxes_24[0], case_recursive_boxes_24[1],
239 1, 0, 0.5);
240 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_25",
241 case_recursive_boxes_25[0], case_recursive_boxes_25[1],
242 1, 0, 0.5);
243 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_26",
244 case_recursive_boxes_26[0], case_recursive_boxes_26[1],
245 1, 0, 2.5);
246 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_27",
247 case_recursive_boxes_27[0], case_recursive_boxes_27[1],
248 1, 0, 0.5);
249 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_28",
250 case_recursive_boxes_28[0], case_recursive_boxes_28[1],
251 2, 0, 1.0);
252 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_29",
253 case_recursive_boxes_29[0], case_recursive_boxes_29[1],
254 5, 0, 3.75);
255 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_30",
256 case_recursive_boxes_30[0], case_recursive_boxes_30[1],
257 4, 0, 6.0);
258 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_31",
259 case_recursive_boxes_31[0], case_recursive_boxes_31[1],
260 2, 0, 2.5);
261 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_32",
262 case_recursive_boxes_32[0], case_recursive_boxes_32[1],
263 2, 0, 1.75);
264 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_33",
265 case_recursive_boxes_33[0], case_recursive_boxes_33[1],
266 3, 0, 2.0);
267 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_34",
268 case_recursive_boxes_34[0], case_recursive_boxes_34[1],
b32b8144 269 2, 0, 17.25);
7c673cae
FG
270 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_35",
271 case_recursive_boxes_35[0], case_recursive_boxes_35[1],
b32b8144 272 2, 0, 20.0);
7c673cae
FG
273 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_36",
274 case_recursive_boxes_36[0], case_recursive_boxes_36[1],
275 1, 0, 0.5);
276 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_37",
277 case_recursive_boxes_37[0], case_recursive_boxes_37[1],
278 2, 0, 1.0);
279
b32b8144
FG
280 TEST_INTERSECTION(case_recursive_boxes_39, 3, 0, 3.0);
281 TEST_INTERSECTION(case_recursive_boxes_40, 1, 0, 1.0);
282 TEST_INTERSECTION(case_recursive_boxes_41, 1, 0, 23.5);
283 TEST_INTERSECTION(case_recursive_boxes_42, 1, 29, 95.0);
284 TEST_INTERSECTION(case_recursive_boxes_43, 2, 0, 22.5);
285 TEST_INTERSECTION(case_recursive_boxes_44, 2, 0, 3.0);
286 TEST_INTERSECTION(case_recursive_boxes_45, 7, 0, 12.0);
287 TEST_INTERSECTION(case_recursive_boxes_46, 6, -1, 7.0);
288 TEST_INTERSECTION(case_recursive_boxes_47, 1, 5, 1.0);
289 TEST_INTERSECTION(case_recursive_boxes_48, 1, 5, 1.0);
290 TEST_INTERSECTION(case_recursive_boxes_49, 7, 57, 20.0);
11fdf7f2
TL
291 TEST_INTERSECTION(case_recursive_boxes_50, 9, 62, 26.0);
292 TEST_INTERSECTION(case_recursive_boxes_51, 14, 74, 19.0);
b32b8144
FG
293 TEST_INTERSECTION(case_recursive_boxes_52, 8, -1, 22.0);
294 TEST_INTERSECTION(case_recursive_boxes_53, 1, -1, 19.75);
295 TEST_INTERSECTION(case_recursive_boxes_54, 3, -1, 10.0);
296 TEST_INTERSECTION(case_recursive_boxes_55, 5, -1, 2.25);
297 TEST_INTERSECTION(case_recursive_boxes_56, 1, -1, 0.5);
298 TEST_INTERSECTION(case_recursive_boxes_57, 10, -1, 9.5);
299 TEST_INTERSECTION(case_recursive_boxes_58, 1, -1, 0.25);
300 TEST_INTERSECTION(case_recursive_boxes_59, 8, -1, 8.25);
301 TEST_INTERSECTION(case_recursive_boxes_60, 8, -1, 10.0);
302 TEST_INTERSECTION(case_recursive_boxes_61, 2, -1, 20.0);
303 TEST_INTERSECTION(case_recursive_boxes_62, 9, -1, 10.5);
b32b8144 304 TEST_INTERSECTION(case_recursive_boxes_63, 11, -1, 5.75);
b32b8144 305 TEST_INTERSECTION(case_recursive_boxes_64, 5, -1, 17.25);
b32b8144 306 TEST_INTERSECTION(case_recursive_boxes_65, 3, -1, 17.25);
b32b8144 307 TEST_INTERSECTION(case_recursive_boxes_66, 4, -1, 16.0);
b32b8144
FG
308 TEST_INTERSECTION(case_recursive_boxes_67, 5, -1, 2.5);
309 TEST_INTERSECTION(case_recursive_boxes_68, 8, -1, 9.5);
310 TEST_INTERSECTION(case_recursive_boxes_69, 6, -1, 3.25);
b32b8144 311 TEST_INTERSECTION(case_recursive_boxes_70, 6, -1, 18.5);
b32b8144
FG
312 TEST_INTERSECTION(case_recursive_boxes_71, 3, -1, 1.75);
313 TEST_INTERSECTION(case_recursive_boxes_72, 8, -1, 4.5);
314 TEST_INTERSECTION(case_recursive_boxes_73, 3, -1, 18.5);
b32b8144 315 TEST_INTERSECTION(case_recursive_boxes_74, 3, -1, 20.25);
b32b8144
FG
316 TEST_INTERSECTION(case_recursive_boxes_75, 5, -1, 16.75);
317 TEST_INTERSECTION(case_recursive_boxes_76, 2, -1, 18.25);
318 TEST_INTERSECTION(case_recursive_boxes_77, 5, -1, 3.5);
319 TEST_INTERSECTION(case_recursive_boxes_78, 9, -1, 8.0);
320 TEST_INTERSECTION(case_recursive_boxes_79, 5, -1, 9.0);
321 TEST_INTERSECTION(case_recursive_boxes_80, 1, -1, 0.25);
11fdf7f2 322 TEST_INTERSECTION(case_recursive_boxes_81, 5, -1, 3.75);
11fdf7f2 323 TEST_INTERSECTION(case_recursive_boxes_82, 5, -1, 8.5);
11fdf7f2
TL
324 TEST_INTERSECTION(case_recursive_boxes_83, 5, -1, 10.25);
325 TEST_INTERSECTION(case_recursive_boxes_84, 1, -1, 0.5);
92f5a8d4 326#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
11fdf7f2
TL
327 TEST_INTERSECTION(case_recursive_boxes_85, 1, -1, 0.25);
328#endif
329 TEST_INTERSECTION(case_recursive_boxes_86, 0, -1, 0.0);
330 TEST_INTERSECTION(case_recursive_boxes_87, 0, -1, 0.0);
331 TEST_INTERSECTION(case_recursive_boxes_88, 4, -1, 3.5);
b32b8144 332
92f5a8d4
TL
333#if ! defined(BOOST_GEOMETRY_USE_RESCALING)
334 TEST_INTERSECTION(case_precision_m1, 1, -1, 14.0);
335 TEST_INTERSECTION(case_precision_m2, 2, -1, 15.25);
336 TEST_INTERSECTION_REV(case_precision_m1, 1, -1, 14.0);
337 TEST_INTERSECTION_REV(case_precision_m2, 2, -1, 15.25);
338#else
339 // Validity: false positives (very small triangles looking like a line)
340 TEST_INTERSECTION_IGNORE(case_precision_m1, 1, -1, 14.0);
341 TEST_INTERSECTION_IGNORE(case_precision_m2, 2, -1, 15.25);
342#endif
343
7c673cae
FG
344 test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
345 ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
346 2, 10, 6.0); // Area from SQL Server
347 test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_b",
348 ggl_list_20120915_h2[0], ggl_list_20120915_h2[2],
349 2, 10, 6.0); // Area from SQL Server
350
351 test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081",
352 ticket_9081[0], ticket_9081[1],
20effc67 353 count_set(2, 4), 10, 0.0019812556);
7c673cae 354
92f5a8d4 355 // Should generate output, even for <float>
20effc67 356 // For long double two small extra slivers are generated
92f5a8d4
TL
357 test_one<Polygon, MultiPolygon, MultiPolygon>("mail_2019_01_21_johan",
358 mail_2019_01_21_johan[2], mail_2019_01_21_johan[3],
20effc67 359 count_set(2, 4), -1, 0.0005889587);
92f5a8d4 360
20effc67
TL
361 // Might generate a very small triangle, which is acceptable
362 TEST_INTERSECTION(ticket_11018, count_set(0, 1), 0, expectation_limits(0.0, 4.0e-7));
7c673cae 363
b32b8144
FG
364 TEST_INTERSECTION(ticket_12503, 2, 13, 17.375);
365
92f5a8d4
TL
366#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
367 // Result is wrong with rescaling
368 TEST_INTERSECTION(issue_630_a, 1, -1, 0.1770);
369#endif
1e59de90 370
20effc67 371 TEST_INTERSECTION(issue_630_b, 1, -1, expectation_limits(0.1713911, 0.1714));
92f5a8d4
TL
372
373#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
1e59de90
TL
374 // Result is missing with rescaling
375 TEST_INTERSECTION(issue_630_c, 1, -1, 0.1770);
376
92f5a8d4
TL
377 // Result is missing with rescaling
378 TEST_INTERSECTION(issue_643, 1, -1, 3.4615);
379#endif
380
1e59de90
TL
381 TEST_INTERSECTION(issue_869_c, 3, -1, 3600);
382
383 TEST_INTERSECTION(issue_888_34, 7, -1, 0.0256838);
384 TEST_INTERSECTION(issue_888_37, 13, -1, 0.0567043);
7c673cae 385
1e59de90 386 TEST_INTERSECTION(mysql_23023665_7, 2, 11, 9.80505786783);
b32b8144 387 TEST_INTERSECTION(mysql_23023665_12, 2, 0, 11.812440191387557);
b32b8144 388 TEST_INTERSECTION(mysql_regression_1_65_2017_08_31, 2, -1, 29.9022122);
7c673cae
FG
389}
390
391template <typename Polygon, typename MultiPolygon, typename Box>
392void test_areal_clip()
393{
394 static std::string const clip = "POLYGON((1 1,4 4))";
395 test_one<Polygon, Box, MultiPolygon>("simplex_multi_mp_b", clip, case_multi_simplex[0],
396 2, 11, 6.791666);
397 test_one<Polygon, MultiPolygon, Box>("simplex_multi_b_mp", case_multi_simplex[0], clip,
398 2, 11, 6.791666);
399}
400
401template <typename LineString, typename MultiLineString, typename Box>
402void test_linear()
403{
404 typedef typename bg::point_type<MultiLineString>::type point;
405 test_one<point, MultiLineString, MultiLineString>("case_multi_ml_ml_1",
406 "MULTILINESTRING((0 0,1 1))", "MULTILINESTRING((0 1,1 0))",
407 1, 1, 0.0);
408 test_one<point, MultiLineString, MultiLineString>("case_multi_ml_ml_2",
409 "MULTILINESTRING((0 0,1 1),(0.5 0,1.5 1))", "MULTILINESTRING((0 1,1 0),(0.5 1,1.5 0))",
410 4, 4, 0.0);
411
412 test_one<point, LineString, MultiLineString>("case_multi_l_ml",
413 "LINESTRING(0 0,1 1)", "MULTILINESTRING((0 1,1 0),(0.5 1,1.5 0))",
414 2, 2, 0.0);
415 test_one<point, MultiLineString, LineString>("case_multi_ml_l",
416 "MULTILINESTRING((0 1,1 0),(0.5 1,1.5 0))", "LINESTRING(0 0,1 1)",
417 2, 2, 0.0);
418
419 test_one<LineString, MultiLineString, Box>("case_multi_ml_b",
420 "MULTILINESTRING((0 0,3 3)(1 0,4 3))", "POLYGON((1 1,3 2))",
421 2, 4, 2.0 * std::sqrt(2.0));
422 test_one<LineString, Box, MultiLineString>("case_multi_b_ml",
423 "POLYGON((1 1,3 2))", "MULTILINESTRING((0 0,3 3)(1 0,4 3))",
424 2, 4, 2.0 * std::sqrt(2.0));
425}
426
427template <typename P>
428void test_point_output()
429{
430 typedef bg::model::box<P> box;
431 typedef bg::model::linestring<P> linestring;
432 typedef bg::model::polygon<P> polygon;
433 typedef bg::model::multi_polygon<polygon> multi_polygon;
434
435 test_point_output<multi_polygon, multi_polygon>(case_multi_simplex[0], case_multi_simplex[1], 10);
436 test_point_output<linestring, multi_polygon>("linestring(4 0,0 4)", case_multi_simplex[0], 4);
437 test_point_output<box, multi_polygon>("box(3 0,4 6)", case_multi_simplex[0], 8);
438}
439
440template <typename MultiPolygon, typename MultiLineString>
441void test_areal_linear()
442{
443 typedef typename boost::range_value<MultiPolygon>::type Polygon;
444 typedef typename boost::range_value<MultiLineString>::type LineString;
445 typedef typename bg::point_type<Polygon>::type Point;
446 typedef bg::model::ring<Point> Ring;
447
448 test_one_lp<LineString, MultiPolygon, LineString>("case_mp_ls_1", case_multi_simplex[0], "LINESTRING(2 0,2 5)", 2, 4, 3.70);
449 test_one_lp<LineString, Polygon, MultiLineString>("case_p_mls_1", case_single_simplex, "MULTILINESTRING((2 0,2 5),(3 0,3 5))", 2, 4, 7.5);
450 test_one_lp<LineString, MultiPolygon, MultiLineString>("case_mp_mls_1", case_multi_simplex[0], "MULTILINESTRING((2 0,2 5),(3 0,3 5))", 4, 8, 6.8333333);
451 test_one_lp<LineString, Ring, MultiLineString>("case_r_mls_1", case_single_simplex, "MULTILINESTRING((2 0,2 5),(3 0,3 5))", 2, 4, 7.5);
452}
453
454template <typename P>
455void test_all()
456{
457 typedef bg::model::ring<P> ring;
458 typedef bg::model::polygon<P> polygon;
459 typedef bg::model::multi_polygon<polygon> multi_polygon;
460 test_areal<ring, polygon, multi_polygon>();
461
462#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
463
464 typedef bg::model::ring<P, false> ring_ccw;
465 typedef bg::model::polygon<P, false> polygon_ccw;
466 typedef bg::model::multi_polygon<polygon_ccw> multi_polygon_ccw;
467 test_areal<ring_ccw, polygon_ccw, multi_polygon_ccw>();
468
469 typedef bg::model::ring<P, true, false> ring_open;
470 typedef bg::model::polygon<P, true, false> polygon_open;
471 typedef bg::model::multi_polygon<polygon_open> multi_polygon_open;
472 test_areal<ring_open, polygon_open, multi_polygon_open>();
473
474 typedef bg::model::ring<P, false, false> ring_open_ccw;
475 typedef bg::model::polygon<P, false, false> polygon_open_ccw;
476 typedef bg::model::multi_polygon<polygon_open_ccw> multi_polygon_open_ccw;
477 test_areal<ring_open_ccw, polygon_open_ccw, multi_polygon_open_ccw>();
478
479 typedef bg::model::box<P> box;
480 test_areal_clip<polygon, multi_polygon, box>();
481 test_areal_clip<polygon_ccw, multi_polygon_ccw, box>();
482
483 typedef bg::model::linestring<P> linestring;
484 typedef bg::model::multi_linestring<linestring> multi_linestring;
485
486 test_linear<linestring, multi_linestring, box>();
487 test_areal_linear<multi_polygon, multi_linestring>();
488#endif
489
490 test_point_output<P>();
7c673cae
FG
491}
492
493
494int test_main(int, char* [])
495{
92f5a8d4
TL
496 BoostGeometryWriteTestConfiguration();
497 test_all<bg::model::d2::point_xy<default_test_type> >();
7c673cae
FG
498
499#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
500 test_all<bg::model::d2::point_xy<float> >();
7c673cae
FG
501#endif
502
20effc67 503#if defined(BOOST_GEOMETRY_TEST_FAILURES)
1e59de90 504 BoostGeometryWriteExpectedFailures(9, 1, 2, 1);
7c673cae
FG
505#endif
506
507 return 0;
508}