]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/set_operations/union/union.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / set_operations / union / union.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2016 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2016 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2016 Mateusz Loskot, London, UK.
7
8 // This file was modified by Oracle on 2016,2017.
9 // Modifications copyright (c) 2016-2017, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18
19 #include <iostream>
20 #include <string>
21
22 #include "test_union.hpp"
23 #include <algorithms/test_overlay.hpp>
24
25 #include <algorithms/overlay/overlay_cases.hpp>
26 #include <boost/geometry/geometries/point_xy.hpp>
27
28
29 #define TEST_UNION(caseid, clips, holes, points, area) \
30 (test_one<Polygon, Polygon, Polygon>) \
31 ( #caseid, caseid[0], caseid[1], clips, holes, points, area)
32
33 #define TEST_UNION_WITH(caseid, clips, holes, points, area) \
34 (test_one<Polygon, Polygon, Polygon>) \
35 ( #caseid, caseid[0], caseid[1], clips, holes, points, area, settings)
36
37 #define TEST_UNION_REV(caseid, clips, holes, points, area) \
38 (test_one<Polygon, Polygon, Polygon>) \
39 ( #caseid "_rev", caseid[1], caseid[0], clips, holes, points, area)
40
41
42 template <typename Ring, typename Polygon>
43 void test_areal()
44 {
45 typedef typename bg::coordinate_type<Polygon>::type ct;
46
47 ut_settings ignore_validity_for_float;
48 if (BOOST_GEOMETRY_CONDITION((boost::is_same<ct, float>::value)) )
49 {
50 ignore_validity_for_float.set_test_validity(false);
51 }
52
53 test_one<Polygon, Polygon, Polygon>("simplex_normal",
54 simplex_normal[0], simplex_normal[1],
55 1, 0, 13, 11.526367);
56
57 test_one<Polygon, Polygon, Polygon>("simplex_with_empty_1",
58 simplex_normal[0], polygon_empty,
59 1, 0, 4, 8.0);
60 test_one<Polygon, Polygon, Polygon>("simplex_with_empty_2",
61 polygon_empty, simplex_normal[0],
62 1, 0, 4, 8.0);
63
64 test_one<Polygon, Polygon, Polygon>("star_ring", example_star, example_ring,
65 1, 0, 23, 5.67017141);
66
67 // This sample was selected because of the border case.
68 test_one<Polygon, Polygon, Polygon>("star_poly", example_star, example_polygon,
69 1, 1, -1, 5.647949);
70
71 // Pseudo-box as Polygon
72 // (note, internally, the intersection points is different, so yes,
73 // it has to be tested)
74 test_one<Polygon, Polygon, Polygon>("box_poly3", "POLYGON((1.5 1.5 , 1.5 2.5 , 4.5 2.5 , 4.5 1.5 , 1.5 1.5))",
75 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
76 1, 1, 15, 5.93625);
77
78 test_one<Polygon, Polygon, Polygon>("first_within_second",
79 first_within_second[0], first_within_second[1],
80 1, 0, 5, 25.0);
81
82 test_one<Polygon, Polygon, Polygon>("second_within_first",
83 first_within_second[1], first_within_second[0],
84 1, 0, 5, 25.0);
85
86 test_one<Polygon, Polygon, Polygon>("first_within_hole_of_second",
87 first_within_hole_of_second[0], first_within_hole_of_second[1],
88 2, 1, 15, 17.0);
89
90 test_one<Polygon, Polygon, Polygon>("new_hole",
91 new_hole[0], new_hole[1],
92 1, 1, 14, 23.0);
93
94 test_one<Polygon, Polygon, Polygon>("side_side",
95 side_side[0], side_side[1], 1, 0, 7, 2.0);
96
97 test_one<Polygon, Polygon, Polygon>("identical",
98 identical[0], identical[1], 1, 0, 5, 1.0);
99
100 test_one<Polygon, Polygon, Polygon>("disjoint",
101 disjoint[0], disjoint[1], 2, 0, 10, 2.0);
102
103 test_one<Polygon, Polygon, Polygon>("intersect_holes_intersect",
104 intersect_holes_intersect[0], intersect_holes_intersect[1],
105 1, 1, 14, 39.75);
106
107 test_one<Polygon, Polygon, Polygon>("intersect_holes_intersect_and_disjoint",
108 intersect_holes_intersect_and_disjoint[0], intersect_holes_intersect_and_disjoint[1],
109 1, 1, 14, 39.75);
110
111 test_one<Polygon, Polygon, Polygon>("intersect_holes_intersect_and_touch",
112 intersect_holes_intersect_and_touch[0], intersect_holes_intersect_and_touch[1],
113 1, 1, 14, 39.75);
114
115 test_one<Polygon, Polygon, Polygon>("intersect_holes_new_ring",
116 intersect_holes_new_ring[0], intersect_holes_new_ring[1],
117 1, 2, 15, 253.8961);
118
119 test_one<Polygon, Polygon, Polygon>("intersect_holes_disjoint",
120 intersect_holes_disjoint[0],
121 intersect_holes_disjoint[1],
122 1, 0, 9, 40.0);
123
124 test_one<Polygon, Polygon, Polygon>("within_holes_disjoint",
125 within_holes_disjoint[0], within_holes_disjoint[1],
126 1, 0, 5, 49.0);
127
128 test_one<Polygon, Polygon, Polygon>("winded",
129 winded[0], winded[1],
130 1, 5, 30, 114.0);
131
132 test_one<Polygon, Polygon, Polygon>("two_bends",
133 two_bends[0], two_bends[1],
134 1, 0, 7, 40.0);
135
136 test_one<Polygon, Polygon, Polygon>("star_comb_15",
137 star_comb_15[0], star_comb_15[1],
138 1, 27, 204, 898.09693338);
139
140 test_one<Polygon, Polygon, Polygon>("equal_holes_disjoint",
141 equal_holes_disjoint[0], equal_holes_disjoint[1],
142 1, 1, 10, 81 - 3 * 7);
143
144 test_one<Polygon, Polygon, Polygon>("only_hole_intersections1",
145 only_hole_intersections[0], only_hole_intersections[1],
146 1, 2, 13, 190.9090909);
147 test_one<Polygon, Polygon, Polygon>("only_hole_intersections2",
148 only_hole_intersections[0], only_hole_intersections[2],
149 1, 2, 13, 190.9090909);
150
151 test_one<Polygon, Polygon, Polygon>("intersect_exterior_and_interiors_winded",
152 intersect_exterior_and_interiors_winded[0], intersect_exterior_and_interiors_winded[1],
153 1, 1, 26, 66.5333333);
154
155 test_one<Polygon, Polygon, Polygon>("crossed",
156 crossed[0], crossed[1],
157 1, 3, 17, 23.5); // Area from SQL Server - was somehow wrong before
158
159 test_one<Polygon, Polygon, Polygon>("fitting",
160 fitting[0], fitting[1],
161 1, 0, 5, 25);
162
163 test_one<Polygon, Polygon, Polygon>("distance_zero",
164 distance_zero[0], distance_zero[1],
165 1, 0, -1, 9.0098387);
166
167 test_one<Polygon, Polygon, Polygon>("wrapped_a",
168 wrapped[0], wrapped[1],
169 1, 1, 16, 16);
170 test_one<Polygon, Polygon, Polygon>("wrapped_b",
171 wrapped[0], wrapped[2],
172 1, 1, 16, 16);
173
174 test_one<Polygon, Polygon, Polygon>("9",
175 case_9[0], case_9[1], 2, 0, 8, 11);
176 test_one<Polygon, Polygon, Polygon>("22",
177 case_22[0], case_22[1], 2, 0, 8, 9.5);
178 test_one<Polygon, Polygon, Polygon>("25",
179 case_25[0], case_25[1], 2, 0, 8, 7);
180 test_one<Polygon, Polygon, Polygon>("26",
181 case_26[0], case_26[1], 2, 0, 9, 7.5);
182 test_one<Polygon, Polygon, Polygon>("31",
183 case_31[0], case_31[1], 2, 0, 8, 4.5);
184 test_one<Polygon, Polygon, Polygon>("32",
185 case_32[0], case_32[1], 2, 0, 8, 4.5);
186 test_one<Polygon, Polygon, Polygon>("33",
187 case_33[0], case_33[1], 2, 0, 8, 4.5);
188 test_one<Polygon, Polygon, Polygon>("36",
189 case_36[0], case_36[1], 1, 1, 10, 14.375);
190 test_one<Polygon, Polygon, Polygon>("40",
191 case_40[0], case_40[1], 2, 0, 18, 11);
192
193 // Test rings which should be generated by assemble
194 test_one<Polygon, Polygon, Polygon>("53_iet",
195 case_53[0], case_53[2], 1, 1, 16, 16);
196 test_one<Polygon, Polygon, Polygon>("58_iet",
197 case_58[0], case_58[2], 1, 3, 20, 12.16666);
198
199 test_one<Polygon, Polygon, Polygon>("59_iet",
200 case_59[0], case_59[2], 1, 1, 14, 17.20833);
201
202 test_one<Polygon, Polygon, Polygon>("80",
203 case_80[0], case_80[1], 2, 2, 18, 129.0);
204
205 test_one<Polygon, Polygon, Polygon>("81",
206 case_81[0], case_81[1], 1, 2, 15, 163.5);
207
208 test_one<Polygon, Polygon, Polygon>("82",
209 case_82[0], case_82[1], 1, 1, 21, 19.75);
210
211 test_one<Polygon, Polygon, Polygon>("83",
212 case_83[0], case_83[1], 1, 0, 7, 20.0);
213
214 test_one<Polygon, Polygon, Polygon>("90",
215 case_90[0], case_90[1], 1, 2, 17, 221.3688);
216
217 test_one<Polygon, Polygon, Polygon>("91",
218 case_91[0], case_91[1], 1, 1, 9, 147.5);
219
220 test_one<Polygon, Polygon, Polygon>("92",
221 case_92[0], case_92[1], 2, 0, 9, 175.0);
222
223 test_one<Polygon, Polygon, Polygon>("93",
224 case_93[0], case_93[1], 1, 2, 12, 172.9167);
225
226 test_one<Polygon, Polygon, Polygon>("94",
227 case_94[0], case_94[1], 2, 0, 12, 170.0);
228
229 // Has two separate but touching interior rings
230 test_one<Polygon, Polygon, Polygon>("95",
231 case_95[0], case_95[1], 1, 2, 15, 1320.0);
232
233 test_one<Polygon, Polygon, Polygon>("96",
234 case_96[0], case_96[1], 1, 1, 10, 1500.0);
235
236 test_one<Polygon, Polygon, Polygon>("97",
237 case_97[0], case_97[1], 1, 0, 10, 286.799);
238
239 test_one<Polygon, Polygon, Polygon>("98",
240 case_98[0], case_98[1], 1, 1, 14, 653.067);
241
242 test_one<Polygon, Polygon, Polygon>("99",
243 case_99[0], case_99[1], 1, 0, 5, 1600.0);
244
245 test_one<Polygon, Polygon, Polygon>("100",
246 case_100[0], case_100[1], 1, 1, 13, 19.125);
247
248 test_one<Polygon, Polygon, Polygon>("101",
249 case_101[0], case_101[1], 1, 0, 9, 21.0);
250
251 test_one<Polygon, Polygon, Polygon>("102",
252 case_102[0], case_102[1], 1, 1, 17, 8.75);
253
254 test_one<Polygon, Polygon, Polygon>("103",
255 case_103[0], case_103[1],
256 1, 0, 5, 1.0);
257 test_one<Polygon, Polygon, Polygon>("104",
258 case_104[0], case_104[1],
259 1, 0, 5, 100.0);
260
261 test_one<Polygon, Polygon, Polygon>("105",
262 case_105[0], case_105[1], 1, 0, 5, 100);
263
264 test_one<Polygon, Polygon, Polygon>("108",
265 case_108[0], case_108[1], 1, 0, 13, 5.0);
266
267 TEST_UNION(case_precision_1, 1, 0, -1, 22.0);
268 TEST_UNION(case_precision_2, 1, 0, -1, 22.0);
269 TEST_UNION(case_precision_3, 1, 0, -1, 22.0);
270 TEST_UNION(case_precision_4, 1, 0, -1, 22.0);
271 TEST_UNION(case_precision_5, 1, 0, -1, 22.0);
272 TEST_UNION(case_precision_6, 1, 0, -1, 71.0);
273 TEST_UNION(case_precision_7, 1, 0, -1, 22.0);
274 TEST_UNION(case_precision_8, 1, 1, -1, 73.0);
275 TEST_UNION(case_precision_9, 1, 1, -1, 73.0);
276 TEST_UNION(case_precision_10, 1, 1, -1, 73.0);
277 TEST_UNION(case_precision_11, 1, 1, -1, 73.0);
278 TEST_UNION(case_precision_12, 1, 0, -1, 14.0);
279 TEST_UNION(case_precision_13, 1, 0, -1, 14.0);
280 TEST_UNION(case_precision_14, 1, 0, -1, 22.0);
281 TEST_UNION(case_precision_15, 1, 1, -1, 73.0);
282 TEST_UNION(case_precision_16, 1, 1, -1, 73.0);
283 TEST_UNION(case_precision_17, 1, 1, -1, 73.0);
284 TEST_UNION(case_precision_18, 1, 1, -1, 73.0);
285 TEST_UNION(case_precision_19, 1, 1, -1, 73.0);
286 TEST_UNION(case_precision_20, 1, 0, -1, 22.0);
287 TEST_UNION(case_precision_21, 1, 0, -1, 22.0);
288 TEST_UNION(case_precision_22, 1, 1, -1, 73.0);
289 TEST_UNION(case_precision_23, 1, 1, -1, 73.0);
290 TEST_UNION(case_precision_24, 1, 0, -1, 22.0);
291 TEST_UNION(case_precision_25, 1, 0, -1, 22.0);
292 TEST_UNION(case_precision_26, 1, 1, -1, 73.0);
293
294 TEST_UNION_REV(case_precision_1, 1, 0, -1, 22.0);
295 TEST_UNION_REV(case_precision_2, 1, 0, -1, 22.0);
296 TEST_UNION_REV(case_precision_3, 1, 0, -1, 22.0);
297 TEST_UNION_REV(case_precision_4, 1, 0, -1, 22.0);
298 TEST_UNION_REV(case_precision_5, 1, 0, -1, 22.0);
299 TEST_UNION_REV(case_precision_6, 1, 0, -1, 71.0);
300 TEST_UNION_REV(case_precision_7, 1, 0, -1, 22.0);
301 TEST_UNION_REV(case_precision_8, 1, 1, -1, 73.0);
302 TEST_UNION_REV(case_precision_9, 1, 1, -1, 73.0);
303 TEST_UNION_REV(case_precision_10, 1, 1, -1, 73.0);
304 TEST_UNION_REV(case_precision_11, 1, 1, -1, 73.0);
305 TEST_UNION_REV(case_precision_12, 1, 0, -1, 14.0);
306 TEST_UNION_REV(case_precision_13, 1, 0, -1, 14.0);
307 TEST_UNION_REV(case_precision_14, 1, 0, -1, 22.0);
308 TEST_UNION_REV(case_precision_15, 1, 1, -1, 73.0);
309 TEST_UNION_REV(case_precision_16, 1, 1, -1, 73.0);
310 TEST_UNION_REV(case_precision_17, 1, 1, -1, 73.0);
311 TEST_UNION_REV(case_precision_18, 1, 1, -1, 73.0);
312 TEST_UNION_REV(case_precision_19, 1, 1, -1, 73.0);
313 TEST_UNION_REV(case_precision_20, 1, 0, -1, 22.0);
314 TEST_UNION_REV(case_precision_21, 1, 0, -1, 22.0);
315 TEST_UNION_REV(case_precision_22, 1, 1, -1, 73.0);
316 TEST_UNION_REV(case_precision_23, 1, 1, -1, 73.0);
317 TEST_UNION_REV(case_precision_24, 1, 0, -1, 22.0);
318 TEST_UNION_REV(case_precision_25, 1, 0, -1, 22.0);
319 TEST_UNION_REV(case_precision_26, 1, 1, -1, 73.0);
320
321 /*
322 test_one<Polygon, Polygon, Polygon>(102,
323 simplex_normal[0], simplex_reversed[1],
324 1, 0, 7, X);
325
326 test_one<Polygon, Polygon, Polygon>(103,
327 simplex_reversed[0], simplex_normal[1],
328 1, 0, 7, 24.0);
329
330 test_one<Polygon, Polygon, Polygon>(104,
331 simplex_reversed[0], simplex_reversed[1],
332 1, 0, 7, 24.0);
333
334 test_one<Polygon, Polygon, Polygon>(100,
335 star_15, comb_15,
336 1, 10, 7, 24.0);
337 */
338
339 // test some other input/output types
340
341 // 1 input Ring
342 test_one<Polygon, Polygon, Ring>("identical_pr", identical[0], identical[1], 1, 0, 5, 1.0);
343 test_one<Polygon, Ring, Polygon>("identical_rp", identical[0], identical[1], 1, 0, 5, 1.0);
344
345 // 2 input rings
346 test_one<Polygon, Ring, Ring>("identical_rr", identical[0], identical[1], 1, 0, 5, 1.0);
347
348 // output is also Ring
349 test_one<Ring, Ring, Ring>("identical_rrr", identical[0], identical[1], 1, 0, 5, 1.0);
350
351 // "new hole", tested with Ring -> the newly formed hole will be omitted
352 test_one<Ring, Ring, Ring>("new_hole_discarded", new_hole[0], new_hole[1], 1, 0, 9, 24.0);
353
354 test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
355 ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
356 1, 1, 16, 80456.4904910401);
357
358 test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
359 ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
360 1, 1, 13, 20016.4);
361
362 test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
363 ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
364 1, 0, 8, 14729.07145);
365
366 test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
367 ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
368 1, 1, 15, 129904.197692871);
369
370 #if defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
371 // Either 1 or 2, depending if the intersection/turn point (eps.region) is missed
372 TEST_UNION(ggl_list_20110820_christophe, count_set(1, 2), 0, -1, 67.3550722317627);
373 #endif
374
375 {
376 // SQL Server gives: 313.360374193241
377 // PostGIS gives: 313.360364623393
378 // Without rescaling, it is creates an invalidity for double
379 ut_settings settings;
380 settings.set_test_validity(BG_IF_RESCALED(true, false));
381 TEST_UNION_WITH(isovist, 1, 0, -1, 313.36036462);
382 }
383
384 TEST_UNION(ggl_list_20190307_matthieu_1, 1, 1, -1, 0.83773);
385 TEST_UNION(ggl_list_20190307_matthieu_2, 1, 0, -1, 16.0);
386
387 // Ticket 5103 https://svn.boost.org/trac/boost/ticket/5103
388 // This ticket was actually reported for Boost.Polygon
389 // We check it for Boost.Geometry as well.
390 // SQL Server gives: 2515271331437.69
391 // PostGIS gives: 2515271327070.52
392 // Boost.Geometry gives: 2515271327070.5237746891 (ttmath)
393 // 2515271327070.5156 (double)
394 // 2515271320603.0000 (int)
395 // Note the int-test was tested outside of this unit test.
396 // It is in two points 0.37 off (logical for an int).
397 // Because of the width of the polygon (400000 meter)
398 // this causes a substantial difference.
399 TEST_UNION(ticket_5103, 1, 0, 25, 2515271327070.5);
400
401 TEST_UNION(ticket_8310a, 1, 0, -1, 10.5000019595);
402 TEST_UNION(ticket_8310b, 1, 0, -1, 10.5000019595);
403 TEST_UNION(ticket_8310c, 1, 0, -1, 10.5000019595);
404 TEST_UNION_REV(ticket_8310a, 1, 0, -1, 10.5000019595);
405 TEST_UNION_REV(ticket_8310b, 1, 0, -1, 10.5000019595);
406 TEST_UNION_REV(ticket_8310c, 1, 0, -1, 10.5000019595);
407
408 TEST_UNION(ticket_9081_15, 1, 0, -1, 0.0403425433);
409
410 TEST_UNION(ticket_9563, 1, 0, -1, 150.0);
411
412 TEST_UNION(ticket_9756, 1, 0, 10, expectation_limits(1289.0835, 1290.40625));
413
414 // Can generate one polygon, or two splitted, both is OK
415 TEST_UNION(ticket_10108_a, count_set(1, 2), 0, 8, 0.0435229);
416 TEST_UNION(ticket_10108_b, count_set(1, 2), 0, 10, 2424.3449);
417
418 TEST_UNION(ticket_10866, 1, 0, 14, 332760303.5);
419
420 TEST_UNION(ticket_11725, 1, 1, 10, 7.5);
421
422 #if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES)
423 // With rescaling an extra overlapping polygon is generated, which is wrong
424 TEST_UNION(issue_548, 1, 0, -1, 617382720000);
425 #endif
426
427 TEST_UNION(issue_566_a, 1, 0, -1, 214.3728);
428 TEST_UNION(issue_566_b, 1, 0, -1, 214.3728);
429 TEST_UNION_REV(issue_566_a, 1, 0, -1, 214.3728);
430 TEST_UNION_REV(issue_566_b, 1, 0, -1, 214.3728);
431
432 {
433 // Rescaling produces an invalid result
434 ut_settings settings;
435 settings.set_test_validity(BG_IF_RESCALED(false, true));
436 TEST_UNION_WITH(geos_1, 1, 0, -1, expectation_limits(3458.0, 3461.3203125));
437 }
438 TEST_UNION(geos_2, 1, 0, -1, expectation_limits(349.0625, 350.55102539));
439 TEST_UNION(geos_3, 1, 0, -1, 29391548.4998779);
440 TEST_UNION(geos_4, 1, 0, -1, 2304.4163115);
441
442 // Robustness issues, followed out buffer-robustness-tests, test them also reverse
443 {
444 // Area can vary depending on joining point of nearly parallel lines
445 ut_settings settings;
446 settings.percentage = 0.01;
447 test_one<Polygon, Polygon, Polygon>("buffer_rt_a", buffer_rt_a[0], buffer_rt_a[1],
448 1, 0, -1, 19.28, settings);
449 test_one<Polygon, Polygon, Polygon>("buffer_rt_a_rev", buffer_rt_a[1], buffer_rt_a[0],
450 1, 0, -1, 19.28, settings);
451 }
452 #if ! defined(BOOST_GEOMETRY_EXCLUDE)
453 test_one<Polygon, Polygon, Polygon>("buffer_rt_f", buffer_rt_f[0], buffer_rt_f[1],
454 1, 0, -1, 4.60853);
455 test_one<Polygon, Polygon, Polygon>("buffer_rt_f_rev", buffer_rt_f[1], buffer_rt_f[0],
456 1, 0, -1, 4.60853);
457 #endif
458 test_one<Polygon, Polygon, Polygon>("buffer_rt_g", buffer_rt_g[0], buffer_rt_g[1],
459 1, 0, -1, 16.571);
460 test_one<Polygon, Polygon, Polygon>("buffer_rt_g_rev", buffer_rt_g[1], buffer_rt_g[0],
461 1, 0, -1, 16.571);
462 test_one<Polygon, Polygon, Polygon>("buffer_rt_i", buffer_rt_i[0], buffer_rt_i[1],
463 1, 0, -1, 13.6569);
464 test_one<Polygon, Polygon, Polygon>("buffer_rt_i_rev", buffer_rt_i[1], buffer_rt_i[0],
465 1, 0, -1, 13.6569);
466 test_one<Polygon, Polygon, Polygon>("buffer_rt_j", buffer_rt_j[0], buffer_rt_j[1],
467 1, 0, -1, 16.5711);
468 test_one<Polygon, Polygon, Polygon>("buffer_rt_j_rev", buffer_rt_j[1], buffer_rt_j[0],
469 1, 0, -1, 16.5711);
470
471 test_one<Polygon, Polygon, Polygon>("buffer_rt_l", buffer_rt_l[0], buffer_rt_l[1],
472 1, 0, -1, 19.3995);
473 test_one<Polygon, Polygon, Polygon>("buffer_rt_l_rev", buffer_rt_l[1], buffer_rt_l[0],
474 1, 0, -1, 19.3995);
475
476 test_one<Polygon, Polygon, Polygon>("buffer_rt_m1", buffer_rt_m1[0], buffer_rt_m1[1],
477 1, 0, -1, 19.4852);
478 test_one<Polygon, Polygon, Polygon>("buffer_rt_m1_rev", buffer_rt_m1[1], buffer_rt_m1[0],
479 1, 0, -1, 19.4852);
480
481 test_one<Polygon, Polygon, Polygon>("buffer_rt_m2", buffer_rt_m2[0], buffer_rt_m2[1],
482 1, 0, -1, 21.4853);
483 test_one<Polygon, Polygon, Polygon>("buffer_rt_m2_rev", buffer_rt_m2[1], buffer_rt_m2[0],
484 1, 0, -1, 21.4853);
485
486 test_one<Polygon, Polygon, Polygon>("buffer_rt_q", buffer_rt_q[0], buffer_rt_q[1],
487 1, 0, -1, 18.5710);
488 test_one<Polygon, Polygon, Polygon>("buffer_rt_q_rev", buffer_rt_q[1], buffer_rt_q[0],
489 1, 0, -1, 18.5710);
490 test_one<Polygon, Polygon, Polygon>("buffer_rt_r", buffer_rt_r[0], buffer_rt_r[1],
491 1, 0, -1, 21.07612);
492 test_one<Polygon, Polygon, Polygon>("buffer_rt_r_rev", buffer_rt_r[1], buffer_rt_r[0],
493 1, 0, -1, 21.07612);
494 test_one<Polygon, Polygon, Polygon>("buffer_rt_t", buffer_rt_t[0], buffer_rt_t[1],
495 1, 0, -1, 15.6569);
496 test_one<Polygon, Polygon, Polygon>("buffer_rt_t_rev", buffer_rt_t[1], buffer_rt_t[0],
497 1, 0, -1, 15.6569, ignore_validity_for_float);
498
499 test_one<Polygon, Polygon, Polygon>("buffer_mp1", buffer_mp1[0], buffer_mp1[1],
500 1, 0, -1, 22.815);
501
502 test_one<Polygon, Polygon, Polygon>("buffer_mp2", buffer_mp2[0], buffer_mp2[1],
503 1, -1, 217, 36.752837);
504
505 test_one<Polygon, Polygon, Polygon>("mysql_21964079_1",
506 mysql_21964079_1[0], mysql_21964079_1[1],
507 2, 1, -1, 234.5);
508 test_one<Polygon, Polygon, Polygon>("mysql_21964079_2",
509 mysql_21964079_2[0], mysql_21964079_2[1],
510 2, 1, -1, 112.0);
511
512 test_one<Polygon, Polygon, Polygon>("mysql_23023665_1",
513 mysql_23023665_1[0], mysql_23023665_1[1],
514 2, 1, -1, 92.0 + 142.5);
515 test_one<Polygon, Polygon, Polygon>("mysql_23023665_2",
516 mysql_23023665_2[0], mysql_23023665_2[1],
517 2, 1, -1, 96.0 + 16.0);
518 test_one<Polygon, Polygon, Polygon>("mysql_23023665_3",
519 mysql_23023665_3[0], mysql_23023665_3[1],
520 2, 1, -1, 225.0 + 66.0);
521 test_one<Polygon, Polygon, Polygon>("mysql_21964049",
522 mysql_21964049[0], mysql_21964049[1],
523 1, 1, -1, 220.5);
524 }
525
526 template <typename P>
527 void test_all()
528 {
529 typedef bg::model::polygon<P> polygon;
530 typedef bg::model::ring<P> ring;
531 typedef bg::model::box<P> box;
532
533 test_areal<ring, polygon>();
534
535 #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
536 // Open
537 test_areal<bg::model::ring<P, true, false>, bg::model::polygon<P, true, false> >();
538
539 // Counter clockwise
540 test_areal<bg::model::ring<P, false>, bg::model::polygon<P, false> >();
541
542 // Counter clockwise and open
543 test_areal<bg::model::ring<P, false, false>, bg::model::polygon<P, false, false> >();
544 #endif
545
546 test_one<polygon, box, polygon>("box_ring", example_box, example_ring,
547 1, 1, 15, 6.38875);
548
549 test_one<polygon, box, polygon>("box_poly", example_box, example_polygon,
550 1, 3, 23, 6.30983);
551
552
553 test_one<polygon, box, polygon>("box_poly1", example_box,
554 "POLYGON((3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2))",
555 1, 1, 15, 6.38875);
556 test_one<polygon, box, polygon>("box_poly2", example_box,
557 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,5.3 2.5,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))",
558 1, 1, 15, 5.93625);
559
560 // 3: see areal
561
562 test_one<polygon, box, polygon>("box_poly4", example_box,
563 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
564 1, 1, 15, 4.651245);
565
566 test_one<polygon, box, polygon>("box_poly5", example_box,
567 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 2.5,4.5 2.3,5.0 2.3,5.0 2.1,4.5 2.1,4.5 1.9,4.0 1.9,4.5 1.2,4.9 0.8,2.9 0.7,2 1.3))",
568 1, 1, 21, 4.7191);
569
570 test_one<polygon, box, polygon>("box_poly6", example_box,
571 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 2.5,4.5 1.2,2.9 0.7,2 1.3))",
572 1, 1, 15, 4.2174);
573
574 test_one<polygon, box, polygon>("box_poly7", example_box,
575 "POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.0 3.0,5.0 2.0,2.9 0.7,2 1.3))",
576 1, 1, 17, 4.270554);
577
578 test_one<polygon, box, polygon>("box_poly8", "box(0 0, 3 3)",
579 "POLYGON((2 2, 1 4, 2 4, 3 3, 2 2))",
580 1, 0, 8, 10.25);
581 }
582
583
584 int test_main(int, char* [])
585 {
586 BoostGeometryWriteTestConfiguration();
587 test_all<bg::model::d2::point_xy<default_test_type>>();
588
589 #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
590 test_all<bg::model::d2::point_xy<float>>();
591 test_all<bg::model::d2::point_xy<long double>>();
592 test_all<bg::model::d2::point_xy<mp_test_type>>();
593 #endif
594
595 #if defined(BOOST_GEOMETRY_TEST_FAILURES)
596 BoostGeometryWriteExpectedFailures(3, 3, 1, 0);
597 #endif
598
599 return 0;
600 }