]>
Commit | Line | Data |
---|---|---|
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 | ||
35 | #define TEST_INTERSECTION_IGNORE(caseid, clips, points, area) \ | |
36 | { ut_settings ignore_validity; ignore_validity.test_validity = false; \ | |
37 | (test_one<Polygon, MultiPolygon, MultiPolygon>) \ | |
38 | ( #caseid, caseid[0], caseid[1], clips, points, area, ignore_validity); } | |
39 | ||
7c673cae FG |
40 | template <typename Ring, typename Polygon, typename MultiPolygon> |
41 | void test_areal() | |
42 | { | |
7c673cae FG |
43 | test_one<Polygon, MultiPolygon, MultiPolygon>("simplex_multi", |
44 | case_multi_simplex[0], case_multi_simplex[1], | |
45 | 2, 12, 6.42); | |
46 | ||
47 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_no_ip", | |
48 | case_multi_no_ip[0], case_multi_no_ip[1], | |
49 | 2, 8, 8.5); | |
50 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_2", | |
51 | case_multi_2[0], case_multi_2[1], | |
52 | 3, 12, 5.9); | |
53 | ||
54 | test_one<Polygon, MultiPolygon, Polygon>("simplex_multi_mp_p", | |
55 | case_multi_simplex[0], case_single_simplex, | |
56 | 2, 12, 6.42); | |
57 | ||
58 | test_one<Polygon, Ring, MultiPolygon>("simplex_multi_r_mp", | |
59 | case_single_simplex, case_multi_simplex[0], | |
60 | 2, 12, 6.42); | |
61 | test_one<Ring, MultiPolygon, Polygon>("simplex_multi_mp_r", | |
62 | case_multi_simplex[0], case_single_simplex, | |
63 | 2, 12, 6.42); | |
64 | ||
65 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_a", | |
66 | case_58_multi[0], case_58_multi[3], | |
67 | 3, 12, 0.666666667); | |
68 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b", | |
69 | case_58_multi[1], case_58_multi[2], | |
70 | 1, 19, 11.16666666667); | |
71 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b4", | |
72 | case_58_multi[4], case_58_multi[2], | |
73 | 1, 13, 12.66666666); | |
74 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b5", | |
75 | case_58_multi[5], case_58_multi[2], | |
76 | 1, 13, 13.25); | |
77 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b6", | |
78 | case_58_multi[6], case_58_multi[2], | |
79 | 1, 13, 13.25); | |
80 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_58_multi_b7", | |
81 | case_58_multi[7], case_58_multi[2], | |
82 | 1, 16, 12.5); | |
83 | ||
84 | // Constructed cases for multi/touch/equal/etc | |
85 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_61_multi", | |
86 | case_61_multi[0], case_61_multi[1], | |
87 | 0, 0, 0.0); | |
88 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_62_multi", | |
89 | case_62_multi[0], case_62_multi[1], | |
90 | 1, 5, 1.0); | |
91 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_63_multi", | |
92 | case_63_multi[0], case_63_multi[1], | |
93 | 1, 5, 1.0); | |
94 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_64_multi", | |
95 | case_64_multi[0], case_64_multi[1], | |
96 | 1, 5, 1.0); | |
97 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi", | |
98 | case_65_multi[0], case_65_multi[1], | |
99 | 1, 5, 1.0); | |
100 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi_inv_a", | |
101 | case_65_multi[0], case_65_multi[3], | |
102 | 0, 0, 0.0); | |
103 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi_inv_b", | |
104 | case_65_multi[1], case_65_multi[2], | |
105 | 2, 10, 3.0); | |
106 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_72_multi", | |
107 | case_72_multi[0], case_72_multi[1], | |
108 | 3, 14, 2.85); | |
109 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_72_multi_inv_b", | |
110 | case_72_multi[1], case_72_multi[2], | |
b32b8144 | 111 | 3, 16, 6.15); |
7c673cae FG |
112 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_77_multi", |
113 | case_77_multi[0], case_77_multi[1], | |
114 | 5, 33, 9.0); | |
115 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi", | |
116 | case_78_multi[0], case_78_multi[1], | |
b32b8144 | 117 | 1, 16, 22.0); |
7c673cae FG |
118 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi", |
119 | case_101_multi[0], case_101_multi[1], | |
120 | 4, 22, 4.75); | |
121 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi", | |
122 | case_102_multi[0], case_102_multi[1], | |
123 | 3, 26, 19.75); | |
124 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_102_multi_inv_b", | |
125 | case_102_multi[1], case_102_multi[2], | |
b32b8144 | 126 | 6, 25, 3.75); |
7c673cae FG |
127 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi", |
128 | case_107_multi[0], case_107_multi[1], | |
129 | 2, 10, 1.5); | |
130 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_107_multi_inv_b", | |
131 | case_107_multi[1], case_107_multi[2], | |
132 | 3, 13, 3.0); | |
133 | ||
134 | #ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS | |
b32b8144 FG |
135 | { |
136 | ut_settings ignore_validity; ignore_validity.test_validity = false; | |
137 | ||
138 | // One intersection is missing (by rescaling) | |
139 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_108_multi", | |
140 | case_108_multi[0], case_108_multi[1], | |
141 | 5, 33, 7.5, | |
142 | ignore_validity); | |
143 | } | |
7c673cae | 144 | #endif |
b32b8144 FG |
145 | |
146 | TEST_INTERSECTION(case_123_multi, 3, 13, 1.875); | |
147 | TEST_INTERSECTION(case_124_multi, 2, 13, 2.0625); | |
148 | TEST_INTERSECTION(case_125_multi, 3, 17, 2.1); | |
149 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
150 | TEST_INTERSECTION(case_126_multi, 5, 27, 9.0); | |
151 | #else | |
152 | TEST_INTERSECTION_IGNORE(case_126_multi, 3, 23, 9.0); | |
153 | #endif | |
154 | TEST_INTERSECTION(case_127_multi, 3, 19, 24.0); | |
155 | TEST_INTERSECTION(case_128_multi, 2, 26, 75.5); | |
156 | TEST_INTERSECTION(case_129_multi, 1, 20, 20.5); | |
157 | TEST_INTERSECTION(case_130_multi, 2, 30, 39.0); | |
158 | ||
159 | TEST_INTERSECTION(case_133_multi, 2, 23, 40.625); | |
160 | TEST_INTERSECTION(case_134_multi, 1, 23, 42.0); | |
161 | TEST_INTERSECTION(case_135_multi, 1, 17, 7.0); | |
162 | TEST_INTERSECTION(case_136_multi, 1, 17, 6.5); | |
163 | TEST_INTERSECTION(case_137_multi, 1, 17, 6.5); | |
164 | ||
165 | TEST_INTERSECTION(case_138_multi, 2, 23, 40.4); | |
166 | TEST_INTERSECTION(case_139_multi, 2, 23, 40.546875); | |
167 | TEST_INTERSECTION(case_140_multi, 2, 23, 40.546875); | |
168 | ||
169 | // TODO: isolated region with multiple connection should be handled | |
170 | // differently | |
171 | TEST_INTERSECTION_IGNORE(case_141_multi, 2, -1, 74.5); | |
172 | ||
173 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
174 | TEST_INTERSECTION(case_recursive_boxes_1, 10, 97, 47.0); | |
175 | #else | |
176 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_1, 8, 97, 47.0); | |
177 | #endif | |
178 | ||
7c673cae FG |
179 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_2", |
180 | case_recursive_boxes_2[0], case_recursive_boxes_2[1], | |
b32b8144 | 181 | 1, 50, 90.0); // Area from SQL Server |
7c673cae FG |
182 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3", |
183 | case_recursive_boxes_3[0], case_recursive_boxes_3[1], | |
184 | 19, 87, 12.5); // Area from SQL Server | |
185 | ||
b32b8144 FG |
186 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS |
187 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 13, 169, 67.0); | |
188 | #else | |
189 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_4, 8, 178, 67.0); | |
190 | #endif | |
7c673cae FG |
191 | |
192 | // Fixed by replacing handle_tangencies in less_by_segment_ratio sort order | |
b32b8144 | 193 | // Should contain 6 output polygons |
7c673cae FG |
194 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_6", |
195 | case_recursive_boxes_6[0], case_recursive_boxes_6[1], | |
196 | 6, 47, 19.0); | |
197 | ||
198 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_7", | |
199 | case_recursive_boxes_7[0], case_recursive_boxes_7[1], | |
200 | 2, 9, 1.5); | |
201 | ||
202 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_8", | |
203 | case_recursive_boxes_8[0], case_recursive_boxes_8[1], | |
204 | 3, 19, 3.75); | |
205 | ||
206 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_9", | |
207 | case_recursive_boxes_9[0], case_recursive_boxes_9[1], | |
208 | 5, 27, 4.25); | |
209 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_10", | |
210 | case_recursive_boxes_10[0], case_recursive_boxes_10[1], | |
211 | 2, 8, 0.75); | |
212 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_11", | |
213 | case_recursive_boxes_11[0], case_recursive_boxes_11[1], | |
214 | 2, 8, 1.0); | |
215 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_12", | |
216 | case_recursive_boxes_12[0], case_recursive_boxes_12[1], | |
217 | 1, 4, 0.5); | |
218 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_13", | |
219 | case_recursive_boxes_13[0], case_recursive_boxes_13[1], | |
220 | 0, 0, 0.0); | |
221 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_14", | |
222 | case_recursive_boxes_14[0], case_recursive_boxes_14[1], | |
223 | 0, 0, 0.0); | |
224 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_15", | |
225 | case_recursive_boxes_15[0], case_recursive_boxes_15[1], | |
226 | 1, 4, 0.5); | |
227 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_16", | |
228 | case_recursive_boxes_16[0], case_recursive_boxes_16[1], | |
229 | 9, 43, 10.0); | |
230 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_17", | |
231 | case_recursive_boxes_17[0], case_recursive_boxes_17[1], | |
232 | 7, -1, 7.75); | |
233 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_18", | |
234 | case_recursive_boxes_18[0], case_recursive_boxes_18[1], | |
235 | 0, 0, 0.0); | |
236 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_19", | |
237 | case_recursive_boxes_19[0], case_recursive_boxes_19[1], | |
238 | 0, 0, 0.0); | |
239 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_20", | |
240 | case_recursive_boxes_20[0], case_recursive_boxes_20[1], | |
241 | 2, 0, 1.0); | |
242 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_21", | |
243 | case_recursive_boxes_21[0], case_recursive_boxes_21[1], | |
244 | 1, 0, 0.5); | |
245 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_22", | |
246 | case_recursive_boxes_22[0], case_recursive_boxes_22[1], | |
247 | 0, 0, 0.0); | |
248 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_23", | |
249 | case_recursive_boxes_23[0], case_recursive_boxes_23[1], | |
250 | 1, 0, 0.5); | |
251 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_24", | |
252 | case_recursive_boxes_24[0], case_recursive_boxes_24[1], | |
253 | 1, 0, 0.5); | |
254 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_25", | |
255 | case_recursive_boxes_25[0], case_recursive_boxes_25[1], | |
256 | 1, 0, 0.5); | |
257 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_26", | |
258 | case_recursive_boxes_26[0], case_recursive_boxes_26[1], | |
259 | 1, 0, 2.5); | |
260 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_27", | |
261 | case_recursive_boxes_27[0], case_recursive_boxes_27[1], | |
262 | 1, 0, 0.5); | |
263 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_28", | |
264 | case_recursive_boxes_28[0], case_recursive_boxes_28[1], | |
265 | 2, 0, 1.0); | |
266 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_29", | |
267 | case_recursive_boxes_29[0], case_recursive_boxes_29[1], | |
268 | 5, 0, 3.75); | |
269 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_30", | |
270 | case_recursive_boxes_30[0], case_recursive_boxes_30[1], | |
271 | 4, 0, 6.0); | |
272 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_31", | |
273 | case_recursive_boxes_31[0], case_recursive_boxes_31[1], | |
274 | 2, 0, 2.5); | |
275 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_32", | |
276 | case_recursive_boxes_32[0], case_recursive_boxes_32[1], | |
277 | 2, 0, 1.75); | |
278 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_33", | |
279 | case_recursive_boxes_33[0], case_recursive_boxes_33[1], | |
280 | 3, 0, 2.0); | |
281 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_34", | |
282 | case_recursive_boxes_34[0], case_recursive_boxes_34[1], | |
b32b8144 | 283 | 2, 0, 17.25); |
7c673cae FG |
284 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_35", |
285 | case_recursive_boxes_35[0], case_recursive_boxes_35[1], | |
b32b8144 | 286 | 2, 0, 20.0); |
7c673cae FG |
287 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_36", |
288 | case_recursive_boxes_36[0], case_recursive_boxes_36[1], | |
289 | 1, 0, 0.5); | |
290 | test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_37", | |
291 | case_recursive_boxes_37[0], case_recursive_boxes_37[1], | |
292 | 2, 0, 1.0); | |
293 | ||
b32b8144 FG |
294 | TEST_INTERSECTION(case_recursive_boxes_39, 3, 0, 3.0); |
295 | TEST_INTERSECTION(case_recursive_boxes_40, 1, 0, 1.0); | |
296 | TEST_INTERSECTION(case_recursive_boxes_41, 1, 0, 23.5); | |
297 | TEST_INTERSECTION(case_recursive_boxes_42, 1, 29, 95.0); | |
298 | TEST_INTERSECTION(case_recursive_boxes_43, 2, 0, 22.5); | |
299 | TEST_INTERSECTION(case_recursive_boxes_44, 2, 0, 3.0); | |
300 | TEST_INTERSECTION(case_recursive_boxes_45, 7, 0, 12.0); | |
301 | TEST_INTERSECTION(case_recursive_boxes_46, 6, -1, 7.0); | |
302 | TEST_INTERSECTION(case_recursive_boxes_47, 1, 5, 1.0); | |
303 | TEST_INTERSECTION(case_recursive_boxes_48, 1, 5, 1.0); | |
304 | TEST_INTERSECTION(case_recursive_boxes_49, 7, 57, 20.0); | |
305 | TEST_INTERSECTION(case_recursive_boxes_50, 9, 71, 26.0); | |
306 | TEST_INTERSECTION(case_recursive_boxes_51, 14, 79, 19.0); | |
307 | TEST_INTERSECTION(case_recursive_boxes_52, 8, -1, 22.0); | |
308 | TEST_INTERSECTION(case_recursive_boxes_53, 1, -1, 19.75); | |
309 | TEST_INTERSECTION(case_recursive_boxes_54, 3, -1, 10.0); | |
310 | TEST_INTERSECTION(case_recursive_boxes_55, 5, -1, 2.25); | |
311 | TEST_INTERSECTION(case_recursive_boxes_56, 1, -1, 0.5); | |
312 | TEST_INTERSECTION(case_recursive_boxes_57, 10, -1, 9.5); | |
313 | TEST_INTERSECTION(case_recursive_boxes_58, 1, -1, 0.25); | |
314 | TEST_INTERSECTION(case_recursive_boxes_59, 8, -1, 8.25); | |
315 | TEST_INTERSECTION(case_recursive_boxes_60, 8, -1, 10.0); | |
316 | TEST_INTERSECTION(case_recursive_boxes_61, 2, -1, 20.0); | |
317 | TEST_INTERSECTION(case_recursive_boxes_62, 9, -1, 10.5); | |
318 | ||
319 | TEST_INTERSECTION(case_recursive_boxes_63, 11, -1, 5.75); | |
320 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
321 | TEST_INTERSECTION(case_recursive_boxes_64, 5, -1, 17.25); | |
322 | #else | |
323 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_64, 4, -1, 17.25); | |
324 | #endif | |
325 | TEST_INTERSECTION(case_recursive_boxes_65, 3, -1, 17.25); | |
326 | ||
327 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
328 | TEST_INTERSECTION(case_recursive_boxes_66, 4, -1, 16.0); | |
329 | #else | |
330 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_66, 2, -1, 16.0); | |
331 | #endif | |
332 | ||
333 | TEST_INTERSECTION(case_recursive_boxes_67, 5, -1, 2.5); | |
334 | TEST_INTERSECTION(case_recursive_boxes_68, 8, -1, 9.5); | |
335 | TEST_INTERSECTION(case_recursive_boxes_69, 6, -1, 3.25); | |
336 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
337 | TEST_INTERSECTION(case_recursive_boxes_70, 6, -1, 18.5); | |
338 | #else | |
339 | // Misses a necessary self-turn and therefore a ring | |
340 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_70, 3, -1, 18.0); | |
341 | #endif | |
342 | ||
343 | TEST_INTERSECTION(case_recursive_boxes_71, 3, -1, 1.75); | |
344 | TEST_INTERSECTION(case_recursive_boxes_72, 8, -1, 4.5); | |
345 | TEST_INTERSECTION(case_recursive_boxes_73, 3, -1, 18.5); | |
346 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS | |
347 | TEST_INTERSECTION(case_recursive_boxes_74, 3, -1, 20.25); | |
348 | #else | |
349 | TEST_INTERSECTION_IGNORE(case_recursive_boxes_74, 2, -1, 20.25); | |
350 | #endif | |
351 | ||
352 | TEST_INTERSECTION(case_recursive_boxes_75, 5, -1, 16.75); | |
353 | TEST_INTERSECTION(case_recursive_boxes_76, 2, -1, 18.25); | |
354 | TEST_INTERSECTION(case_recursive_boxes_77, 5, -1, 3.5); | |
355 | TEST_INTERSECTION(case_recursive_boxes_78, 9, -1, 8.0); | |
356 | TEST_INTERSECTION(case_recursive_boxes_79, 5, -1, 9.0); | |
357 | TEST_INTERSECTION(case_recursive_boxes_80, 1, -1, 0.25); | |
358 | ||
7c673cae FG |
359 | test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a", |
360 | ggl_list_20120915_h2[0], ggl_list_20120915_h2[1], | |
361 | 2, 10, 6.0); // Area from SQL Server | |
362 | test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_b", | |
363 | ggl_list_20120915_h2[0], ggl_list_20120915_h2[2], | |
364 | 2, 10, 6.0); // Area from SQL Server | |
365 | ||
366 | test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_9081", | |
367 | ticket_9081[0], ticket_9081[1], | |
368 | 2, 10, 0.0019812556); | |
369 | ||
370 | // qcc-arm reports 1.7791215549400884e-14 | |
371 | test_one<Polygon, MultiPolygon, MultiPolygon>("ticket_11018", | |
372 | ticket_11018[0], ticket_11018[1], | |
373 | 1, 4, | |
374 | #ifdef BOOST_GEOMETRY_NO_ROBUSTNESS | |
375 | 9.896437631745599e-09 | |
376 | #else | |
377 | 1.7791170511070893e-14, ut_settings(0.001) | |
378 | #endif | |
379 | ||
380 | ); | |
381 | ||
b32b8144 FG |
382 | TEST_INTERSECTION(ticket_12503, 2, 13, 17.375); |
383 | ||
7c673cae FG |
384 | test_one<Polygon, MultiPolygon, MultiPolygon>("mysql_23023665_7", |
385 | mysql_23023665_7[0], mysql_23023665_7[1], | |
386 | 2, 11, 9.80505786783); | |
387 | ||
b32b8144 FG |
388 | #ifdef BOOST_GEOMETRY_INCLUDE_SELF_TURNS |
389 | TEST_INTERSECTION(mysql_23023665_12, 2, 0, 11.812440191387557); | |
390 | #else | |
391 | TEST_INTERSECTION_IGNORE(mysql_23023665_12, 1, -1, 11.812440191387557); | |
392 | #endif | |
393 | ||
394 | TEST_INTERSECTION(mysql_regression_1_65_2017_08_31, 2, -1, 29.9022122); | |
7c673cae FG |
395 | } |
396 | ||
397 | template <typename Polygon, typename MultiPolygon, typename Box> | |
398 | void test_areal_clip() | |
399 | { | |
400 | static std::string const clip = "POLYGON((1 1,4 4))"; | |
401 | test_one<Polygon, Box, MultiPolygon>("simplex_multi_mp_b", clip, case_multi_simplex[0], | |
402 | 2, 11, 6.791666); | |
403 | test_one<Polygon, MultiPolygon, Box>("simplex_multi_b_mp", case_multi_simplex[0], clip, | |
404 | 2, 11, 6.791666); | |
405 | } | |
406 | ||
407 | template <typename LineString, typename MultiLineString, typename Box> | |
408 | void test_linear() | |
409 | { | |
410 | typedef typename bg::point_type<MultiLineString>::type point; | |
411 | test_one<point, MultiLineString, MultiLineString>("case_multi_ml_ml_1", | |
412 | "MULTILINESTRING((0 0,1 1))", "MULTILINESTRING((0 1,1 0))", | |
413 | 1, 1, 0.0); | |
414 | test_one<point, MultiLineString, MultiLineString>("case_multi_ml_ml_2", | |
415 | "MULTILINESTRING((0 0,1 1),(0.5 0,1.5 1))", "MULTILINESTRING((0 1,1 0),(0.5 1,1.5 0))", | |
416 | 4, 4, 0.0); | |
417 | ||
418 | test_one<point, LineString, MultiLineString>("case_multi_l_ml", | |
419 | "LINESTRING(0 0,1 1)", "MULTILINESTRING((0 1,1 0),(0.5 1,1.5 0))", | |
420 | 2, 2, 0.0); | |
421 | test_one<point, MultiLineString, LineString>("case_multi_ml_l", | |
422 | "MULTILINESTRING((0 1,1 0),(0.5 1,1.5 0))", "LINESTRING(0 0,1 1)", | |
423 | 2, 2, 0.0); | |
424 | ||
425 | test_one<LineString, MultiLineString, Box>("case_multi_ml_b", | |
426 | "MULTILINESTRING((0 0,3 3)(1 0,4 3))", "POLYGON((1 1,3 2))", | |
427 | 2, 4, 2.0 * std::sqrt(2.0)); | |
428 | test_one<LineString, Box, MultiLineString>("case_multi_b_ml", | |
429 | "POLYGON((1 1,3 2))", "MULTILINESTRING((0 0,3 3)(1 0,4 3))", | |
430 | 2, 4, 2.0 * std::sqrt(2.0)); | |
431 | } | |
432 | ||
433 | template <typename P> | |
434 | void test_point_output() | |
435 | { | |
436 | typedef bg::model::box<P> box; | |
437 | typedef bg::model::linestring<P> linestring; | |
438 | typedef bg::model::polygon<P> polygon; | |
439 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
440 | ||
441 | test_point_output<multi_polygon, multi_polygon>(case_multi_simplex[0], case_multi_simplex[1], 10); | |
442 | test_point_output<linestring, multi_polygon>("linestring(4 0,0 4)", case_multi_simplex[0], 4); | |
443 | test_point_output<box, multi_polygon>("box(3 0,4 6)", case_multi_simplex[0], 8); | |
444 | } | |
445 | ||
446 | template <typename MultiPolygon, typename MultiLineString> | |
447 | void test_areal_linear() | |
448 | { | |
449 | typedef typename boost::range_value<MultiPolygon>::type Polygon; | |
450 | typedef typename boost::range_value<MultiLineString>::type LineString; | |
451 | typedef typename bg::point_type<Polygon>::type Point; | |
452 | typedef bg::model::ring<Point> Ring; | |
453 | ||
454 | test_one_lp<LineString, MultiPolygon, LineString>("case_mp_ls_1", case_multi_simplex[0], "LINESTRING(2 0,2 5)", 2, 4, 3.70); | |
455 | 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); | |
456 | 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); | |
457 | 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); | |
458 | } | |
459 | ||
460 | template <typename P> | |
461 | void test_all() | |
462 | { | |
463 | typedef bg::model::ring<P> ring; | |
464 | typedef bg::model::polygon<P> polygon; | |
465 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
466 | test_areal<ring, polygon, multi_polygon>(); | |
467 | ||
468 | #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) | |
469 | ||
470 | typedef bg::model::ring<P, false> ring_ccw; | |
471 | typedef bg::model::polygon<P, false> polygon_ccw; | |
472 | typedef bg::model::multi_polygon<polygon_ccw> multi_polygon_ccw; | |
473 | test_areal<ring_ccw, polygon_ccw, multi_polygon_ccw>(); | |
474 | ||
475 | typedef bg::model::ring<P, true, false> ring_open; | |
476 | typedef bg::model::polygon<P, true, false> polygon_open; | |
477 | typedef bg::model::multi_polygon<polygon_open> multi_polygon_open; | |
478 | test_areal<ring_open, polygon_open, multi_polygon_open>(); | |
479 | ||
480 | typedef bg::model::ring<P, false, false> ring_open_ccw; | |
481 | typedef bg::model::polygon<P, false, false> polygon_open_ccw; | |
482 | typedef bg::model::multi_polygon<polygon_open_ccw> multi_polygon_open_ccw; | |
483 | test_areal<ring_open_ccw, polygon_open_ccw, multi_polygon_open_ccw>(); | |
484 | ||
485 | typedef bg::model::box<P> box; | |
486 | test_areal_clip<polygon, multi_polygon, box>(); | |
487 | test_areal_clip<polygon_ccw, multi_polygon_ccw, box>(); | |
488 | ||
489 | typedef bg::model::linestring<P> linestring; | |
490 | typedef bg::model::multi_linestring<linestring> multi_linestring; | |
491 | ||
492 | test_linear<linestring, multi_linestring, box>(); | |
493 | test_areal_linear<multi_polygon, multi_linestring>(); | |
494 | #endif | |
495 | ||
496 | test_point_output<P>(); | |
497 | // linear | |
498 | ||
499 | } | |
500 | ||
501 | ||
502 | int test_main(int, char* []) | |
503 | { | |
504 | test_all<bg::model::d2::point_xy<double> >(); | |
505 | ||
506 | #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) | |
507 | test_all<bg::model::d2::point_xy<float> >(); | |
508 | ||
509 | #if defined(HAVE_TTMATH) | |
510 | std::cout << "Testing TTMATH" << std::endl; | |
511 | test_all<bg::model::d2::point_xy<ttmath_big> >(); | |
512 | #endif | |
513 | ||
514 | #endif | |
515 | ||
516 | return 0; | |
517 | } |