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