overlaps_sph.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // Boost.Geometry
  2. // Copyright (c) 2016 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include "test_overlaps.hpp"
  8. #include <algorithms/overlay/overlay_cases.hpp>
  9. #include <algorithms/overlay/multi_overlay_cases.hpp>
  10. #include <boost/geometry/geometries/geometries.hpp>
  11. template <typename P>
  12. void test_polygon_polygon()
  13. {
  14. typedef bg::model::polygon<P> poly;
  15. typedef bg::model::ring<P> ring;
  16. test_geometry<ring, ring>(case_1[0], case_1[1],
  17. true);
  18. test_geometry<ring, poly>(case_1[0], case_1[1],
  19. true);
  20. test_geometry<poly, poly>(case_1[0], case_1[1],
  21. true);
  22. test_geometry<poly, poly>(case_2[0], case_2[1],
  23. true);
  24. test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
  25. false);
  26. test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
  27. false);
  28. test_geometry<poly, poly>(case_4[0], case_4[1],
  29. true);
  30. test_geometry<poly, poly>(case_5[0], case_5[1],
  31. true);
  32. test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
  33. false);
  34. test_geometry<poly, poly>(case_7[0], case_7[1],
  35. false);
  36. test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
  37. false);
  38. test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
  39. false);
  40. test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
  41. false);
  42. test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
  43. false);
  44. test_geometry<poly, poly>(case_12[0], case_12[1],
  45. true);
  46. test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
  47. false);
  48. test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
  49. false);
  50. test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
  51. false);
  52. test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
  53. false);
  54. test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
  55. false);
  56. test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
  57. false);
  58. }
  59. template <typename P>
  60. void test_polygon_multi_polygon()
  61. {
  62. typedef bg::model::polygon<P> poly;
  63. typedef bg::model::ring<P> ring;
  64. typedef bg::model::multi_polygon<poly> mpoly;
  65. test_geometry<ring, mpoly>(case_1[0], case_multi_2[0],
  66. true);
  67. test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
  68. true);
  69. }
  70. template <typename P>
  71. void test_multi_polygon_multi_polygon()
  72. {
  73. typedef bg::model::polygon<P> poly;
  74. typedef bg::model::multi_polygon<poly> mpoly;
  75. test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1],
  76. true);
  77. }
  78. template <typename P>
  79. void test_linestring_linestring()
  80. {
  81. typedef bg::model::linestring<P> ls;
  82. test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", false);
  83. test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false);
  84. }
  85. template <typename P>
  86. void test_linestring_multi_linestring()
  87. {
  88. typedef bg::model::linestring<P> ls;
  89. typedef bg::model::multi_linestring<ls> mls;
  90. test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
  91. "MULTILINESTRING((1 0,2 0),(1 1,2 1))",
  92. true);
  93. test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
  94. "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))",
  95. false);
  96. }
  97. template <typename P>
  98. void test_multi_linestring_multi_linestring()
  99. {
  100. typedef bg::model::linestring<P> ls;
  101. typedef bg::model::multi_linestring<ls> mls;
  102. test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))",
  103. "MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))",
  104. true);
  105. }
  106. template <typename P>
  107. void test_all()
  108. {
  109. test_polygon_polygon<P>();
  110. test_polygon_multi_polygon<P>();
  111. test_multi_polygon_multi_polygon<P>();
  112. test_linestring_linestring<P>();
  113. test_linestring_multi_linestring<P>();
  114. test_multi_linestring_multi_linestring<P>();
  115. }
  116. int test_main( int , char* [] )
  117. {
  118. test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
  119. #if defined(HAVE_TTMATH)
  120. test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
  121. #endif
  122. return 0;
  123. }