test_empty_geometry.hpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2018, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_GEOMETRY_TEST_EMPTY_GEOMETRY_HPP
  8. #define BOOST_GEOMETRY_TEST_EMPTY_GEOMETRY_HPP
  9. template <typename Point, typename Strategy>
  10. void test_more_empty_input_pointlike_pointlike(Strategy const& strategy)
  11. {
  12. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  13. std::cout << std::endl;
  14. std::cout << "testing on empty inputs... " << std::flush;
  15. #endif
  16. bg::model::multi_point<Point> multipoint_empty;
  17. Point point = from_wkt<Point>("point(0 0)");
  18. // 1st geometry is empty
  19. test_empty_input(multipoint_empty, point, strategy);
  20. // 2nd geometry is empty
  21. test_empty_input(point, multipoint_empty, strategy);
  22. // both geometries are empty
  23. test_empty_input(multipoint_empty, multipoint_empty, strategy);
  24. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  25. std::cout << "done!" << std::endl;
  26. #endif
  27. }
  28. template <typename Point, typename Strategy>
  29. void test_more_empty_input_pointlike_linear(Strategy const& strategy)
  30. {
  31. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  32. std::cout << std::endl;
  33. std::cout << "testing on empty inputs... " << std::flush;
  34. #endif
  35. bg::model::linestring<Point> line_empty;
  36. bg::model::multi_point<Point> multipoint_empty;
  37. bg::model::multi_linestring<bg::model::linestring<Point> > multiline_empty;
  38. Point point = from_wkt<Point>("POINT(0 0)");
  39. bg::model::linestring<Point> line =
  40. from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1,2 2)");
  41. // 1st geometry is empty
  42. test_empty_input(multipoint_empty, line, strategy);
  43. // 2nd geometry is empty
  44. test_empty_input(line, multipoint_empty, strategy);
  45. test_empty_input(point, line_empty, strategy);
  46. test_empty_input(point, multiline_empty, strategy);
  47. // both geometries are empty
  48. test_empty_input(multipoint_empty, line_empty, strategy);
  49. test_empty_input(multipoint_empty, multiline_empty, strategy);
  50. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  51. std::cout << "done!" << std::endl;
  52. #endif
  53. }
  54. template <typename Point, typename Strategy>
  55. void test_more_empty_input_pointlike_areal(Strategy const& strategy)
  56. {
  57. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  58. std::cout << std::endl;
  59. std::cout << "testing on empty inputs... " << std::flush;
  60. #endif
  61. bg::model::multi_point<Point> multipoint_empty;
  62. bg::model::polygon<Point> polygon_empty;
  63. bg::model::multi_polygon<bg::model::polygon<Point> > multipolygon_empty;
  64. Point point = from_wkt<Point>("POINT(0 0)");
  65. bg::model::polygon<Point> polygon =
  66. from_wkt<bg::model::polygon<Point> >("POLYGON((0 0,1 0,1 1,0 1,0 0))");
  67. // 1st geometry is empty
  68. test_empty_input(multipoint_empty, polygon, strategy);
  69. test_empty_input(polygon_empty, point, strategy);
  70. test_empty_input(multipolygon_empty, point, strategy);
  71. // 2nd geometry is empty
  72. test_empty_input(point, polygon_empty, strategy);
  73. test_empty_input(point, multipolygon_empty, strategy);
  74. test_empty_input(polygon, multipoint_empty, strategy);
  75. // both geometries are empty
  76. test_empty_input(multipoint_empty, polygon_empty, strategy);
  77. test_empty_input(multipoint_empty, multipolygon_empty, strategy);
  78. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  79. std::cout << "done!" << std::endl;
  80. #endif
  81. }
  82. template <typename Point, typename Strategy>
  83. void test_more_empty_input_linear_linear(Strategy const& strategy)
  84. {
  85. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  86. std::cout << std::endl;
  87. std::cout << "testing on empty inputs... " << std::flush;
  88. #endif
  89. bg::model::linestring<Point> line_empty;
  90. bg::model::multi_linestring<bg::model::linestring<Point> > multiline_empty;
  91. bg::model::linestring<Point> line =
  92. from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1)");
  93. // 1st geometry is empty
  94. test_empty_input(line_empty, line, strategy);
  95. test_empty_input(multiline_empty, line, strategy);
  96. // 2nd geometry is empty
  97. test_empty_input(line, line_empty, strategy);
  98. test_empty_input(line, multiline_empty, strategy);
  99. // both geometries are empty
  100. test_empty_input(line_empty, line_empty, strategy);
  101. test_empty_input(multiline_empty, line_empty, strategy);
  102. test_empty_input(multiline_empty, multiline_empty, strategy);
  103. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  104. std::cout << "done!" << std::endl;
  105. #endif
  106. }
  107. template <typename Point, typename Strategy>
  108. void test_more_empty_input_linear_areal(Strategy const& strategy)
  109. {
  110. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  111. std::cout << std::endl;
  112. std::cout << "testing on empty inputs... " << std::flush;
  113. #endif
  114. bg::model::linestring<Point> line_empty;
  115. bg::model::multi_linestring<bg::model::linestring<Point> > multiline_empty;
  116. bg::model::polygon<Point> polygon_empty;
  117. bg::model::multi_polygon<bg::model::polygon<Point> > multipolygon_empty;
  118. bg::model::linestring<Point> line =
  119. from_wkt<bg::model::linestring<Point> >("LINESTRING(0 0,1 1)");
  120. bg::model::polygon<Point> polygon =
  121. from_wkt<bg::model::polygon<Point> >("POLYGON((0 0,1 0,1 1,0 1,0 0))");
  122. // 1st geometry is empty
  123. test_empty_input(line_empty, polygon, strategy);
  124. test_empty_input(multiline_empty, polygon, strategy);
  125. test_empty_input(polygon_empty, line, strategy);
  126. test_empty_input(multipolygon_empty, line, strategy);
  127. // 2nd geometry is empty
  128. test_empty_input(line, polygon_empty, strategy);
  129. test_empty_input(line, multipolygon_empty, strategy);
  130. test_empty_input(polygon, line_empty, strategy);
  131. test_empty_input(polygon, multiline_empty, strategy);
  132. // both geometries are empty
  133. test_empty_input(line_empty, polygon_empty, strategy);
  134. test_empty_input(line_empty, multipolygon_empty, strategy);
  135. test_empty_input(multiline_empty, polygon_empty, strategy);
  136. test_empty_input(multiline_empty, multipolygon_empty, strategy);
  137. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  138. std::cout << "done!" << std::endl;
  139. #endif
  140. }
  141. template <typename Point, typename Strategy>
  142. void test_more_empty_input_areal_areal(Strategy const& strategy)
  143. {
  144. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  145. std::cout << std::endl;
  146. std::cout << "testing on empty inputs... " << std::flush;
  147. #endif
  148. bg::model::polygon<Point> polygon_empty;
  149. bg::model::multi_polygon<bg::model::polygon<Point> > multipolygon_empty;
  150. bg::model::polygon<Point> polygon =
  151. from_wkt<bg::model::polygon<Point> >("POLYGON((0 0,1 0,1 1,0 1,0 0))");
  152. // 1st geometry is empty
  153. test_empty_input(polygon_empty, polygon, strategy);
  154. test_empty_input(multipolygon_empty, polygon, strategy);
  155. // 2nd geometry is empty
  156. test_empty_input(polygon, polygon_empty, strategy);
  157. test_empty_input(polygon, multipolygon_empty, strategy);
  158. // both geometries are empty
  159. test_empty_input(polygon_empty, multipolygon_empty, strategy);
  160. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  161. std::cout << "done!" << std::endl;
  162. #endif
  163. }
  164. #endif // BOOST_GEOMETRY_TEST_EMPTY_GEOMETRY_HPP