union_pl_pl.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2014-2015, Oracle and/or its affiliates.
  3. // Licensed under the Boost Software License version 1.0.
  4. // http://www.boost.org/users/license.html
  5. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  6. #include <iostream>
  7. #ifndef BOOST_TEST_MODULE
  8. #define BOOST_TEST_MODULE test_union_pointlike_pointlike
  9. #endif
  10. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  11. #define BOOST_GEOMETRY_DEBUG_TURNS
  12. #define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
  13. #endif
  14. #include <boost/test/included/unit_test.hpp>
  15. #include "../test_set_ops_pointlike.hpp"
  16. #include <boost/geometry/geometries/multi_point.hpp>
  17. typedef bg::model::point<double,2,bg::cs::cartesian> point_type;
  18. typedef bg::model::multi_point<point_type> multi_point_type;
  19. //===========================================================================
  20. //===========================================================================
  21. //===========================================================================
  22. BOOST_AUTO_TEST_CASE( test_union_point_point )
  23. {
  24. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  25. std::cout << std::endl << std::endl << std::endl;
  26. std::cout << "*** POINT / POINT UNION ***" << std::endl;
  27. std::cout << std::endl;
  28. #endif
  29. typedef point_type P;
  30. typedef multi_point_type MP;
  31. typedef test_set_op_of_pointlike_geometries
  32. <
  33. P, P, MP, bg::overlay_union
  34. > tester;
  35. tester::apply
  36. ("ppu01",
  37. from_wkt<P>("POINT(0 0)"),
  38. from_wkt<P>("POINT(1 1)"),
  39. from_wkt<MP>("MULTIPOINT(0 0,1 1)")
  40. );
  41. tester::apply
  42. ("ppu02",
  43. from_wkt<P>("POINT(0 0)"),
  44. from_wkt<P>("POINT(0 0)"),
  45. from_wkt<MP>("MULTIPOINT(0 0)")
  46. );
  47. }
  48. BOOST_AUTO_TEST_CASE( test_union_multipoint_point )
  49. {
  50. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  51. std::cout << std::endl << std::endl << std::endl;
  52. std::cout << "*** MULTIPOINT / POINT UNION ***" << std::endl;
  53. std::cout << std::endl;
  54. #endif
  55. typedef point_type P;
  56. typedef multi_point_type MP;
  57. typedef test_set_op_of_pointlike_geometries
  58. <
  59. MP, P, MP, bg::overlay_union
  60. > tester;
  61. tester::apply
  62. ("mppu01",
  63. from_wkt<MP>("MULTIPOINT(0 0)"),
  64. from_wkt<P>("POINT(1 1)"),
  65. from_wkt<MP>("MULTIPOINT(0 0,1 1)")
  66. );
  67. tester::apply
  68. ("mppu02",
  69. from_wkt<MP>("MULTIPOINT(0 0)"),
  70. from_wkt<P>("POINT(0 0)"),
  71. from_wkt<MP>("MULTIPOINT(0 0)")
  72. );
  73. tester::apply
  74. ("mppu03",
  75. from_wkt<MP>("MULTIPOINT(0 0,0 0)"),
  76. from_wkt<P>("POINT(1 1)"),
  77. from_wkt<MP>("MULTIPOINT(0 0,0 0,1 1)")
  78. );
  79. tester::apply
  80. ("mppu04",
  81. from_wkt<MP>("MULTIPOINT(0 0,0 0)"),
  82. from_wkt<P>("POINT(0 0)"),
  83. from_wkt<MP>("MULTIPOINT(0 0)")
  84. );
  85. tester::apply
  86. ("mppu05",
  87. from_wkt<MP>("MULTIPOINT(0 0,0 0,1 0)"),
  88. from_wkt<P>("POINT(1 1)"),
  89. from_wkt<MP>("MULTIPOINT(0 0,0 0,1 0,1 1)")
  90. );
  91. tester::apply
  92. ("mppu06",
  93. from_wkt<MP>("MULTIPOINT(0 0,0 0,1 0)"),
  94. from_wkt<P>("POINT(1 0)"),
  95. from_wkt<MP>("MULTIPOINT(0 0,0 0,1 0)")
  96. );
  97. tester::apply
  98. ("mppu07",
  99. from_wkt<MP>("MULTIPOINT(0 0,0 0,1 0)"),
  100. from_wkt<P>("POINT(0 0)"),
  101. from_wkt<MP>("MULTIPOINT(0 0,1 0)")
  102. );
  103. tester::apply
  104. ("mppu08",
  105. from_wkt<MP>("MULTIPOINT()"),
  106. from_wkt<P>("POINT(0 0)"),
  107. from_wkt<MP>("MULTIPOINT(0 0)")
  108. );
  109. }
  110. BOOST_AUTO_TEST_CASE( test_union_multipoint_multipoint )
  111. {
  112. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  113. std::cout << std::endl << std::endl << std::endl;
  114. std::cout << "*** MULTIPOINT / MULTIPOINT UNION ***" << std::endl;
  115. std::cout << std::endl;
  116. #endif
  117. typedef multi_point_type MP;
  118. typedef test_set_op_of_pointlike_geometries
  119. <
  120. MP, MP, MP, bg::overlay_union
  121. > tester;
  122. tester::apply
  123. ("mpmpu01",
  124. from_wkt<MP>("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"),
  125. from_wkt<MP>("MULTIPOINT(1 0,1 1,1 1,1 1)"),
  126. from_wkt<MP>("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"),
  127. from_wkt<MP>("MULTIPOINT(1 0,1 1,1 1,1 1,2 2,3 3,0 0,0 0,2 2)")
  128. );
  129. tester::apply
  130. ("mpmpu02",
  131. from_wkt<MP>("MULTIPOINT(0 0,1 1,1 0,1 1)"),
  132. from_wkt<MP>("MULTIPOINT(1 0,0 0,1 1,0 0)"),
  133. from_wkt<MP>("MULTIPOINT(0 0,1 1,1 0,1 1)"),
  134. from_wkt<MP>("MULTIPOINT(1 0,0 0,1 1,0 0)")
  135. );
  136. tester::apply
  137. ("mpmpu03",
  138. from_wkt<MP>("MULTIPOINT()"),
  139. from_wkt<MP>("MULTIPOINT(1 0,0 0,1 1,0 0)"),
  140. from_wkt<MP>("MULTIPOINT(1 0,0 0,1 1,0 0)")
  141. );
  142. tester::apply
  143. ("mpmpu04",
  144. from_wkt<MP>("MULTIPOINT(0 0,1 1,1 0,1 1)"),
  145. from_wkt<MP>("MULTIPOINT()"),
  146. from_wkt<MP>("MULTIPOINT(0 0,1 1,1 0,1 1)")
  147. );
  148. tester::apply
  149. ("mpmpu05",
  150. from_wkt<MP>("MULTIPOINT()"),
  151. from_wkt<MP>("MULTIPOINT()"),
  152. from_wkt<MP>("MULTIPOINT()")
  153. );
  154. tester::apply
  155. ("mpmpu06",
  156. from_wkt<MP>("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0)"),
  157. from_wkt<MP>("MULTIPOINT(0 1,0 2,1 0,0 0,2 0)"),
  158. from_wkt<MP>("MULTIPOINT(0 0,1 0,2 0,3 0,0 0,1 0,2 0,0 1,0 2)"),
  159. from_wkt<MP>("MULTIPOINT(0 1,0 2,1 0,0 0,2 0,3 0)")
  160. );
  161. }