within_linear_areal.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
  4. // This file was modified by Oracle on 2014, 2015, 2016.
  5. // Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #include "test_within.hpp"
  11. #include <boost/geometry/geometries/geometries.hpp>
  12. #include <boost/geometry/geometries/point_xy.hpp>
  13. #include <boost/geometry/geometries/multi_linestring.hpp>
  14. #include <boost/geometry/geometries/multi_polygon.hpp>
  15. template <typename P1, typename P2>
  16. void test_l_a()
  17. {
  18. typedef bg::model::linestring<P1> ls;
  19. typedef bg::model::multi_linestring<ls> mls;
  20. typedef bg::model::polygon<P2> poly;
  21. typedef bg::model::ring<P2> ring;
  22. typedef bg::model::multi_polygon<poly> mpoly;
  23. // B,I
  24. test_geometry<ls, ring>("LINESTRING(0 0, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
  25. // B,I
  26. test_geometry<ls, poly>("LINESTRING(0 0, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
  27. // I
  28. test_geometry<ls, poly>("LINESTRING(1 1, 2 2)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
  29. // I,E
  30. test_geometry<ls, poly>("LINESTRING(1 1, 6 6)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
  31. // B
  32. test_geometry<ls, poly>("LINESTRING(0 0, 5 0)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
  33. test_geometry<ls, poly>("LINESTRING(0 0, 0 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
  34. // E
  35. test_geometry<ls, poly>("LINESTRING(6 0, 6 5)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
  36. // BIBIB
  37. test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true);
  38. // BIBEBIB
  39. test_geometry<ls, mpoly>("LINESTRING(0 0, 10 10)", "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((6 6,5 10,10 10,10 5,6 6)))", false);
  40. // MySQL report 18.12.2014 (https://svn.boost.org/trac/boost/ticket/10887)
  41. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 2)",
  42. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  43. true);
  44. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 5)",
  45. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  46. true);
  47. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
  48. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  49. true);
  50. // MySQL report 18.12.2014 - extended
  51. test_geometry<ls, mpoly>("LINESTRING(5 -2,5 0)",
  52. "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)))",
  53. true);
  54. test_geometry<ls, mpoly>("LINESTRING(0 0,5 0)",
  55. "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)))",
  56. false);
  57. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
  58. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  59. true);
  60. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 0,0 -1,5 0))",
  61. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  62. false);
  63. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(6 -2,5 0))",
  64. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  65. true);
  66. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,0 1,5 0),(0 -1,5 0))",
  67. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  68. false);
  69. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,5 0),(5 -2,5 0))",
  70. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  71. false);
  72. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,5 0),(0 0,5 0))",
  73. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  74. false);
  75. // BI
  76. test_geometry<mls, poly>("MULTILINESTRING((0 0,2 2),(2 2,3 3))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true);
  77. // I E
  78. test_geometry<mls, poly>("MULTILINESTRING((1 1,2 2),(6 6,7 7))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false);
  79. // I I
  80. test_geometry<mls, mpoly>("MULTILINESTRING((1 1,5 5),(6 6,7 7))",
  81. "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))",
  82. true);
  83. // I E
  84. test_geometry<mls, mpoly>("MULTILINESTRING((1 1,5 5),(11 11,12 12))",
  85. "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))",
  86. false);
  87. }
  88. template <typename P1, typename P2>
  89. void test_all()
  90. {
  91. test_l_a<P1, P2>();
  92. }
  93. template <typename P>
  94. void test_all()
  95. {
  96. test_l_a<P, P>();
  97. }
  98. int test_main( int , char* [] )
  99. {
  100. test_all<bg::model::d2::point_xy<int> >();
  101. test_all<bg::model::d2::point_xy<double> >();
  102. test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
  103. #if defined(HAVE_TTMATH)
  104. test_all<bg::model::d2::point_xy<ttmath_big> >();
  105. #endif
  106. return 0;
  107. }