relate_linear_areal_sph.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. // Boost.Geometry
  2. // Unit Test
  3. // Copyright (c) 2016, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #include "test_relate.hpp"
  9. template <typename P>
  10. void test_linestring_polygon()
  11. {
  12. typedef bg::model::linestring<P> ls;
  13. typedef bg::model::polygon<P> poly;
  14. typedef bg::model::ring<P> ring;
  15. // LS disjoint
  16. test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
  17. test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
  18. // II BB
  19. test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212");
  20. test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FFF0F212");
  21. test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1FF0FF212");
  22. // IE
  23. test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1FF0212");
  24. // IE IB0
  25. test_geometry<ls, poly>("LINESTRING(11 1,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "FF1F00212");
  26. // IE IB1
  27. test_geometry<ls, poly>("LINESTRING(11 1,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
  28. test_geometry<ls, poly>("LINESTRING(11 1,10 10,0 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
  29. test_geometry<ls, poly>("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
  30. test_geometry<ls, poly>("LINESTRING(0 -1,1 0,2 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
  31. // IE IB0 II
  32. test_geometry<ls, poly>("LINESTRING(11 1,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
  33. // IE IB0 lring
  34. test_geometry<ls, poly>("LINESTRING(11 1,10 5,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F01FFF212");
  35. // IE IB1 lring
  36. test_geometry<ls, poly>("LINESTRING(11 1,10 5,10 10,11 5,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11FFF212");
  37. // IB1 II
  38. test_geometry<ls, poly>("LINESTRING(0 0,5 0,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
  39. // BI0 II IB1
  40. test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212");
  41. // IB1 II IB1
  42. test_geometry<ls, poly>("LINESTRING(1 0,2 0,3 1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11FF0F212");
  43. // IB1 IE IB1
  44. test_geometry<ls, poly>("LINESTRING(1 0,2 0,3 -1,4 0,5 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F0F212");
  45. // II IB1
  46. test_geometry<ls, poly>("LINESTRING(5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
  47. // IB1 II
  48. test_geometry<ls, poly>("LINESTRING(10 10,10 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "11F00F212");
  49. // IE IB1
  50. test_geometry<ls, poly>("LINESTRING(15 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
  51. // IB1 IE
  52. test_geometry<ls, poly>("LINESTRING(10 10,10 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "F11F00212");
  53. // duplicated points
  54. {
  55. // II IB0 IE
  56. test_geometry<ls, poly>("LINESTRING(5 5,10 5,15 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
  57. test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,10 5,10 5,10 5,15 10,15 10,15 10)",
  58. "POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
  59. "1010F0212");
  60. test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,10 0,10 0,10 0,15 10,15 10,15 10)",
  61. "POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
  62. "1010F0212");
  63. // IE IB0 II
  64. test_geometry<ls, poly>("LINESTRING(15 10,15 10,15 10,10 5,10 5,10 5,5 5,5 5,5 5)",
  65. "POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
  66. "1010F0212");
  67. test_geometry<ls, poly>("LINESTRING(15 10,15 10,15 10,10 0,10 0,10 0,5 5,5 5,5 5)",
  68. "POLYGON((0 0,0 0,0 0,0 10,0 10,0 10,10 10,10 10,10 10,10 0,10 0,10 0,0 0,0 0,0 0))",
  69. "1010F0212");
  70. // TEST
  71. //test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
  72. test_geometry<ls, poly>("LINESTRING(5 5,5 5,5 5,15 5,15 5,15 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", "1010F0212");
  73. }
  74. // non-simple polygon with hole
  75. test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
  76. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  77. "10F0FF212");
  78. test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
  79. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  80. "F1FF0F212");
  81. test_geometry<ls, poly>("LINESTRING(2 8,10 5,2 2)",
  82. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  83. "F1FF0F212");
  84. test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 2)",
  85. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  86. "F1FF0F212");
  87. test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 8)",
  88. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  89. "F1FF0F212");
  90. // non-simple polygon with hole, linear ring
  91. test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
  92. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  93. "10FFFF212");
  94. test_geometry<ls, poly>("LINESTRING(10 5,10 9,11 5,10 1,10 5)",
  95. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  96. "F11FFF212");
  97. test_geometry<ls, poly>("LINESTRING(11 5,10 1,10 5,10 9,11 5)",
  98. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  99. "F11FFF212");
  100. // non-simple polygon with self-touching holes
  101. test_geometry<ls, poly>("LINESTRING(7 1,8 5,7 9)",
  102. "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
  103. "10F0FF212");
  104. test_geometry<ls, poly>("LINESTRING(8 2,8 5,8 8)",
  105. "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
  106. "F1FF0F212");
  107. test_geometry<ls, poly>("LINESTRING(2 8,8 5,2 2)",
  108. "POLYGON((0 0,0 10,10 10,10 0,0 0),(8 1,9 1,9 9,8 9,8 1),(2 2,8 5,2 8,2 2))",
  109. "F1FF0F212");
  110. // non-simple polygon self-touching
  111. test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
  112. "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
  113. "10F0FF212");
  114. test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
  115. "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
  116. "F1FF0F212");
  117. test_geometry<ls, poly>("LINESTRING(2 8,10 5,2 2)",
  118. "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
  119. "F1FF0F212");
  120. // non-simple polygon self-touching, linear ring
  121. test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
  122. "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
  123. "10FFFF212");
  124. test_geometry<ls, poly>("LINESTRING(10 5,10 9,11 5,10 1,10 5)",
  125. "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
  126. "F11FFF212");
  127. test_geometry<ls, poly>("LINESTRING(11 5,10 1,10 5,10 9,11 5)",
  128. "POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
  129. "F11FFF212");
  130. // polygons with some ring equal to the linestring
  131. test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
  132. "POLYGON((0 0,0 10,10 10,10 0,0 0))",
  133. "F1FFFF2F2");
  134. test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
  135. "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2))",
  136. "F1FFFF212");
  137. test_geometry<ls, poly>("LINESTRING(2 2,5 5,2 8,2 2)",
  138. "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2))",
  139. "F1FFFF212");
  140. // self-IP going on the boundary then into the exterior and to the boundary again
  141. test_geometry<ls, poly>("LINESTRING(2 10.023946271183535,5 10.037423045910710,5 15,6 15,5 10.037423045910710,8 10.023946271183535)",
  142. "POLYGON((0 0,0 10,10 10,10 0,0 0))",
  143. "F11F0F212");
  144. // self-IP going on the boundary then into the interior and to the boundary again
  145. test_geometry<ls, poly>("LINESTRING(2 10.023946271183535,5 10.037423045910710,5 5,6 5,5 10.037423045910710,8 10.023946271183535)",
  146. "POLYGON((0 0,0 10,10 10,10 0,0 0))",
  147. "11FF0F212");
  148. // self-IP with a hole -> B to I to B to E
  149. test_geometry<ls, poly>("LINESTRING(0 0,3 3)", "POLYGON((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0))",
  150. "FF1F00212");
  151. }
  152. template <typename P>
  153. void test_linestring_multi_polygon()
  154. {
  155. typedef bg::model::linestring<P> ls;
  156. typedef bg::model::polygon<P> poly;
  157. typedef bg::model::multi_polygon<poly> mpoly;
  158. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
  159. "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
  160. "F1FF0F212");
  161. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
  162. "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0)))",
  163. "F1FF0F212");
  164. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
  165. "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
  166. "F1FF0F212");
  167. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
  168. "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0)))",
  169. "11F00F212");
  170. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 2)",
  171. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
  172. "F1FF0F212");
  173. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,2 8)",
  174. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
  175. "F1FF0F212");
  176. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,3 3)",
  177. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
  178. "F1FF0F212");
  179. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,3 7)",
  180. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
  181. "F1FF0F212");
  182. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,5 5)",
  183. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)),((10 5,3 3,3 7,10 5)))",
  184. "11F00F212");
  185. test_geometry<ls, mpoly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
  186. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 20,20 0)))",
  187. "F1FFFF212");
  188. // degenerated points
  189. test_geometry<ls, mpoly>("LINESTRING(5 5,10 10,10 10,10 10,15 15)",
  190. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((10 10,10 20,20 20,20 10,10 10)))",
  191. "10F0FF212");
  192. // self-IP polygon with a hole and second polygon with a hole -> B to I to B to B to I to B to E
  193. test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
  194. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)),((0 0,2 8,8 8,8 2,0 0),(0 0,7 3,7 7,3 7,0 0)))",
  195. "FF1F00212");
  196. // self-IP polygon with a hole and second polygon -> B to I to B to B to I
  197. test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
  198. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)),((0 0,2 8,8 8,8 2,0 0)))",
  199. "1FF00F212");
  200. test_geometry<ls, mpoly>("LINESTRING(0 0,3 3)",
  201. "MULTIPOLYGON(((0 0,2 8,8 8,8 2,0 0)),((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))",
  202. "1FF00F212");
  203. // MySQL report 18.12.2014 (https://svn.boost.org/trac/boost/ticket/10887)
  204. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 2)",
  205. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  206. "10F0FF212");
  207. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 5.0190018174896416)",
  208. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  209. "10F00F212");
  210. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
  211. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  212. "1FF00F212");
  213. // MySQL report 18.12.2014 - extended
  214. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
  215. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
  216. "1FF00F212");
  217. test_geometry<ls, mpoly>("LINESTRING(0 0,5 0)",
  218. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)),((5 0,7 1,7 -1,5 0)))",
  219. "FF1F00212");
  220. // 22.01.2015
  221. test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,10 0)",
  222. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  223. "11F00F212");
  224. test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,0 10)",
  225. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  226. "11F00F212");
  227. // extended
  228. test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,2 1)",
  229. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  230. "10F0FF212");
  231. test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,5 -5)",
  232. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  233. "1010F0212");
  234. test_geometry<ls, mpoly>("LINESTRING(5 5,0 0,5 -5,5 1)",
  235. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  236. "1010FF212");
  237. test_geometry<ls, mpoly>("LINESTRING(-5 5,0 0,5 -5)",
  238. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  239. "F01FF0212");
  240. }
  241. template <typename P>
  242. void test_multi_linestring_polygon()
  243. {
  244. typedef bg::model::linestring<P> ls;
  245. typedef bg::model::multi_linestring<ls> mls;
  246. typedef bg::model::polygon<P> poly;
  247. typedef bg::model::ring<P> ring;
  248. typedef typename bg::coordinate_type<P>::type coord_t;
  249. test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
  250. "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
  251. "1F10F0212");
  252. test_geometry<mls, poly>("MULTILINESTRING((10 0, 18 12),(2 2,2 1))",
  253. "POLYGON((5 0,0 -5,-5 0,0 5,5 0))",
  254. "1F10F0212");
  255. if ( BOOST_GEOMETRY_CONDITION((
  256. boost::is_same<coord_t, double>::value )) )
  257. {
  258. // assertion failure in 1.57
  259. test_geometry<mls, poly>("MULTILINESTRING((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
  260. "POLYGON((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
  261. "*********");
  262. test_geometry<mls, poly>("MULTILINESTRING((-2.333333333333333 -8.6666666666666661,-4.3253012048192767 -8.168674698795181,-4.1194968553459113 -7.6100628930817606,-2.8823529411764706 -7.7647058823529411,-2.882352941176471 -7.7647058823529411,-2.263157894736842 -8.6315789473684212,-2.333333333333333 -8.6666666666666661))",
  263. "POLYGON((-0.59322033898305082 -8.0508474576271194,-2.882352941176471 -7.7647058823529411,-2.8823529411764706 -7.7647058823529411,-3.7361111111111112 -6.5694444444444446,-3.4404145077720205 -5.766839378238342,-4.1864406779661012 -3.6779661016949152,-7.5252525252525251 -5.5858585858585865,-7.5862068965517242 -5.1896551724137936,-4.47887323943662 -2.859154929577465,-4.5789473684210531 -2.5789473684210527,-3 -1,-2.9310344827586206 -0.86206896551724144,-3.1764705882352944 -0.70588235294117663,-4.7401960784313726 -2.1274509803921577,-5.3255813953488369 -0.48837209302325502,-4.7872340425531918 0.31914893617021284,-5.8571428571428577 1.0000000000000007,-5.3255813953488369 -0.48837209302325502,-5.9473684210526319 -1.4210526315789465,-8 2,-7.7333333333333334 2.1939393939393939,-8.8294573643410867 2.891472868217055,-8.8556701030927822 3.061855670103093,-7.5999999999999996 3.6000000000000001,-7.7999999999999998 3.7999999999999998,-7.75 3.7916666666666665,-7.5471698113207548 3.6226415094339623,-7.3200000000000003 3.7200000000000002,-3.473684210526315 3.0789473684210527,-3.2549019607843133 3.2156862745098036,-2.9999999999999982 3.1428571428571423,-3.1733333333333325 3.2666666666666666,-2.9180327868852456 3.4262295081967209,-2.8723404255319145 3.1063829787234041,-2.1111111111111112 2.8888888888888888,-2.1428571428571428 2.8571428571428572,-1.8433734939759043 2.8072289156626509,-1.8396226415094346 2.8113207547169816,-1.6486486486486487 2.756756756756757,-1.76510067114094 2.8926174496644301,-0.53846153846153855 4.2307692307692308,1.8148148148148147 5.4074074074074074,1.588235294117647 2.2352941176470589,1.819672131147541 2.1967213114754101,2 4,2 2.1666666666666665,2.3538461538461544 2.1076923076923078,2 1.6875000000000004,2 -2,1.2173913043478262 -3.8260869565217392,1.7375886524822697 1.3758865248226959,1.5073170731707317 1.1024390243902444,1.1428571428571428 -4,-0.59322033898305082 -8.0508474576271194),(1.666666666666667 1.5999999999999988,1.5675675675675675 1.8378378378378377,1.4374999999999991 1.8750000000000002,1.0487804878048776 2.3414634146341466,0.46666666666666712 2.6060606060606055,0.086956521739131043 2.2608695652173911,1.4374999999999991 1.8750000000000002,1.666666666666667 1.5999999999999988))",
  264. "*********");
  265. }
  266. // 21.01.2015
  267. test_geometry<mls, poly>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
  268. "POLYGON((5 5,5 15,15 15,15 5,5 5))",
  269. "101000212");
  270. test_geometry<mls, poly>("MULTILINESTRING((15 15,6 6),(0 0, 7 7))",
  271. "POLYGON((5 5,5 15,15 15,15 5,5 5))",
  272. "101000212");
  273. // extended
  274. test_geometry<mls, ring>("MULTILINESTRING((15 15,6 6),(4 14,6 15.986412732589057))",
  275. "POLYGON((5 5,5 15,15 15,15 5,5 5))",
  276. "101000212");
  277. // 23.01.2015
  278. test_geometry<mls, poly>("MULTILINESTRING((4 10.035925377760330, 3 10.031432746397092, 10 6),(5 0, 7 5, 9 10.013467818052765))",
  279. "POLYGON((0 0,0 10,10 10,10 0,5 5,0 0))",
  280. "111F00212");
  281. // 23.01.2015
  282. test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
  283. "POLYGON((0 0,0 10,10 10,10 0,0 0))",
  284. "10FF0F212");
  285. }
  286. template <typename P>
  287. void test_multi_linestring_multi_polygon()
  288. {
  289. typedef bg::model::linestring<P> ls;
  290. typedef bg::model::polygon<P> poly;
  291. typedef bg::model::multi_linestring<ls> mls;
  292. typedef bg::model::multi_polygon<poly> mpoly;
  293. // polygons with some ring equal to the linestrings
  294. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
  295. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
  296. "F11FFF2F2");
  297. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
  298. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
  299. "F1FFFF2F2");
  300. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0))",
  301. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
  302. "F1FFFF2F2");
  303. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
  304. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
  305. "F11FFF2F2");
  306. // disjoint
  307. test_geometry<mls, mpoly>("MULTILINESTRING((20 20,30 30),(30 30,40 40))",
  308. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
  309. "FF1FF0212");
  310. test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 5),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
  311. "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
  312. "F1FF0F212");
  313. test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 5),(5 5,5 0),(0 5,0 0,5 0),(10 10,10 5,5 5,5 10,10 10))",
  314. "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
  315. "F1FFFF212");
  316. test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 0),(5 5,5 0),(10 10,10 5,5 5,5 10,10 10))",
  317. "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)),((5 5,10 1,10 0,5 5)))",
  318. "11FF0F212");
  319. // MySQL report 18.12.2014 - extended
  320. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
  321. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  322. "10FFFF212");
  323. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 0,0 -1,5 0))",
  324. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  325. "F01FFF212");
  326. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(6 -2,5 0))",
  327. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  328. "10F0FF212");
  329. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 -1,5 0))",
  330. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  331. "F01FF0212");
  332. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,5 0),(5 -2,5 0))",
  333. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  334. "1010F0212");
  335. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,5 0),(0 0,5 0))",
  336. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  337. "1010F0212");
  338. // 22.01.2015 - extended
  339. test_geometry<mls, mpoly>("MULTILINESTRING((10 10,0 10),(5 5,0 0,10 0))",
  340. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  341. "11F00F212");
  342. test_geometry<mls, mpoly>("MULTILINESTRING((5 5,0 0,5 -5),(0 0,9 1))",
  343. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  344. "101000212");
  345. test_geometry<mls, mpoly>("MULTILINESTRING((5 -5,0 0,5 5),(0 0,5 -1))",
  346. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))",
  347. "101000212");
  348. }
  349. template <typename P>
  350. void test_all()
  351. {
  352. test_linestring_polygon<P>();
  353. test_linestring_multi_polygon<P>();
  354. test_multi_linestring_polygon<P>();
  355. test_multi_linestring_multi_polygon<P>();
  356. }
  357. int test_main( int , char* [] )
  358. {
  359. typedef bg::cs::spherical_equatorial<bg::degree> cs_t;
  360. test_all<bg::model::point<float, 2, cs_t> >();
  361. test_all<bg::model::point<double, 2, cs_t> >();
  362. #if defined(HAVE_TTMATH)
  363. test_all<bg::model::point<ttmath_big, 2, cs_t> >();
  364. #endif
  365. return 0;
  366. }