]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/set_operations/difference/difference_multi.cpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / set_operations / difference / difference_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// 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#include <iostream>
11#include <string>
12
13#include "test_difference.hpp"
14#include <algorithms/test_overlay.hpp>
15#include <algorithms/overlay/multi_overlay_cases.hpp>
16
17#include <boost/geometry/algorithms/correct.hpp>
18#include <boost/geometry/algorithms/intersection.hpp>
19
20#include <boost/geometry/geometries/point_xy.hpp>
21#include <boost/geometry/geometries/multi_point.hpp>
22#include <boost/geometry/geometries/multi_polygon.hpp>
23
24#include <boost/geometry/io/wkt/read.hpp>
25
b32b8144
FG
26// Convenience macros (points are not checked)
27#define TEST_DIFFERENCE(caseid, clips1, area1, clips2, area2, clips3) \
28 (test_one<Polygon, MultiPolygon, MultiPolygon>) \
29 ( #caseid, caseid[0], caseid[1], clips1, -1, area1, clips2, -1, area2, \
30 clips3, -1, area1 + area2)
31
32#define TEST_DIFFERENCE_IGNORE(caseid, clips1, area1, clips2, area2, clips3) \
20effc67 33 { ut_settings ignore_validity; ignore_validity.set_test_validity(false); \
b32b8144
FG
34 (test_one<Polygon, MultiPolygon, MultiPolygon>) \
35 ( #caseid, caseid[0], caseid[1], clips1, -1, area1, clips2, -1, area2, \
36 clips3, -1, area1 + area2, ignore_validity); }
37
38#define TEST_DIFFERENCE_WITH(index1, index2, caseid, clips1, area1, \
39 clips2, area2, clips3) \
40 (test_one<Polygon, MultiPolygon, MultiPolygon>) \
41 ( #caseid "_" #index1 "_" #index2, caseid[index1], caseid[index2], \
42 clips1, -1, area1, \
43 clips2, -1, area2, \
44 clips3, -1, area1 + area2, settings)
45
46
7c673cae
FG
47template <typename Ring, typename Polygon, typename MultiPolygon>
48void test_areal()
49{
7c673cae
FG
50 test_one<Polygon, MultiPolygon, MultiPolygon>("simplex_multi",
51 case_multi_simplex[0], case_multi_simplex[1],
52 5, 21, 5.58, 4, 17, 2.58);
53
54 test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_no_ip",
55 case_multi_no_ip[0], case_multi_no_ip[1],
56 2, 12, 24.0, 2, 12, 34.0);
57 test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_2",
58 case_multi_2[0], case_multi_2[1],
59 2, 15, 19.6, 2, 13, 33.6);
60
61 test_one<Polygon, MultiPolygon, Polygon>("simplex_multi_mp_p",
62 case_multi_simplex[0], case_single_simplex,
63 5, 21, 5.58, 4, 17, 2.58);
64 test_one<Polygon, Ring, MultiPolygon>("simplex_multi_r_mp",
65 case_single_simplex, case_multi_simplex[0],
66 4, 17, 2.58, 5, 21, 5.58);
67 test_one<Polygon, MultiPolygon, Ring>("simplex_multi_mp_r",
68 case_multi_simplex[0], case_single_simplex,
69 5, 21, 5.58, 4, 17, 2.58);
70
71 // Constructed cases for multi/touch/equal/etc
72 test_one<Polygon, MultiPolygon, MultiPolygon>("case_61_multi",
73 case_61_multi[0], case_61_multi[1],
74 2, 10, 2, 2, 10, 2, 1, 10, 4);
75 test_one<Polygon, MultiPolygon, MultiPolygon>("case_62_multi",
76 case_62_multi[0], case_62_multi[1],
77 0, 0, 0, 1, 5, 1);
78 test_one<Polygon, MultiPolygon, MultiPolygon>("case_63_multi",
79 case_63_multi[0], case_63_multi[1],
80 0, 0, 0, 1, 5, 1);
81 test_one<Polygon, MultiPolygon, MultiPolygon>("case_64_multi",
82 case_64_multi[0], case_64_multi[1],
83 1, 5, 1, 1, 5, 1, 1, 7, 2);
84 test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi",
85 case_65_multi[0], case_65_multi[1],
86 0, 0, 0, 2, 10, 3);
87
88 test_one<Polygon, MultiPolygon, MultiPolygon>("case_72_multi",
89 case_72_multi[0], case_72_multi[1],
b32b8144 90 3, 13, 1.65, 3, 17, 6.15);
7c673cae
FG
91
92 test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi",
93 case_77_multi[0], case_77_multi[1],
94 6, 31, 7.0,
11fdf7f2
TL
95 5, 33, 13.0,
96 5, 38, 7.0 + 13.0);
7c673cae
FG
97
98 test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
99 case_78_multi[0], case_78_multi[1],
100 1, 5, 1.0, 1, 5, 1.0);
101
b32b8144
FG
102 TEST_DIFFERENCE(case_123_multi, 1, 0.25, 2, 0.625, 3);
103 TEST_DIFFERENCE(case_124_multi, 1, 0.25, 2, 0.4375, 3);
104 TEST_DIFFERENCE(case_125_multi, 1, 0.25, 2, 0.400, 3);
105
106 // A should have 3 clips, B should have 5 clips
b32b8144 107 TEST_DIFFERENCE(case_126_multi, 4, 16.0, 5, 27.0, 9);
b32b8144 108
7c673cae
FG
109 {
110 ut_settings settings;
111
92f5a8d4 112 settings.sym_difference = BG_IF_RESCALED(false, true);
7c673cae
FG
113
114 test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi",
115 case_108_multi[0], case_108_multi[1],
116 7, 32, 5.5,
11fdf7f2 117 4, 24, 9.75,
7c673cae
FG
118 7, 45, 15.25,
119 settings);
120 }
121
122 // Ticket on GGL list 2011/10/25
123 // to mix polygon/multipolygon in call to difference
124 test_one<Polygon, Polygon, Polygon>("ggl_list_20111025_vd_pp",
125 ggl_list_20111025_vd[0], ggl_list_20111025_vd[1],
126 1, 4, 8.0, 1, 4, 12.5);
127 test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_pm",
128 ggl_list_20111025_vd[0], ggl_list_20111025_vd[3],
129 1, 4, 8.0, 1, 4, 12.5);
130 test_one<Polygon, MultiPolygon, Polygon>("ggl_list_20111025_vd_mp",
131 ggl_list_20111025_vd[2], ggl_list_20111025_vd[1],
132 1, 4, 8.0, 1, 4, 12.5);
133 test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20111025_vd_mm",
134 ggl_list_20111025_vd[2], ggl_list_20111025_vd[3],
135 1, 4, 8.0, 1, 4, 12.5);
136
137 test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_2",
138 ggl_list_20111025_vd_2[0], ggl_list_20111025_vd_2[1],
139 1, 7, 10.0, 2, 10, 6.0);
140
141 test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
142 ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
143 2, 13, 17.0, 0, 0, 0.0);
144 test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_b",
145 ggl_list_20120915_h2[0], ggl_list_20120915_h2[2],
146 2, 13, 17.0, 0, 0, 0.0);
147
148 {
149 ut_settings settings;
150 settings.percentage = 0.001;
20effc67 151 settings.set_test_validity(BG_IF_RESCALED(true, false));
b32b8144 152 TEST_DIFFERENCE_WITH(0, 1, ggl_list_20120221_volker, 2, 7962.66, 2, 2775258.93, 4);
92f5a8d4
TL
153 }
154
1e59de90 155#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
92f5a8d4 156 {
1e59de90
TL
157 // 1: Very small sliver for B (discarded when rescaling)
158 // 2: sym difference is not considered as valid (without rescaling
159 // this is a false negative)
160 // 3: with rescaling A is considered as invalid (robustness problem)
92f5a8d4 161 ut_settings settings;
1e59de90
TL
162 settings.validity_of_sym = BG_IF_RESCALED(false, true);
163 settings.validity_false_negative_sym = true;
20effc67
TL
164 TEST_DIFFERENCE_WITH(0, 1, bug_21155501,
165 (count_set(1, 4)), expectation_limits(3.75893, 3.75894),
166 (count_set(1, 4)), (expectation_limits(1.776357e-15, 7.661281e-15)),
167 (count_set(2, 5)));
7c673cae 168 }
1e59de90 169#endif
7c673cae 170
92f5a8d4 171#if defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
11fdf7f2 172 {
92f5a8d4 173 // With rescaling, it is complete but invalid
20effc67 174 // Without rescaling, one ring is missing (for a and s)
11fdf7f2 175 ut_settings settings;
20effc67 176 settings.set_test_validity(BG_IF_RESCALED(false, true));
1e59de90 177 settings.validity_of_sym = BG_IF_RESCALED(false, true);
92f5a8d4
TL
178 TEST_DIFFERENCE_WITH(0, 1, ticket_9081,
179 2, 0.0907392476356186,
180 4, 0.126018011439877,
20effc67 181 count_set(3, 4));
11fdf7f2 182 }
b32b8144
FG
183#endif
184
11fdf7f2 185 TEST_DIFFERENCE(ticket_12503, 46, 920.625, 4, 7.625, 50);
92f5a8d4
TL
186
187 {
188 // Reported issues going wrong with rescaling (except for 630b)
189 ut_settings settings;
190 settings.percentage = 0.001;
191
192#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
20effc67 193 TEST_DIFFERENCE_WITH(0, 1, issue_630_a, 0, expectation_limits(0.0), 1, (expectation_limits(2.023, 2.2004)), 1);
7c673cae 194#endif
1e59de90 195
92f5a8d4 196 TEST_DIFFERENCE_WITH(0, 1, issue_630_b, 1, 0.0056089, 2, 1.498976, 3);
92f5a8d4 197
1e59de90 198#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
92f5a8d4
TL
199 TEST_DIFFERENCE_WITH(0, 1, issue_630_c, 0, 0, 1, 1.493367, 1);
200#endif
201
1e59de90
TL
202#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
203 // Symmetrical difference fails without get_clusters
204 settings.sym_difference = BG_IF_TEST_FAILURES;
20effc67 205 TEST_DIFFERENCE_WITH(0, 1, issue_643, 1, expectation_limits(76.5385), optional(), optional_sliver(1.0e-6), 1);
92f5a8d4
TL
206#endif
207 }
7c673cae 208
1e59de90
TL
209 // Cases below go (or went) wrong in either a ( [0] - [1] ) or b ( [1] - [0] )
210 // Requires reversal of isolation in ii turns. There should be 3 rings.
211 TEST_DIFFERENCE(issue_869_a, 3, 3600, 0, 0, 3); // a went wrong
212
213 TEST_DIFFERENCE(issue_888_34, 22, 0.2506824, 6, 0.0253798, 28); // a went wrong
214 TEST_DIFFERENCE(issue_888_37, 15, 0.0451408, 65, 0.3014843, 80); // b went wrong
215
216 {
217 ut_settings settings;
218 settings.validity_false_negative_a = true;
219 settings.validity_false_negative_sym = true;
220 TEST_DIFFERENCE_WITH(0, 1, issue_888_53, 117, 0.2973268, 17, 0.0525798, 134);
221 }
222
7c673cae
FG
223 // Areas and #clips correspond with POSTGIS (except sym case)
224 test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
225 case_101_multi[0], case_101_multi[1],
226 5, 23, 4.75,
227 5, 40, 12.75,
228 5, 48, 4.75 + 12.75);
229
230 // Areas and #clips correspond with POSTGIS
231 test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi",
232 case_102_multi[0], case_102_multi[1],
233 2, 8, 0.75,
234 6, 25, 3.75,
235 6, 27, 0.75 + 3.75);
236
237 // Areas and #clips correspond with POSTGIS
238 test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi",
239 case_107_multi[0], case_107_multi[1],
240 2, 11, 2.25,
241 3, 14, 3.0,
242 4, 21, 5.25);
243
b32b8144
FG
244 TEST_DIFFERENCE(case_133_multi, 3, 16.0, 2, 8.0, 5);
245 TEST_DIFFERENCE(case_134_multi, 3, 16.0, 2, 8.0, 5);
246 TEST_DIFFERENCE(case_135_multi, 2, 2.0, 2, 13.0, 2);
247 TEST_DIFFERENCE(case_136_multi, 2, 2.0, 3, 13.5, 3);
248 TEST_DIFFERENCE(case_137_multi, 2, 2.5, 2, 13.0, 2);
249 TEST_DIFFERENCE(case_138_multi, 5, 16.6, 3, 8.225, 8);
250 TEST_DIFFERENCE(case_139_multi, 4, 16.328125, 3, 8.078125, 7);
251 TEST_DIFFERENCE(case_140_multi, 4, 16.328125, 3, 8.078125, 7);
252 TEST_DIFFERENCE(case_141_multi, 5, 15.5, 5, 10.0, 10);
253
7c673cae
FG
254 // Areas correspond with POSTGIS,
255 // #clips in PostGIS is 11,11,5 but should most probably be be 12,12,6
b32b8144 256 TEST_DIFFERENCE(case_recursive_boxes_1, 12, 26.0, 12, 24.0, 6);
7c673cae
FG
257
258 // Areas and #clips correspond with POSTGIS
259 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_2",
260 case_recursive_boxes_2[0], case_recursive_boxes_2[1],
261 3, 15, 3.0,
262 7, 33, 7.0,
263 10, 48, 10.0);
264
265 // Areas and #clips by POSTGIS (except sym case)
266 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3",
267 case_recursive_boxes_3[0], case_recursive_boxes_3[1],
268 24, -1, 21.5,
269 25, -1, 22.5,
270 37, -1, 44.0);
271
272 // 4, input is not valid
273
b32b8144 274 TEST_DIFFERENCE(case_recursive_boxes_5, 16, 22.0, 12, 27.0, 10);
b32b8144 275 TEST_DIFFERENCE(case_recursive_boxes_6, 7, 3.5, 3, 1.5, 9);
7c673cae
FG
276
277 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7",
278 case_recursive_boxes_7[0], case_recursive_boxes_7[1],
279 3, 15, 2.75,
280 4, 19, 2.75,
281 3, 22, 5.5);
282
283 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_8",
284 case_recursive_boxes_8[0], case_recursive_boxes_8[1],
285 2, -1, 2.50,
286 4, -1, 5.75,
287 4, -1, 8.25);
288
289 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_9",
290 case_recursive_boxes_9[0], case_recursive_boxes_9[1],
291 3, -1, 1.5,
292 4, -1, 2.5,
293 6, -1, 4.0);
294
295 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_10",
296 case_recursive_boxes_10[0], case_recursive_boxes_10[1],
297 2, -1, 1.25,
298 2, -1, 0.75,
299 4, -1, 2.00);
300
301 test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_11",
302 case_recursive_boxes_11[0], case_recursive_boxes_11[1],
303 3, -1, 2.5,
304 3, -1, 4.5,
305 3, -1, 7.0);
306
b32b8144
FG
307 TEST_DIFFERENCE(case_recursive_boxes_12, 4, 2.75, 3, 2.75, 6);
308 TEST_DIFFERENCE(case_recursive_boxes_13, 4, 4.75, 3, 5.5, 3);
309 TEST_DIFFERENCE(case_recursive_boxes_14, 3, 2.0, 4, 2.5, 5);
310 TEST_DIFFERENCE(case_recursive_boxes_15, 3, 3.0, 2, 2.5, 3);
b32b8144
FG
311 TEST_DIFFERENCE(case_recursive_boxes_16, 8, 6.5, 3, 5.5, 9);
312 TEST_DIFFERENCE(case_recursive_boxes_17, 10, 7.75, 7, 5.5, 13);
b32b8144
FG
313 TEST_DIFFERENCE(case_recursive_boxes_18, 2, 1.0, 1, 1.5, 3);
314 TEST_DIFFERENCE(case_recursive_boxes_19, 2, 1.0, 2, 1.5, 3);
315 TEST_DIFFERENCE(case_recursive_boxes_20, 2, 1.0, 0, 0.0, 2);
316
317 TEST_DIFFERENCE(case_recursive_boxes_21, 2, 1.0, 1, 1.0, 1);
318 TEST_DIFFERENCE(case_recursive_boxes_22, 2, 1.25, 2, 2.0, 2);
319 TEST_DIFFERENCE(case_recursive_boxes_23, 2, 0.75, 1, 0.5, 3);
320 TEST_DIFFERENCE(case_recursive_boxes_24, 3, 2.5, 2, 2.0, 5);
321 TEST_DIFFERENCE(case_recursive_boxes_25, 2, 2.5, 3, 2.5, 2);
322 TEST_DIFFERENCE(case_recursive_boxes_26, 2, 1.5, 3, 2.0, 4);
323 TEST_DIFFERENCE(case_recursive_boxes_27, 1, 1.5, 3, 2.5, 3);
324 TEST_DIFFERENCE(case_recursive_boxes_28, 3, 2.5, 2, 3.0, 4);
325 TEST_DIFFERENCE(case_recursive_boxes_29, 5, 7.25, 5, 4.5, 5);
326 TEST_DIFFERENCE(case_recursive_boxes_30, 6, 4.25, 3, 7.25, 7);
327
328 TEST_DIFFERENCE(case_recursive_boxes_31, 2, 2.0, 1, 0.5, 2);
329 TEST_DIFFERENCE(case_recursive_boxes_32, 2, 2.75, 2, 1.25, 2);
330 TEST_DIFFERENCE(case_recursive_boxes_33, 4, 3.0, 3, 6.0, 4);
b32b8144 331 TEST_DIFFERENCE(case_recursive_boxes_34, 7, 7.25, 1, 0.5, 8);
b32b8144
FG
332 TEST_DIFFERENCE(case_recursive_boxes_35, 5, 1.75, 5, 2.75, 10);
333 TEST_DIFFERENCE(case_recursive_boxes_36, 2, 1.0, 2, 1.5, 3);
334 TEST_DIFFERENCE(case_recursive_boxes_37, 3, 2.5, 2, 4.25, 2);
335 TEST_DIFFERENCE(case_recursive_boxes_38, 5, 7.75, 4, 3.5, 3);
336 TEST_DIFFERENCE(case_recursive_boxes_39, 3, 6.0, 3, 3.0, 4);
337 TEST_DIFFERENCE(case_recursive_boxes_40, 11, 14.0, 9, 13.0, 11);
338
339 TEST_DIFFERENCE(case_recursive_boxes_41, 1, 0.5, 1, 0.5, 2);
b32b8144 340 TEST_DIFFERENCE(case_recursive_boxes_42, 1, 1.0, 4, 4.0, 5);
b32b8144
FG
341 TEST_DIFFERENCE(case_recursive_boxes_43, 1, 0.5, 3, 2.0, 4);
342 TEST_DIFFERENCE(case_recursive_boxes_44, 3, 5.0, 0, 0.0, 3);
343 TEST_DIFFERENCE(case_recursive_boxes_45, 6, 20.0, 7, 20.0, 3);
344 TEST_DIFFERENCE(case_recursive_boxes_46, 4, 14.0, 5, 12.0, 5);
345 TEST_DIFFERENCE(case_recursive_boxes_47, 4, 10.0, 7, 11.0, 1);
346 TEST_DIFFERENCE(case_recursive_boxes_48, 0, 0.0, 1, 9.0, 1);
b32b8144 347 TEST_DIFFERENCE(case_recursive_boxes_49, 10, 22.0, 10, 17.0, 11);
b32b8144
FG
348 TEST_DIFFERENCE(case_recursive_boxes_50, 14, 21.0, 16, 21.0, 14);
349 TEST_DIFFERENCE(case_recursive_boxes_51, 14, 25.0, 12, 31.0, 7);
b32b8144 350 TEST_DIFFERENCE(case_recursive_boxes_52, 13, 30.0, 15, 25.0, 8);
b32b8144
FG
351 TEST_DIFFERENCE(case_recursive_boxes_53, 6, 3.5, 4, 1.5, 9);
352 TEST_DIFFERENCE(case_recursive_boxes_54, 6, 6.5, 8, 6.0, 7);
353 TEST_DIFFERENCE(case_recursive_boxes_55, 4, 5.5, 6, 7.75, 4);
b32b8144 354 TEST_DIFFERENCE(case_recursive_boxes_56, 4, 4.5, 5, 2.75, 6);
b32b8144
FG
355 TEST_DIFFERENCE(case_recursive_boxes_57, 5, 3.75, 9, 6.5, 10);
356 TEST_DIFFERENCE(case_recursive_boxes_58, 4, 2.25, 6, 3.75, 7);
b32b8144 357 TEST_DIFFERENCE(case_recursive_boxes_59, 8, 6.5, 7, 7.0, 12);
b32b8144 358 TEST_DIFFERENCE(case_recursive_boxes_60, 6, 5.25, 7, 5.25, 11);
b32b8144 359 TEST_DIFFERENCE(case_recursive_boxes_61, 2, 1.5, 6, 2.0, 7);
92f5a8d4
TL
360#if defined(BOOST_GEOMETRY_TEST_FAILURES)
361 // Misses one triangle, should be fixed in traversal.
362 // It is not related to rescaling.
b32b8144
FG
363 TEST_DIFFERENCE(case_recursive_boxes_62, 5, 5.0, 11, 5.75, 12);
364#endif
365
b32b8144 366 TEST_DIFFERENCE(case_recursive_boxes_63, 9, 10.5, 5, 27.75, 4);
b32b8144 367 TEST_DIFFERENCE(case_recursive_boxes_64, 6, 2.75, 7, 4.5, 11);
b32b8144 368 TEST_DIFFERENCE(case_recursive_boxes_65, 6, 4.25, 7, 3.0, 13);
b32b8144
FG
369 TEST_DIFFERENCE(case_recursive_boxes_66, 5, 4.75, 7, 4.0, 9);
370 TEST_DIFFERENCE(case_recursive_boxes_67, 7, 6.25, 9, 6.0, 10);
371 TEST_DIFFERENCE(case_recursive_boxes_68, 10, 6.5, 9, 6.5, 7);
372 TEST_DIFFERENCE(case_recursive_boxes_69, 5, 6.25, 5, 6.75, 8);
b32b8144 373 TEST_DIFFERENCE(case_recursive_boxes_70, 5, 2.0, 8, 4.5, 11);
b32b8144 374 TEST_DIFFERENCE(case_recursive_boxes_71, 7, 8.25, 7, 5.75, 8);
b32b8144
FG
375 TEST_DIFFERENCE(case_recursive_boxes_72, 6, 6.5, 7, 4.0, 10);
376 TEST_DIFFERENCE(case_recursive_boxes_73, 4, 1.75, 5, 4.0, 8);
b32b8144 377 TEST_DIFFERENCE(case_recursive_boxes_74, 3, 3.00, 3, 1.5, 5);
b32b8144 378 TEST_DIFFERENCE(case_recursive_boxes_75, 7, 4.5, 4, 2.0, 11);
b32b8144
FG
379 TEST_DIFFERENCE(case_recursive_boxes_76, 7, 3.75, 4, 2.5, 9);
380 TEST_DIFFERENCE(case_recursive_boxes_77, 4, 3.75, 7, 6.25, 8);
381 TEST_DIFFERENCE(case_recursive_boxes_78, 11, 5.5, 8, 4.5, 14);
b32b8144 382 TEST_DIFFERENCE(case_recursive_boxes_79, 2, 1.25, 6, 4.5, 8);
b32b8144 383
b32b8144 384 // one polygon is divided into two, for same reason as union creates a small
20effc67
TL
385 // interior ring there, which is acceptable
386 TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, count_set(2, 3));
b32b8144 387
11fdf7f2 388 TEST_DIFFERENCE(case_recursive_boxes_81, 3, 5.0, 6, 6.75, 6);
11fdf7f2 389 TEST_DIFFERENCE(case_recursive_boxes_82, 5, 7.25, 7, 4.5, 8);
11fdf7f2
TL
390 TEST_DIFFERENCE(case_recursive_boxes_83, 9, 5.25, 8, 5.25, 12);
391 TEST_DIFFERENCE(case_recursive_boxes_84, 4, 8.0, 7, 9.0, 4);
92f5a8d4 392#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
11fdf7f2
TL
393 TEST_DIFFERENCE(case_recursive_boxes_85, 4, 4.0, 7, 3.75, 9);
394#endif
395
396 TEST_DIFFERENCE(case_recursive_boxes_86, 1, 1.5, 2, 1.5, 3);
397 TEST_DIFFERENCE(case_recursive_boxes_87, 4, 2.0, 4, 2.5, 8);
398 TEST_DIFFERENCE(case_recursive_boxes_88, 3, 4.75, 5, 6.75, 4);
399
92f5a8d4 400 // Output of A can be 0 or 1 polygons (with a very small area)
20effc67 401 TEST_DIFFERENCE(case_precision_m1, optional(), expectation_limits(0.0, 5.0e-7), 1, 57.0, count_set(1, 2));
92f5a8d4 402 // Output of A can be 1 or 2 polygons (one with a very small area)
20effc67 403 TEST_DIFFERENCE(case_precision_m2, count_set(1, 2), 1.0, 1, 57.75, count_set(2, 3));
92f5a8d4 404
b32b8144 405 {
1e59de90
TL
406 ut_settings settings;
407 settings.sym_difference = BG_IF_RESCALED(true, BG_IF_TEST_FAILURES);
b32b8144
FG
408 test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_21965285_b",
409 mysql_21965285_b[0],
410 mysql_21965285_b[1],
411 2, -1, 183.71376870369406,
412 2, -1, 131.21376870369406,
1e59de90 413 settings);
b32b8144
FG
414 }
415
92f5a8d4 416 TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31,
20effc67
TL
417 optional(), optional_sliver(1e-6),
418 3, 152.064185, count_set(3, 4));
7c673cae
FG
419}
420
421
422template <typename P>
423void test_all()
424{
425 typedef bg::model::ring<P> ring;
426 typedef bg::model::polygon<P> polygon;
427 typedef bg::model::multi_polygon<polygon> multi_polygon;
428 test_areal<ring, polygon, multi_polygon>();
429}
430
431
432// Test cases for integer coordinates / ccw / open
b32b8144
FG
433template <typename Polygon, typename MultiPolygon>
434void test_specific_areal()
7c673cae 435{
7c673cae
FG
436 {
437 // Spikes in a-b and b-a, failure in symmetric difference
7c673cae
FG
438 ut_settings settings;
439 settings.sym_difference = false;
20effc67 440 settings.set_test_validity(false);
7c673cae 441
92f5a8d4 442 TEST_DIFFERENCE_WITH(0, 1, ticket_11674,
1e59de90
TL
443 count_set(2, 3, 4),
444 expectation_limits(9105196, 9105705),
445 6,
446 expectation_limits(119059, 119757), ignore_count());
7c673cae
FG
447 }
448
449 {
b32b8144
FG
450 // Ticket 12751 (Volker)
451 // Spikes in a-b and b-a, failure in symmetric difference
452
7c673cae 453 ut_settings settings;
b32b8144 454 settings.remove_spikes = true;
7c673cae 455
92f5a8d4 456 TEST_DIFFERENCE_WITH(0, 1, ticket_12751, 1,
20effc67
TL
457 expectation_limits(2781964, 2782115), 1,
458 expectation_limits(597.0, 598.0), 2);
b32b8144 459
92f5a8d4 460 TEST_DIFFERENCE_WITH(2, 3, ticket_12751,
1e59de90
TL
461 2, expectation_limits(2537404, 2538306),
462 2, expectation_limits(294736, 295353),
92f5a8d4 463 3);
b32b8144 464 }
7c673cae 465
b32b8144
FG
466 {
467 // Ticket 12752 (Volker)
468 // Spikes in a-b and b-a, failure in symmetric difference
469 ut_settings settings;
470 settings.remove_spikes = true;
471 settings.sym_difference = false;
1e59de90 472 settings.set_test_validity(false);
92f5a8d4 473 TEST_DIFFERENCE_WITH(0, 1, ticket_12752,
1e59de90
TL
474 count_set(2, 3), expectation_limits(2775740, 2776693),
475 3, expectation_limits(7710, 7903),
92f5a8d4 476 2);
b32b8144
FG
477 }
478
479 {
92f5a8d4 480 const std::string a_min_b =
1e59de90
TL
481 test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10661",
482 ticket_10661[0], ticket_10661[1],
483 2, -1, expectation_limits(1441855, 1442081),
484 2, -1, expectation_limits(13167454, 13182415),
485 count_set(3, 4));
b32b8144
FG
486
487 test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10661_2",
7c673cae 488 a_min_b, ticket_10661[2],
1e59de90
TL
489 1, 8, 825640.5,
490 1, 10, expectation_limits(27226148, 27842812),
491 count_set(1, 2));
7c673cae 492 }
b32b8144
FG
493
494 {
495 ut_settings settings;
496 settings.sym_difference = false;
92f5a8d4 497
1e59de90
TL
498 TEST_DIFFERENCE_WITH(0, 1, ticket_9942, 4,
499 expectation_limits(7427727, 7428549), 5,
500 expectation_limits(184653, 184687), 5);
501 TEST_DIFFERENCE_WITH(0, 1, ticket_9942a, 1,
502 expectation_limits(412676, 413469), 2,
503 expectation_limits(76779, 77038), 4);
b32b8144
FG
504 }
505}
506
507template <typename Point, bool ClockWise, bool Closed>
508void test_specific()
509{
510 typedef bg::model::polygon<Point, ClockWise, Closed> polygon;
511 typedef bg::model::multi_polygon<polygon> multi_polygon;
512 test_specific_areal<polygon, multi_polygon>();
7c673cae
FG
513}
514
515
516int test_main(int, char* [])
517{
92f5a8d4
TL
518 BoostGeometryWriteTestConfiguration();
519 test_all<bg::model::d2::point_xy<default_test_type> >();
7c673cae
FG
520
521 test_specific<bg::model::d2::point_xy<int>, false, false>();
522
523#if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
524 test_all<bg::model::d2::point_xy<float> >();
7c673cae
FG
525#endif
526
20effc67
TL
527#if defined(BOOST_GEOMETRY_TEST_FAILURES)
528 // Not yet fully tested for float.
529 // The difference algorithm can generate (additional) slivers
1e59de90 530 BoostGeometryWriteExpectedFailures(24, 11, 21, 7);
7c673cae
FG
531#endif
532
533 return 0;
534}