test_relops.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Boost.Geometry
  2. // Copyright (c) 2019, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_TEST_CS_UNDEFINED_TEST_RELOPS_HPP
  7. #define BOOST_GEOMETRY_TEST_CS_UNDEFINED_TEST_RELOPS_HPP
  8. #include "common.hpp"
  9. #include <boost/geometry/algorithms/covered_by.hpp>
  10. #include <boost/geometry/algorithms/crosses.hpp>
  11. #include <boost/geometry/algorithms/disjoint.hpp>
  12. #include <boost/geometry/algorithms/equals.hpp>
  13. #include <boost/geometry/algorithms/intersects.hpp>
  14. #include <boost/geometry/algorithms/overlaps.hpp>
  15. #include <boost/geometry/algorithms/relate.hpp>
  16. #include <boost/geometry/algorithms/relation.hpp>
  17. #include <boost/geometry/algorithms/touches.hpp>
  18. #include <boost/geometry/algorithms/within.hpp>
  19. template
  20. <
  21. typename G1,
  22. typename G2,
  23. std::size_t Dim1 = bg::topological_dimension<G1>::value,
  24. std::size_t Dim2 = bg::topological_dimension<G2>::value
  25. >
  26. struct call_equals
  27. {
  28. template <typename S>
  29. static void apply(G1 const& g1, G2 const& g2, S const& s) {}
  30. };
  31. template <typename G1, typename G2, std::size_t Dim>
  32. struct call_equals<G1, G2, Dim, Dim>
  33. {
  34. template <typename S>
  35. static void apply(G1 const& g1, G2 const& g2, S const& s)
  36. {
  37. bg::equals(g1, g2, s);
  38. }
  39. };
  40. template
  41. <
  42. typename G1,
  43. typename G2,
  44. std::size_t Dim1 = bg::topological_dimension<G1>::value,
  45. std::size_t Dim2 = bg::topological_dimension<G2>::value
  46. >
  47. struct call_overlaps
  48. {
  49. template <typename S>
  50. static void apply(G1 const& g1, G2 const& g2, S const& s) {}
  51. };
  52. template <typename G1, typename G2, std::size_t Dim>
  53. struct call_overlaps<G1, G2, Dim, Dim>
  54. {
  55. template <typename S>
  56. static void apply(G1 const& g1, G2 const& g2, S const& s)
  57. {
  58. bg::overlaps(g1, g2, s);
  59. }
  60. };
  61. template
  62. <
  63. typename G1,
  64. typename G2,
  65. std::size_t Dim1 = bg::topological_dimension<G1>::value,
  66. std::size_t Dim2 = bg::topological_dimension<G2>::value
  67. >
  68. struct call_touches
  69. {
  70. template <typename S>
  71. static void apply(G1 const& g1, G2 const& g2, S const& s)
  72. {
  73. bg::touches(g1, g2, s);
  74. }
  75. };
  76. template <typename G1, typename G2>
  77. struct call_touches<G1, G2, 0, 0>
  78. {
  79. template <typename S>
  80. static void apply(G1 const& g1, G2 const& g2, S const& s) {}
  81. };
  82. template
  83. <
  84. typename G1,
  85. typename G2,
  86. std::size_t Dim1 = bg::topological_dimension<G1>::value,
  87. std::size_t Dim2 = bg::topological_dimension<G2>::value
  88. >
  89. struct call_crosses
  90. {
  91. template <typename S>
  92. static void apply(G1 const& g1, G2 const& g2, S const& s)
  93. {
  94. bg::crosses(g1, g2, s);
  95. }
  96. };
  97. template <typename G1, typename G2>
  98. struct call_crosses<G1, G2, 0, 0>
  99. {
  100. template <typename S>
  101. static void apply(G1 const& g1, G2 const& g2, S const& s) {}
  102. };
  103. template <typename G1, typename G2>
  104. struct call_crosses<G1, G2, 2, 2>
  105. {
  106. template <typename S>
  107. static void apply(G1 const& g1, G2 const& g2, S const& s) {}
  108. };
  109. template <typename G1, typename G2, typename S>
  110. inline void rel(G1 const& g1, G2 const& g2, S const& s)
  111. {
  112. bg::relation(g1, g2, s);
  113. bg::relate(g1, g2, bg::de9im::mask("*********"), s);
  114. bg::covered_by(g1, g2, s);
  115. call_crosses<G1, G2>::apply(g1, g2, s);
  116. bg::disjoint(g1, g2, s);
  117. call_equals<G1, G2>::apply(g1, g2, s);
  118. bg::intersects(g1, g2, s);
  119. call_overlaps<G1, G2>::apply(g1, g2, s);
  120. call_touches<G1, G2>::apply(g1, g2, s);
  121. bg::within(g1, g2, s);
  122. }
  123. template <typename G1, typename G2>
  124. inline void rel_pp(G1 const& g1, G2 const& g2)
  125. {
  126. ::rel(g1, g2, bg::strategy::within::cartesian_point_point());
  127. ::rel(g1, g2, bg::strategy::within::spherical_point_point());
  128. }
  129. template <typename G1, typename G2>
  130. inline void rel_ps(G1 const& g1, G2 const& g2)
  131. {
  132. typedef typename bg::point_type<G1>::type point;
  133. ::rel(g1, g2, bg::strategy::within::cartesian_winding<point>());
  134. ::rel(g1, g2, bg::strategy::within::spherical_winding<point>());
  135. ::rel(g1, g2, bg::strategy::within::geographic_winding<point>());
  136. }
  137. template <typename G1, typename G2>
  138. inline void rel_ss(G1 const& g1, G2 const& g2)
  139. {
  140. ::rel(g1, g2, bg::strategy::intersection::cartesian_segments<>());
  141. ::rel(g1, g2, bg::strategy::intersection::spherical_segments<>());
  142. ::rel(g1, g2, bg::strategy::intersection::geographic_segments<>());
  143. }
  144. #endif // BOOST_GEOMETRY_TEST_CS_UNDEFINED_TEST_RELOPS_HPP