get_turns_linear_linear_sph.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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_get_turns.hpp"
  9. #include <boost/geometry/geometries/geometries.hpp>
  10. template <typename T>
  11. void test_all()
  12. {
  13. typedef bg::model::point<T, 2, bg::cs::spherical_equatorial<bg::degree> > pt;
  14. typedef bg::model::linestring<pt> ls;
  15. typedef bg::model::multi_linestring<ls> mls;
  16. // NOTE: currently for the first endpoint of the Linestring on collinear segment
  17. // is_collinear flags are set to FALSE!
  18. // E.g. in the first test tii++, NOT tii==
  19. test_geometry<ls, ls>("LINESTRING(0 0,2 0)", "LINESTRING(0 0,2 0)", "tii++", "txx==");
  20. test_geometry<ls, ls>("LINESTRING(0 0,2 0)", "LINESTRING(2 0,0 0)", "tix+=", "txi=+");
  21. test_geometry<ls, ls>("LINESTRING(1 0,1 1)", "LINESTRING(0 0,1 0,2 0)", "tuu++");
  22. test_geometry<ls, ls>("LINESTRING(1 0,0 0)", "LINESTRING(0 0,1 0,2 0)", "txi=+", "tiu+=");
  23. test_geometry<ls, ls>("LINESTRING(1 0,2 0)", "LINESTRING(0 0,1 0,2 0)", "tii++", "txx==");
  24. test_geometry<ls, ls>("LINESTRING(1 1,1 0)", "LINESTRING(0 0,1 0,2 0)", "txu++");
  25. test_geometry<ls, ls>("LINESTRING(0 0,1 0)", "LINESTRING(0 0,1 0,2 0)", "tii++", "txu==");
  26. test_geometry<ls, ls>("LINESTRING(2 0,1 0)", "LINESTRING(0 0,1 0,2 0)", "txi=+", "tix+=");
  27. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,1 1)", "tuu++");
  28. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,0 0)", "tix+=", "tui=+");
  29. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,2 0)", "tii++", "txx==");
  30. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 1,1 0)", "tux++");
  31. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(0 0,1 0)", "tii++", "tux==");
  32. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(2 0,1 0)", "tix+=", "txi=+");
  33. test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 1,1 0,3 0,3 1)", "mii++", "ccc==", "muu==");
  34. test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 -1,1 0,3 0,3 -1)", "mii++", "ccc==", "muu==");
  35. test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 1,3 0,1 0,1 1)", "miu+=", "mui=+");
  36. test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 -1,3 0,1 0,1 -1)", "miu+=", "mui=+");
  37. test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 1,2 0,4 0,4 1)", "tii++", "ccc==", "tuu==");
  38. test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 -1,2 0,4 0,4 -1)", "tii++", "ccc==", "tuu==");
  39. test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 1,4 0,2 0,2 1)", "tiu+=", "tui=+");
  40. test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 -1,4 0,2 0,2 -1)", "tiu+=", "tui=+");
  41. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(1 0,2 1,3 5)", "tii++", "ecc==", "tux==");
  42. test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(3 5,2 1,1 0)", "tix+=", "ecc==", "tui=+");
  43. test_geometry<ls, ls>("LINESTRING(1 0,2 1,3 5)", "LINESTRING(0 0,1 0,2 1,3 5,4 0)", "txu==", "ecc==", "tii++");
  44. test_geometry<ls, ls>("LINESTRING(3 5,2 1,1 0)", "LINESTRING(0 0,1 0,2 1,3 5,4 0)", "tiu+=", "ecc==", "txi=+");
  45. test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "mii++", "txu==");
  46. test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "miu+=", "txi=+");
  47. test_geometry<ls, ls>("LINESTRING(-1 -1,1 0,10 0,20 -1)", "LINESTRING(0 0,10 0)", "mii++", "tux==");
  48. test_geometry<ls, ls>("LINESTRING(20 -1,10 0,1 0,-1 -1)", "LINESTRING(0 0,10 0)", "mui=+", "tix+=");
  49. test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)",
  50. "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)",
  51. expected("tii++")("ecc==")("muu==")("mii++")("muu==")("mii++")("mux=="));
  52. test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)",
  53. "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)",
  54. expected("tiu+=")("ecc==")("mui=+")("miu+=")("mui=+")("miu+=")("mui=+"));
  55. test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)",
  56. "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)",
  57. expected("tui=+")("ecc==")("miu+=")("mui=+")("miu+=")("mui=+")("mix+="));
  58. test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)",
  59. "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)",
  60. expected("tuu==")("ecc==")("mii++")("muu==")("mii++")("muu==")("mii++"));
  61. if (BOOST_GEOMETRY_CONDITION((boost::is_same<T, double>::value)))
  62. {
  63. test_geometry<ls, ls>("LINESTRING(-1 0,1 0,2 1.0004570537241201524198894179384922,3 2)",
  64. "LINESTRING(4 5,3 2,1 0,0 0)",
  65. "mix+=", "txi=+", "ecc==");
  66. test_geometry<ls, ls>("LINESTRING(4 5,3 2,1 0,0 0)",
  67. "LINESTRING(-1 0,1 0,2 1.0004570537241201524198894179384922,3 2)",
  68. "mxi=+", "tix+=", "ecc==");
  69. }
  70. test_geometry<ls, ls>("LINESTRING(30 0,20 0,1 1,-1 -1)", "LINESTRING(0 -1,0 0,1 -1,20 0,25 0)", "mix+=", "tui=+", "muu++");
  71. test_geometry<ls, ls>("LINESTRING(0 -1,0 0,1 -1,20 0,25 0)", "LINESTRING(30 0,20 0,1 1,-1 -1)", "mxi=+", "tiu+=", "muu++");
  72. test_geometry<ls, ls>("LINESTRING(0 0,30 0)", "LINESTRING(4 0,4 1,20 1,5 0,1 0)", "muu++", "mui=+", "mix+=");
  73. test_geometry<ls, ls>("LINESTRING(4 0,4 1,20 1,5 0,1 0)", "LINESTRING(0 0,30 0)", "muu++", "miu+=", "mxi=+");
  74. test_geometry<ls, ls>("LINESTRING(30 0,0 0)", "LINESTRING(1 0,5 0,20 1,4 1,4 0,5 0)",
  75. expected("mui=+")("miu+=")("mui=+")("mix+="));
  76. test_geometry<ls, ls>("LINESTRING(1 0,5 0,20 1,4 1,4 0,5 0)", "LINESTRING(30 0,0 0)",
  77. expected("miu+=")("mui=+")("miu+=")("mxi=+"));
  78. test_geometry<ls, ls>("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)",
  79. expected("mii++")("iuu++")("muu=="));
  80. test_geometry<ls, ls>("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,5 0,4 1)",
  81. expected("mii++")("muu++")("muu=="));
  82. // non-collinear
  83. test_geometry<ls, ls>("LINESTRING(0 1,0 0)", "LINESTRING(0 0,1 0,2 0)", "txu++");
  84. test_geometry<ls, ls>("LINESTRING(0 1,0 0,1 1)", "LINESTRING(0 0,1 0,2 0)", "tuu++");
  85. test_geometry<ls, ls>("LINESTRING(0 1,1 0,2 1)", "LINESTRING(0 0,1 0,2 0)", "tuu++");
  86. // SPIKE - NON-ENDPOINT - NON-OPPOSITE
  87. // spike - neq eq
  88. test_geometry<ls, ls>("LINESTRING(0 2,0 4,0 1)", "LINESTRING(0 0,0 4,6 3)",
  89. expected("mii++")("txu==")("tiu==")("mxi=+"));
  90. // spike - eq eq
  91. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 1)", "LINESTRING(0 0,0 4,6 3)",
  92. expected("tii++")("txu==")("tiu==")("mxi=+"));
  93. // spike - eq neq
  94. test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 1)", "LINESTRING(0 0,0 4,6 3)",
  95. expected("tii++")("mxu==")("miu==")("mxi=+"));
  96. // spike - neq neq
  97. test_geometry<ls, ls>("LINESTRING(0 1,0 3,0 2)", "LINESTRING(0 0,0 4,6 3)",
  98. expected("mii++")("mxu==")("miu==")("mxi=+"));
  99. // spike - out neq
  100. test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 2)", "LINESTRING(0 1,0 4,6 3)",
  101. expected("mii++")("mxu==")("miu==")("mxi=+"));
  102. // spike - out eq
  103. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(0 1,0 4,6 3)",
  104. expected("mii++")("txu==")("tiu==")("mxi=+"));
  105. // spike - out out/eq
  106. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(1 0,0 4,6 3)",
  107. expected("tuu++"));
  108. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(-1 0,0 4,6 3)",
  109. expected("tuu++"));
  110. // spike - out out/neq
  111. test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(-1 0,1 0,6 3)",
  112. expected("muu++"));
  113. test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(-1 0,1 0,6 3)",
  114. expected("muu++"));
  115. // SPIKE - NON-ENDPOINT - OPPOSITE
  116. // opposite - eq eq
  117. test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -1,0 0,0 4,6 3)",
  118. expected("tiu+=")("txi=+")("tii=+")("mxu=="));
  119. test_geometry<ls, ls>("LINESTRING(0 -1,0 0,0 4,6 3)", "LINESTRING(0 6,0 4,0 0,0 2)",
  120. expected("tui=+")("tix+=")("tii+=")("mux=="));
  121. // opposite - neq eq
  122. test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -1,0 0,0 5,6 3)",
  123. expected("miu+=")("txi=+")("tii=+")("mxu=="));
  124. // opposite - eq neq
  125. test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -2,0 -1,0 4,6 3)",
  126. expected("tiu+=")("mxi=+")("mii=+")("mxu=="));
  127. // opposite - neq neq
  128. test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -2,0 -1,0 3,6 3)",
  129. expected("miu+=")("mxi=+")("mii=+")("mxu=="));
  130. // opposite - neq neq
  131. test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -2,0 -1,0 3,0 5,6 3)",
  132. expected("miu+=")("mxi=+")("mii=+")("mxu=="));
  133. // opposite - neq eq
  134. test_geometry<ls, ls>("LINESTRING(6 3,0 3,0 0)", "LINESTRING(0 0,0 2,0 3,0 1)",
  135. expected("txi=+")("tix+=")("tii+=")("mux=="));
  136. // SPIKE - ENDPOINT - NON-OPPOSITE
  137. // spike - neq eq
  138. test_geometry<ls, ls>("LINESTRING(0 2,0 4,0 1)", "LINESTRING(0 0,0 4)",
  139. expected("mii++")("txx==")("tix==")("mxi=+"));
  140. test_geometry<ls, ls>("LINESTRING(0 2,0 4,0 1)", "LINESTRING(0 4,0 0)",
  141. expected("miu+=")("txi=+")("tii=+")("mxu=="));
  142. // spike - eq eq
  143. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 1)", "LINESTRING(0 0,0 4)",
  144. expected("tii++")("txx==")("tix==")("mxi=+"));
  145. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 1)", "LINESTRING(0 4,0 0)",
  146. expected("tix+=")("txi=+")("tii=+")("mxu=="));
  147. // spike - eq neq
  148. test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 1)", "LINESTRING(0 0,0 4)",
  149. expected("tii++")("mxu==")("miu==")("mxi=+"));
  150. test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 1)", "LINESTRING(0 4,0 0)",
  151. expected("tix+=")("mxi=+")("mii=+")("mxu=="));
  152. // spike - neq neq
  153. test_geometry<ls, ls>("LINESTRING(0 1,0 3,0 2)", "LINESTRING(0 0,0 4)",
  154. expected("mii++")("mxu==")("miu==")("mxi=+"));
  155. test_geometry<ls, ls>("LINESTRING(0 1,0 3,0 2)", "LINESTRING(0 4,0 0)",
  156. expected("miu+=")("mxi=+")("mii=+")("mxu=="));
  157. // spike - out neq
  158. test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 2)", "LINESTRING(0 1,0 4)",
  159. expected("mii++")("mxu==")("miu==")("mxi=+"));
  160. test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 2)", "LINESTRING(0 4,0 1)",
  161. expected("mix+=")("mxi=+")("mii=+")("mxu=="));
  162. // spike - out eq
  163. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(0 1,0 4)",
  164. expected("mii++")("txx==")("tix==")("mxi=+"));
  165. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(0 4,0 1)",
  166. expected("mix+=")("txi=+")("tii=+")("mxu=="));
  167. // spike - out out/eq
  168. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(1 0,0 4)",
  169. expected("tux++"));
  170. test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(-1 0,0 4)",
  171. expected("tux++"));
  172. // spike - out out/neq
  173. test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(-1 0,1 0)",
  174. expected("muu++"));
  175. test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(1 0,-1 0)",
  176. expected("muu++"));
  177. test_geometry<ls, ls>("LINESTRING(3 0,0 0)",
  178. "LINESTRING(4 2,1 0,9 0)",
  179. expected("mui=+")("miu+="));
  180. // 01.02.2015
  181. test_geometry<ls, ls>("LINESTRING(6 0,0 0,5 0)",
  182. "LINESTRING(2 0,0 0,-10 0)",
  183. expected("mii++")("txu==")("tiu==")("mui=+"));
  184. // the reversal could be automatic...
  185. test_geometry<ls, ls>("LINESTRING(2 0,0 0,-10 0)",
  186. "LINESTRING(6 0,0 0,5 0)",
  187. expected("mii++")("tux==")("tui==")("miu+="));
  188. // sanity check
  189. test_geometry<ls, ls>("LINESTRING(6 0,0 0)",
  190. "LINESTRING(2 0,0 0,-10 0)",
  191. expected("mii++")("txu=="));
  192. test_geometry<ls, ls>("LINESTRING(0 0,5 0)",
  193. "LINESTRING(2 0,0 0,-10 0)",
  194. expected("tiu+=")("mui=+"));
  195. if ( BOOST_GEOMETRY_CONDITION((boost::is_same<T, double>::value)) )
  196. {
  197. test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
  198. "LINESTRING(12 10, 12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
  199. expected("mii++")("ccc==")("mux=="));
  200. test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
  201. "LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392, 12 10)",
  202. expected("miu+=")("mui=+"));
  203. test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
  204. "LINESTRING(12 10, 12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
  205. expected("mui=+")("mix+="));
  206. test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 0)",
  207. "LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392, 12 10)",
  208. expected("muu==")("ccc==")("mii++"));
  209. test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
  210. "LINESTRING(12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
  211. expected("mii++")("ccc==")("mux=="));
  212. test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
  213. "LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392)",
  214. expected("mix+=")("mui=+"));
  215. test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
  216. "LINESTRING(12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
  217. expected("mui=+")("mix+="));
  218. test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
  219. "LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392)",
  220. expected("mux==")("ccc==")("mii++"));
  221. test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
  222. "LINESTRING(12 10, 12.5 -0.50051443471392, 15 0)",
  223. expected("mii++")("mux=="));
  224. test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
  225. "LINESTRING(15 0, 12.5 -0.50051443471392, 12 10)",
  226. expected("miu+=")("mui=+"));
  227. test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
  228. "LINESTRING(12 10, 12.5 -0.50051443471392, 15 0)",
  229. expected("mui=+")("mix+="));
  230. test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
  231. "LINESTRING(15 0, 12.5 -0.50051443471392, 12 10)",
  232. expected("muu==")("mii++"));
  233. }
  234. // TODO:
  235. //test_geometry<ls, ls>("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
  236. //test_geometry<ls, ls>("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
  237. //test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(3 0,3 3,3 1)", "0F1FF0102");
  238. //test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 3,2 1)", "0F1FF0102");
  239. //test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 2,2 1)", "0F1FF0102");
  240. //test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,4 4)", "LINESTRING(0 0,1 1,4 4)", "1FFF0FFF2");
  241. //if ( boost::is_same<T, double>::value )
  242. //{
  243. // to_svg<ls, ls>("LINESTRING(0 0,1 0,2 0,2.5 0,3 1)", "LINESTRING(0 0,2 0,2.5 0,3 1)", "test11.svg");
  244. // to_svg<ls, ls>("LINESTRING(0 0,1 0,2 0,2.5 0,3 1)", "LINESTRING(3 1,2.5 0,2 0,0 0)", "test12.svg");
  245. // to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,20 0,30 0,31 1)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test21.svg");
  246. // to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,20 0,30 0,31 1)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test22.svg");
  247. // to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test31.svg");
  248. // to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test32.svg");
  249. // to_svg<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test33.svg");
  250. // to_svg<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test34.svg");
  251. //}
  252. // duplicated
  253. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0,30 0))",
  254. "MULTILINESTRING((0 10,5 0,20 0,20 0,30 0),(2 0,2 0),(3 0,3 0,3 0))",
  255. expected("mii++")("ccc==")("ccc==")("txx=="));
  256. // spike
  257. test_geometry<ls, ls>("LINESTRING(2 2,5 -1,15 2,18 0,20 0)",
  258. "LINESTRING(30 0,19 0,18 0,0 0)",
  259. expected("iuu++")("iuu++")("tiu+=")("mxi=+"));
  260. // spike
  261. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0,5 0))",
  262. "MULTILINESTRING((1 0,8 0,4 0))",
  263. expected("mii++")("mix+=")("mux==")("mui==")("mix+=")("mii+=")("mxu==")("mxi=+"));
  264. /*test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0,5 0))",
  265. "MULTILINESTRING((1 0,8 0,4 0),(2 0,9 0,5 0))",
  266. expected("mii")("ccc")("ccc")("txx"));*/
  267. // spike vs endpoint
  268. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
  269. "MULTILINESTRING((-1 0,0 0,-2 0),(11 0,10 0,12 0))",
  270. expected("tuu++")("txu++"));
  271. // internal turning R vs spike
  272. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
  273. "MULTILINESTRING((0 1,1 1,0 1))",
  274. expected("tuu++"));
  275. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
  276. "MULTILINESTRING((1 2,1 1,1 2))",
  277. expected("tuu++"));
  278. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 0,0 0))",
  279. "MULTILINESTRING((2 0,1 0,2 0))",
  280. expected("tuu++"));
  281. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
  282. "MULTILINESTRING((0 2,1 1,0 2))",
  283. expected("tuu++"));
  284. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
  285. "MULTILINESTRING((2 0,1 1,2 0))",
  286. expected("tuu++"));
  287. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
  288. "MULTILINESTRING((2 1,1 1,2 1))",
  289. expected("txi=+")("tix+=")("tii+=")("txx=="));
  290. // internal turning L vs spike
  291. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
  292. "MULTILINESTRING((2 1,1 1,2 1))",
  293. expected("tuu++"));
  294. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
  295. "MULTILINESTRING((1 2,1 1,1 2))",
  296. expected("tuu++"));
  297. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
  298. "MULTILINESTRING((2 2,1 1,2 2))",
  299. expected("tuu++"));
  300. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
  301. "MULTILINESTRING((0 0,1 1,0 0))",
  302. expected("tuu++"));
  303. test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
  304. "MULTILINESTRING((0 1,1 1,0 1))",
  305. expected("txi=+")("tix+=")("tii+=")("txx=="));
  306. // spike vs internal turning R
  307. test_geometry<mls, mls>("MULTILINESTRING((0 1,1 1,0 1))",
  308. "MULTILINESTRING((1 0,1 1,2 1))",
  309. expected("tuu++"));
  310. test_geometry<mls, mls>("MULTILINESTRING((1 2,1 1,1 2))",
  311. "MULTILINESTRING((1 0,1 1,2 1))",
  312. expected("tuu++"));
  313. test_geometry<mls, mls>("MULTILINESTRING((2 0,1 0,2 0))",
  314. "MULTILINESTRING((0 0,1 0,0 0))",
  315. expected("tuu++"));
  316. test_geometry<mls, mls>("MULTILINESTRING((0 2,1 1,0 2))",
  317. "MULTILINESTRING((1 0,1 1,2 1))",
  318. expected("tuu++"));
  319. test_geometry<mls, mls>("MULTILINESTRING((2 0,1 1,2 0))",
  320. "MULTILINESTRING((1 0,1 1,2 1))",
  321. expected("tuu++"));
  322. test_geometry<mls, mls>("MULTILINESTRING((2 1,1 1,2 1))",
  323. "MULTILINESTRING((1 0,1 1,2 1))",
  324. expected("tix+=")("txi=+")("tii=+")("txx=="));
  325. // spike vs internal turning L
  326. test_geometry<mls, mls>("MULTILINESTRING((2 1,1 1,2 1))",
  327. "MULTILINESTRING((1 0,1 1,0 1))",
  328. expected("tuu++"));
  329. test_geometry<mls, mls>("MULTILINESTRING((1 2,1 1,1 2))",
  330. "MULTILINESTRING((1 0,1 1,0 1))",
  331. expected("tuu++"));
  332. test_geometry<mls, mls>("MULTILINESTRING((2 2,1 1,2 2))",
  333. "MULTILINESTRING((1 0,1 1,0 1))",
  334. expected("tuu++"));
  335. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  336. "MULTILINESTRING((1 0,1 1,0 1))",
  337. expected("tuu++"));
  338. test_geometry<mls, mls>("MULTILINESTRING((0 1,1 1,0 1))",
  339. "MULTILINESTRING((1 0,1 1,0 1))",
  340. expected("tix+=")("txi=+")("tii=+")("txx=="));
  341. // spike vs internal collinear
  342. test_geometry<mls, mls>("MULTILINESTRING((0 1,1 1,0 1))",
  343. "MULTILINESTRING((2 1,1 1,0 1))",
  344. expected("tix+=")("txi=+")("tii=+")("txx=="));
  345. // internal collinear vs spike
  346. test_geometry<mls, mls>("MULTILINESTRING((2 1,1 1,0 1))",
  347. "MULTILINESTRING((0 1,1 1,0 1))",
  348. expected("txi=+")("tix+=")("tii+=")("txx=="));
  349. // spike vs spike
  350. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  351. "MULTILINESTRING((2 2,1 1,2 2))",
  352. expected("tuu++"));
  353. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  354. "MULTILINESTRING((2 0,1 1,2 0))",
  355. expected("tuu++"));
  356. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  357. "MULTILINESTRING((2 1,1 1,2 1))",
  358. expected("tuu++"));
  359. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  360. "MULTILINESTRING((0 1,1 1,0 1))",
  361. expected("tuu++"));
  362. // collinear spikes
  363. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  364. "MULTILINESTRING((0 0,1 1,0 0))",
  365. expected("tii++")("tix+=")("txi=+")("txx==")
  366. ("ecc=="));
  367. test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
  368. "MULTILINESTRING((1 1,0 0,1 1))",
  369. expected("tix+=")("tii+=")("txx==")("txi==")
  370. ("txi=+")("tii=+")("txx==")("tix=="));
  371. // non-spike similar
  372. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
  373. "MULTILINESTRING((-1 0,0 0,2 0))",
  374. expected("tii++")("mux=="));
  375. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
  376. "MULTILINESTRING((-1 -1,0 0,2 0))",
  377. expected("tii++")("mux=="));
  378. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
  379. "MULTILINESTRING((2 0,0 0,-1 0))",
  380. expected("tiu+=")("mui=+"));
  381. test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
  382. "MULTILINESTRING((2 0,0 0,-1 -1))",
  383. expected("tiu+=")("mui=+"));
  384. }
  385. int test_main(int, char* [])
  386. {
  387. test_all<float>();
  388. test_all<double>();
  389. #if ! defined(_MSC_VER)
  390. test_all<long double>();
  391. #endif
  392. #if defined(HAVE_TTMATH)
  393. test_all<ttmath_big>();
  394. #endif
  395. return 0;
  396. }