union.cpp 25 KB

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