]>
Commit | Line | Data |
---|---|---|
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 | ||
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) \ | |
33 | { ut_settings ignore_validity; ignore_validity.test_validity = false; \ | |
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 | ||
47 | template <typename Ring, typename Polygon, typename MultiPolygon> | |
48 | void test_areal() | |
49 | { | |
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], | |
90 | 3, 13, 1.65, 3, 17, 6.15); | |
91 | ||
92 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi", | |
93 | case_77_multi[0], case_77_multi[1], | |
94 | 6, 31, 7.0, | |
95 | 5, 36, 13.0, | |
96 | 5, 43, 7.0 + 13.0); | |
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 | ||
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 | |
107 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
108 | TEST_DIFFERENCE(case_126_multi, 4, 16.0, 5, 27.0, 9); | |
109 | #else | |
110 | TEST_DIFFERENCE_IGNORE(case_126_multi, 3, 16.0, 4, 27.0, 7); | |
111 | #endif | |
112 | ||
113 | { | |
114 | ut_settings settings; | |
115 | ||
116 | #if !defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
117 | settings.sym_difference = false; | |
118 | #endif | |
119 | ||
120 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi", | |
121 | case_108_multi[0], case_108_multi[1], | |
122 | 7, 32, 5.5, | |
123 | 4, 28, 9.75, | |
124 | 7, 45, 15.25, | |
125 | settings); | |
126 | } | |
127 | ||
128 | // Ticket on GGL list 2011/10/25 | |
129 | // to mix polygon/multipolygon in call to difference | |
130 | test_one<Polygon, Polygon, Polygon>("ggl_list_20111025_vd_pp", | |
131 | ggl_list_20111025_vd[0], ggl_list_20111025_vd[1], | |
132 | 1, 4, 8.0, 1, 4, 12.5); | |
133 | test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_pm", | |
134 | ggl_list_20111025_vd[0], ggl_list_20111025_vd[3], | |
135 | 1, 4, 8.0, 1, 4, 12.5); | |
136 | test_one<Polygon, MultiPolygon, Polygon>("ggl_list_20111025_vd_mp", | |
137 | ggl_list_20111025_vd[2], ggl_list_20111025_vd[1], | |
138 | 1, 4, 8.0, 1, 4, 12.5); | |
139 | test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20111025_vd_mm", | |
140 | ggl_list_20111025_vd[2], ggl_list_20111025_vd[3], | |
141 | 1, 4, 8.0, 1, 4, 12.5); | |
142 | ||
143 | test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_2", | |
144 | ggl_list_20111025_vd_2[0], ggl_list_20111025_vd_2[1], | |
145 | 1, 7, 10.0, 2, 10, 6.0); | |
146 | ||
147 | test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a", | |
148 | ggl_list_20120915_h2[0], ggl_list_20120915_h2[1], | |
149 | 2, 13, 17.0, 0, 0, 0.0); | |
150 | test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_b", | |
151 | ggl_list_20120915_h2[0], ggl_list_20120915_h2[2], | |
152 | 2, 13, 17.0, 0, 0, 0.0); | |
153 | ||
154 | { | |
155 | ut_settings settings; | |
156 | settings.percentage = 0.001; | |
157 | ||
158 | // This testcase is actually different for all combinations | |
159 | #if (!defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS)) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
160 | settings.test_validity = false; | |
161 | #endif | |
162 | ||
163 | #if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS) || defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
164 | TEST_DIFFERENCE_WITH(0, 1, ggl_list_20120221_volker, 2, 7962.66, 2, 2775258.93, 4); | |
165 | #else | |
166 | TEST_DIFFERENCE_WITH(0, 1, ggl_list_20120221_volker, 2, 7962.66, 1, 2775258.93, 3); | |
167 | #endif | |
168 | } | |
169 | ||
170 | #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
171 | test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081", | |
172 | ticket_9081[0], ticket_9081[1], | |
173 | 2, 28, 0.0907392476356186, 4, 25, 0.126018011439877, | |
174 | 4, 42, 0.0907392476356186 + 0.126018011439877, | |
175 | tolerance(0.001)); | |
176 | ||
177 | // POSTGIS areas: 3.75893745345145, 2.5810000723917e-15 | |
178 | TEST_DIFFERENCE_IGNORE(bug_21155501, 1, 3.758937, 0, 0.0, 1); | |
179 | #endif | |
180 | ||
181 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
182 | // The result is valid but wrong, version b includes nearly all area | |
183 | // which was original between all the self-touching polygons | |
184 | // TEST_DIFFERENCE(ticket_12503, 46, 920.625, 41, 497.125, 10); | |
185 | #else | |
186 | TEST_DIFFERENCE_IGNORE(ticket_12503, 45, 920.625, 3, 7.625, 48); | |
187 | #endif | |
188 | ||
189 | // Areas and #clips correspond with POSTGIS (except sym case) | |
190 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi", | |
191 | case_101_multi[0], case_101_multi[1], | |
192 | 5, 23, 4.75, | |
193 | 5, 40, 12.75, | |
194 | 5, 48, 4.75 + 12.75); | |
195 | ||
196 | // Areas and #clips correspond with POSTGIS | |
197 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi", | |
198 | case_102_multi[0], case_102_multi[1], | |
199 | 2, 8, 0.75, | |
200 | 6, 25, 3.75, | |
201 | 6, 27, 0.75 + 3.75); | |
202 | ||
203 | // Areas and #clips correspond with POSTGIS | |
204 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi", | |
205 | case_107_multi[0], case_107_multi[1], | |
206 | 2, 11, 2.25, | |
207 | 3, 14, 3.0, | |
208 | 4, 21, 5.25); | |
209 | ||
210 | TEST_DIFFERENCE(case_133_multi, 3, 16.0, 2, 8.0, 5); | |
211 | TEST_DIFFERENCE(case_134_multi, 3, 16.0, 2, 8.0, 5); | |
212 | TEST_DIFFERENCE(case_135_multi, 2, 2.0, 2, 13.0, 2); | |
213 | TEST_DIFFERENCE(case_136_multi, 2, 2.0, 3, 13.5, 3); | |
214 | TEST_DIFFERENCE(case_137_multi, 2, 2.5, 2, 13.0, 2); | |
215 | TEST_DIFFERENCE(case_138_multi, 5, 16.6, 3, 8.225, 8); | |
216 | TEST_DIFFERENCE(case_139_multi, 4, 16.328125, 3, 8.078125, 7); | |
217 | TEST_DIFFERENCE(case_140_multi, 4, 16.328125, 3, 8.078125, 7); | |
218 | TEST_DIFFERENCE(case_141_multi, 5, 15.5, 5, 10.0, 10); | |
219 | ||
220 | // Areas correspond with POSTGIS, | |
221 | // #clips in PostGIS is 11,11,5 but should most probably be be 12,12,6 | |
222 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
223 | TEST_DIFFERENCE(case_recursive_boxes_1, 12, 26.0, 12, 24.0, 6); | |
224 | #else | |
225 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_1, 11, 26.0, 12, 24.0, 5); | |
226 | #endif | |
227 | ||
228 | // Areas and #clips correspond with POSTGIS | |
229 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_2", | |
230 | case_recursive_boxes_2[0], case_recursive_boxes_2[1], | |
231 | 3, 15, 3.0, | |
232 | 7, 33, 7.0, | |
233 | 10, 48, 10.0); | |
234 | ||
235 | // Areas and #clips by POSTGIS (except sym case) | |
236 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3", | |
237 | case_recursive_boxes_3[0], case_recursive_boxes_3[1], | |
238 | 24, -1, 21.5, | |
239 | 25, -1, 22.5, | |
240 | 37, -1, 44.0); | |
241 | ||
242 | // 4, input is not valid | |
243 | ||
244 | // Should have 16,12 clips in a,b | |
245 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
246 | TEST_DIFFERENCE(case_recursive_boxes_5, 16, 22.0, 12, 27.0, 10); | |
247 | #else | |
248 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_5, 15, 22.0, 11, 27.0, 8); | |
249 | #endif | |
250 | ||
251 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
252 | TEST_DIFFERENCE(case_recursive_boxes_6, 7, 3.5, 3, 1.5, 9); | |
253 | #else | |
254 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_6, 6, 3.5, 3, 1.5, 8); | |
255 | #endif | |
256 | ||
257 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7", | |
258 | case_recursive_boxes_7[0], case_recursive_boxes_7[1], | |
259 | 3, 15, 2.75, | |
260 | 4, 19, 2.75, | |
261 | 3, 22, 5.5); | |
262 | ||
263 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_8", | |
264 | case_recursive_boxes_8[0], case_recursive_boxes_8[1], | |
265 | 2, -1, 2.50, | |
266 | 4, -1, 5.75, | |
267 | 4, -1, 8.25); | |
268 | ||
269 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_9", | |
270 | case_recursive_boxes_9[0], case_recursive_boxes_9[1], | |
271 | 3, -1, 1.5, | |
272 | 4, -1, 2.5, | |
273 | 6, -1, 4.0); | |
274 | ||
275 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_10", | |
276 | case_recursive_boxes_10[0], case_recursive_boxes_10[1], | |
277 | 2, -1, 1.25, | |
278 | 2, -1, 0.75, | |
279 | 4, -1, 2.00); | |
280 | ||
281 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_11", | |
282 | case_recursive_boxes_11[0], case_recursive_boxes_11[1], | |
283 | 3, -1, 2.5, | |
284 | 3, -1, 4.5, | |
285 | 3, -1, 7.0); | |
286 | ||
287 | TEST_DIFFERENCE(case_recursive_boxes_12, 4, 2.75, 3, 2.75, 6); | |
288 | TEST_DIFFERENCE(case_recursive_boxes_13, 4, 4.75, 3, 5.5, 3); | |
289 | TEST_DIFFERENCE(case_recursive_boxes_14, 3, 2.0, 4, 2.5, 5); | |
290 | TEST_DIFFERENCE(case_recursive_boxes_15, 3, 3.0, 2, 2.5, 3); | |
291 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
292 | TEST_DIFFERENCE(case_recursive_boxes_16, 8, 6.5, 3, 5.5, 9); | |
293 | TEST_DIFFERENCE(case_recursive_boxes_17, 10, 7.75, 7, 5.5, 13); | |
294 | #else | |
295 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_16, 7, 6.5, 3, 5.5, 8); | |
296 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_17, 9, 7.75, 6, 5.5, 11); | |
297 | #endif | |
298 | TEST_DIFFERENCE(case_recursive_boxes_18, 2, 1.0, 1, 1.5, 3); | |
299 | TEST_DIFFERENCE(case_recursive_boxes_19, 2, 1.0, 2, 1.5, 3); | |
300 | TEST_DIFFERENCE(case_recursive_boxes_20, 2, 1.0, 0, 0.0, 2); | |
301 | ||
302 | TEST_DIFFERENCE(case_recursive_boxes_21, 2, 1.0, 1, 1.0, 1); | |
303 | TEST_DIFFERENCE(case_recursive_boxes_22, 2, 1.25, 2, 2.0, 2); | |
304 | TEST_DIFFERENCE(case_recursive_boxes_23, 2, 0.75, 1, 0.5, 3); | |
305 | TEST_DIFFERENCE(case_recursive_boxes_24, 3, 2.5, 2, 2.0, 5); | |
306 | TEST_DIFFERENCE(case_recursive_boxes_25, 2, 2.5, 3, 2.5, 2); | |
307 | TEST_DIFFERENCE(case_recursive_boxes_26, 2, 1.5, 3, 2.0, 4); | |
308 | TEST_DIFFERENCE(case_recursive_boxes_27, 1, 1.5, 3, 2.5, 3); | |
309 | TEST_DIFFERENCE(case_recursive_boxes_28, 3, 2.5, 2, 3.0, 4); | |
310 | TEST_DIFFERENCE(case_recursive_boxes_29, 5, 7.25, 5, 4.5, 5); | |
311 | TEST_DIFFERENCE(case_recursive_boxes_30, 6, 4.25, 3, 7.25, 7); | |
312 | ||
313 | TEST_DIFFERENCE(case_recursive_boxes_31, 2, 2.0, 1, 0.5, 2); | |
314 | TEST_DIFFERENCE(case_recursive_boxes_32, 2, 2.75, 2, 1.25, 2); | |
315 | TEST_DIFFERENCE(case_recursive_boxes_33, 4, 3.0, 3, 6.0, 4); | |
316 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
317 | TEST_DIFFERENCE(case_recursive_boxes_34, 7, 7.25, 1, 0.5, 8); | |
318 | #else | |
319 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_34, 5, 7.25, 1, 0.5, 6); | |
320 | #endif | |
321 | TEST_DIFFERENCE(case_recursive_boxes_35, 5, 1.75, 5, 2.75, 10); | |
322 | TEST_DIFFERENCE(case_recursive_boxes_36, 2, 1.0, 2, 1.5, 3); | |
323 | TEST_DIFFERENCE(case_recursive_boxes_37, 3, 2.5, 2, 4.25, 2); | |
324 | TEST_DIFFERENCE(case_recursive_boxes_38, 5, 7.75, 4, 3.5, 3); | |
325 | TEST_DIFFERENCE(case_recursive_boxes_39, 3, 6.0, 3, 3.0, 4); | |
326 | TEST_DIFFERENCE(case_recursive_boxes_40, 11, 14.0, 9, 13.0, 11); | |
327 | ||
328 | TEST_DIFFERENCE(case_recursive_boxes_41, 1, 0.5, 1, 0.5, 2); | |
329 | #ifndef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
330 | // 42.a Fails with self-turns | |
331 | TEST_DIFFERENCE(case_recursive_boxes_42, 1, 1.0, 4, 4.0, 5); | |
332 | #endif | |
333 | TEST_DIFFERENCE(case_recursive_boxes_43, 1, 0.5, 3, 2.0, 4); | |
334 | TEST_DIFFERENCE(case_recursive_boxes_44, 3, 5.0, 0, 0.0, 3); | |
335 | TEST_DIFFERENCE(case_recursive_boxes_45, 6, 20.0, 7, 20.0, 3); | |
336 | TEST_DIFFERENCE(case_recursive_boxes_46, 4, 14.0, 5, 12.0, 5); | |
337 | TEST_DIFFERENCE(case_recursive_boxes_47, 4, 10.0, 7, 11.0, 1); | |
338 | TEST_DIFFERENCE(case_recursive_boxes_48, 0, 0.0, 1, 9.0, 1); | |
339 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
340 | TEST_DIFFERENCE(case_recursive_boxes_49, 10, 22.0, 10, 17.0, 11); | |
341 | #else | |
342 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_49, 9, 22.0, 10, 17.0, 10); | |
343 | #endif | |
344 | TEST_DIFFERENCE(case_recursive_boxes_50, 14, 21.0, 16, 21.0, 14); | |
345 | TEST_DIFFERENCE(case_recursive_boxes_51, 14, 25.0, 12, 31.0, 7); | |
346 | ||
347 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
348 | TEST_DIFFERENCE(case_recursive_boxes_52, 13, 30.0, 15, 25.0, 8); | |
349 | #else | |
350 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_52, 13, 30.0, 15, 25.0, 8); | |
351 | #endif | |
352 | TEST_DIFFERENCE(case_recursive_boxes_53, 6, 3.5, 4, 1.5, 9); | |
353 | TEST_DIFFERENCE(case_recursive_boxes_54, 6, 6.5, 8, 6.0, 7); | |
354 | TEST_DIFFERENCE(case_recursive_boxes_55, 4, 5.5, 6, 7.75, 4); | |
355 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
356 | TEST_DIFFERENCE(case_recursive_boxes_56, 4, 4.5, 5, 2.75, 6); | |
357 | #else | |
358 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_56, 4, 4.5, 5, 2.75, 6); | |
359 | #endif | |
360 | TEST_DIFFERENCE(case_recursive_boxes_57, 5, 3.75, 9, 6.5, 10); | |
361 | TEST_DIFFERENCE(case_recursive_boxes_58, 4, 2.25, 6, 3.75, 7); | |
362 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
363 | TEST_DIFFERENCE(case_recursive_boxes_59, 8, 6.5, 7, 7.0, 12); | |
364 | #else | |
365 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_59, 8, 6.5, 6, 7.0, 11); | |
366 | #endif | |
367 | ||
368 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
369 | TEST_DIFFERENCE(case_recursive_boxes_60, 6, 5.25, 7, 5.25, 11); | |
370 | #else | |
371 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_60, 5, 5.25, 5, 5.25, 8); | |
372 | #endif | |
373 | TEST_DIFFERENCE(case_recursive_boxes_61, 2, 1.5, 6, 2.0, 7); | |
374 | #if defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS) | |
375 | // Misses one triangle | |
376 | TEST_DIFFERENCE(case_recursive_boxes_62, 5, 5.0, 11, 5.75, 12); | |
377 | #endif | |
378 | ||
379 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
380 | TEST_DIFFERENCE(case_recursive_boxes_63, 9, 10.5, 5, 27.75, 4); | |
381 | #else | |
382 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_63, 6, 10.5, 5, 27.75, 2); | |
383 | #endif | |
384 | ||
385 | TEST_DIFFERENCE(case_recursive_boxes_64, 6, 2.75, 7, 4.5, 11); | |
386 | ||
387 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
388 | TEST_DIFFERENCE(case_recursive_boxes_65, 6, 4.25, 7, 3.0, 13); | |
389 | #else | |
390 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_65, 4, 4.25, 7, 3.0, 11); | |
391 | #endif | |
392 | ||
393 | TEST_DIFFERENCE(case_recursive_boxes_66, 5, 4.75, 7, 4.0, 9); | |
394 | TEST_DIFFERENCE(case_recursive_boxes_67, 7, 6.25, 9, 6.0, 10); | |
395 | TEST_DIFFERENCE(case_recursive_boxes_68, 10, 6.5, 9, 6.5, 7); | |
396 | TEST_DIFFERENCE(case_recursive_boxes_69, 5, 6.25, 5, 6.75, 8); | |
397 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
398 | TEST_DIFFERENCE(case_recursive_boxes_70, 5, 2.0, 8, 4.5, 11); | |
399 | #else | |
400 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_70, 5, 2.0, 6, 4.5, 9); | |
401 | #endif | |
402 | ||
403 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
404 | TEST_DIFFERENCE(case_recursive_boxes_71, 7, 8.25, 7, 5.75, 8); | |
405 | #else | |
406 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_71, 6, 8.25, 7, 5.75, 7); | |
407 | #endif | |
408 | ||
409 | TEST_DIFFERENCE(case_recursive_boxes_72, 6, 6.5, 7, 4.0, 10); | |
410 | TEST_DIFFERENCE(case_recursive_boxes_73, 4, 1.75, 5, 4.0, 8); | |
411 | ||
412 | TEST_DIFFERENCE(case_recursive_boxes_74, 3, 3.00, 3, 1.5, 5); | |
413 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
414 | TEST_DIFFERENCE(case_recursive_boxes_75, 7, 4.5, 4, 2.0, 11); | |
415 | #else | |
416 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_75, 5, 4.5, 4, 2.0, 9); | |
417 | #endif | |
418 | ||
419 | TEST_DIFFERENCE(case_recursive_boxes_76, 7, 3.75, 4, 2.5, 9); | |
420 | TEST_DIFFERENCE(case_recursive_boxes_77, 4, 3.75, 7, 6.25, 8); | |
421 | TEST_DIFFERENCE(case_recursive_boxes_78, 11, 5.5, 8, 4.5, 14); | |
422 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
423 | TEST_DIFFERENCE(case_recursive_boxes_79, 2, 1.25, 6, 4.5, 8); | |
424 | #else | |
425 | TEST_DIFFERENCE_IGNORE(case_recursive_boxes_79, 2, 1.25, 5, 4.5, 7); | |
426 | #endif | |
427 | ||
428 | #if defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
429 | TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, 2); | |
430 | #else | |
431 | // one polygon is divided into two, for same reason as union creates a small | |
432 | // interior ring there | |
433 | TEST_DIFFERENCE(case_recursive_boxes_80, 1, 0.5, 2, 0.75, 3); | |
434 | #endif | |
435 | ||
436 | { | |
437 | ut_settings sym_settings; | |
438 | #if defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
439 | sym_settings.sym_difference = false; | |
440 | #endif | |
441 | test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_21965285_b", | |
442 | mysql_21965285_b[0], | |
443 | mysql_21965285_b[1], | |
444 | 2, -1, 183.71376870369406, | |
445 | 2, -1, 131.21376870369406, | |
446 | sym_settings); | |
447 | } | |
448 | ||
449 | #if defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS) && ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) | |
450 | TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 1, 4.30697514e-7, 3, 152.0642, 4); | |
451 | #else | |
452 | // Misses one turn which is actually weird because there are no self-turns involved | |
453 | TEST_DIFFERENCE(mysql_regression_1_65_2017_08_31, 0, 0, 3, 152.0642, 3); | |
454 | #endif | |
455 | } | |
456 | ||
457 | ||
458 | template <typename P> | |
459 | void test_all() | |
460 | { | |
461 | typedef bg::model::ring<P> ring; | |
462 | typedef bg::model::polygon<P> polygon; | |
463 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
464 | test_areal<ring, polygon, multi_polygon>(); | |
465 | } | |
466 | ||
467 | ||
468 | // Test cases for integer coordinates / ccw / open | |
469 | template <typename Polygon, typename MultiPolygon> | |
470 | void test_specific_areal() | |
471 | { | |
472 | { | |
473 | // Spikes in a-b and b-a, failure in symmetric difference | |
474 | ||
475 | ut_settings settings; | |
476 | #if !defined(BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS) | |
477 | settings.sym_difference = false; | |
478 | settings.test_validity = false; | |
479 | #endif | |
480 | ||
481 | TEST_DIFFERENCE_WITH(0, 1, ticket_11674, 3, 9105781.5, 5, 119059.5, -1); | |
482 | } | |
483 | ||
484 | { | |
485 | // Ticket 12751 (Volker) | |
486 | // Spikes in a-b and b-a, failure in symmetric difference | |
487 | ||
488 | ut_settings settings; | |
489 | settings.remove_spikes = true; | |
490 | #if ! defined(BOOST_GEOMETRY_INCLUDE_SELF_TURNS) | |
491 | settings.sym_difference = false; | |
492 | settings.test_validity = false; | |
493 | #endif | |
494 | ||
495 | std::string a_min_b = | |
496 | TEST_DIFFERENCE_WITH(0, 1, ticket_12751, 1, 2781965.0, 1, 597.0, 2); | |
497 | ||
498 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
499 | TEST_DIFFERENCE_WITH(2, 3, ticket_12751, 2, 2537992.5, 2, 294963.5, 3); | |
500 | #else | |
501 | ||
502 | // Testing consistency of testcase itself | |
503 | boost::ignore_unused(a_min_b); | |
504 | // BOOST_CHECK_EQUAL(a_min_b, ticket_12751[2]); | |
505 | ||
506 | TEST_DIFFERENCE_WITH(2, 3, ticket_12751, 1, 2537992.5, 2, 294963.5, 3); | |
507 | #endif | |
508 | ||
509 | } | |
510 | ||
511 | { | |
512 | // Ticket 12752 (Volker) | |
513 | // Spikes in a-b and b-a, failure in symmetric difference | |
514 | ut_settings settings; | |
515 | settings.remove_spikes = true; | |
516 | settings.sym_difference = false; | |
517 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
518 | TEST_DIFFERENCE_WITH(0, 1, ticket_12752, 3, 2776692.0, 3, 7893.0, 2); | |
519 | #else | |
520 | // If self-intersections are not tested, result is not valid | |
521 | settings.test_validity = false; | |
522 | TEST_DIFFERENCE_WITH(0, 1, ticket_12752, 3, 2776692.0, 3, 7893.0, 6); | |
523 | #endif | |
524 | } | |
525 | ||
526 | { | |
527 | std::string a_min_b = | |
528 | TEST_DIFFERENCE(ticket_10661, 2, 1441632.5, 2, 13167454, 4); | |
529 | ||
530 | test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_10661_2", | |
531 | a_min_b, ticket_10661[2], | |
532 | 1, 8, 825192.0, | |
533 | 1, 10, 27226370.5, | |
534 | 1, -1, 825192.0 + 27226370.5); | |
535 | } | |
536 | ||
537 | { | |
538 | ut_settings settings; | |
539 | settings.sym_difference = false; | |
540 | #ifndef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
541 | settings.test_validity = false; | |
542 | TEST_DIFFERENCE_WITH(0, 1, ticket_9942, 3, 7427491.5, 4, 131506, 4); | |
543 | #else | |
544 | TEST_DIFFERENCE_WITH(0, 1, ticket_9942, 4, 7427727.5, 4, 131506, 4); | |
545 | #endif | |
546 | TEST_DIFFERENCE_WITH(0, 1, ticket_9942a, 2, 412676.5, 2, 76779.5, 4); | |
547 | } | |
548 | } | |
549 | ||
550 | template <typename Point, bool ClockWise, bool Closed> | |
551 | void test_specific() | |
552 | { | |
553 | typedef bg::model::polygon<Point, ClockWise, Closed> polygon; | |
554 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
555 | test_specific_areal<polygon, multi_polygon>(); | |
556 | } | |
557 | ||
558 | ||
559 | int test_main(int, char* []) | |
560 | { | |
561 | test_all<bg::model::d2::point_xy<double > >(); | |
562 | ||
563 | test_specific<bg::model::d2::point_xy<int>, false, false>(); | |
564 | ||
565 | #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) | |
566 | test_all<bg::model::d2::point_xy<float> >(); | |
567 | ||
568 | #if defined(HAVE_TTMATH) | |
569 | std::cout << "Testing TTMATH" << std::endl; | |
570 | test_all<bg::model::d2::point_xy<ttmath_big> >(); | |
571 | #endif | |
572 | ||
573 | #endif | |
574 | ||
575 | return 0; | |
576 | } |