linear_or_areal_to_areal.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2014, 2019, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, 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_ALGORITHMS_DETAIL_DISTANCE_LINEAR_OR_AREAL_TO_AREAL_HPP
  8. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_OR_AREAL_TO_AREAL_HPP
  9. #include <boost/geometry/core/point_type.hpp>
  10. #include <boost/geometry/strategies/distance.hpp>
  11. #include <boost/geometry/algorithms/intersects.hpp>
  12. #include <boost/geometry/algorithms/detail/distance/linear_to_linear.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. #ifndef DOXYGEN_NO_DETAIL
  16. namespace detail { namespace distance
  17. {
  18. template <typename Linear, typename Areal, typename Strategy>
  19. struct linear_to_areal
  20. {
  21. typedef typename strategy::distance::services::return_type
  22. <
  23. Strategy,
  24. typename point_type<Linear>::type,
  25. typename point_type<Areal>::type
  26. >::type return_type;
  27. static inline return_type apply(Linear const& linear,
  28. Areal const& areal,
  29. Strategy const& strategy)
  30. {
  31. if ( geometry::intersects(linear, areal,
  32. strategy.get_relate_segment_segment_strategy()) )
  33. {
  34. return 0;
  35. }
  36. return linear_to_linear
  37. <
  38. Linear, Areal, Strategy
  39. >::apply(linear, areal, strategy, false);
  40. }
  41. static inline return_type apply(Areal const& areal,
  42. Linear const& linear,
  43. Strategy const& strategy)
  44. {
  45. return apply(linear, areal, strategy);
  46. }
  47. };
  48. template <typename Areal1, typename Areal2, typename Strategy>
  49. struct areal_to_areal
  50. {
  51. typedef typename strategy::distance::services::return_type
  52. <
  53. Strategy,
  54. typename point_type<Areal1>::type,
  55. typename point_type<Areal2>::type
  56. >::type return_type;
  57. static inline return_type apply(Areal1 const& areal1,
  58. Areal2 const& areal2,
  59. Strategy const& strategy)
  60. {
  61. if ( geometry::intersects(areal1, areal2,
  62. strategy.get_relate_segment_segment_strategy()) )
  63. {
  64. return 0;
  65. }
  66. return linear_to_linear
  67. <
  68. Areal1, Areal2, Strategy
  69. >::apply(areal1, areal2, strategy, false);
  70. }
  71. };
  72. }} // namespace detail::distance
  73. #endif // DOXYGEN_NO_DETAIL
  74. #ifndef DOXYGEN_NO_DISPATCH
  75. namespace dispatch
  76. {
  77. template <typename Linear, typename Areal, typename Strategy>
  78. struct distance
  79. <
  80. Linear, Areal, Strategy,
  81. linear_tag, areal_tag,
  82. strategy_tag_distance_point_segment, false
  83. >
  84. : detail::distance::linear_to_areal
  85. <
  86. Linear, Areal, Strategy
  87. >
  88. {};
  89. template <typename Areal, typename Linear, typename Strategy>
  90. struct distance
  91. <
  92. Areal, Linear, Strategy,
  93. areal_tag, linear_tag,
  94. strategy_tag_distance_point_segment, false
  95. >
  96. : detail::distance::linear_to_areal
  97. <
  98. Linear, Areal, Strategy
  99. >
  100. {};
  101. template <typename Areal1, typename Areal2, typename Strategy>
  102. struct distance
  103. <
  104. Areal1, Areal2, Strategy,
  105. areal_tag, areal_tag,
  106. strategy_tag_distance_point_segment, false
  107. >
  108. : detail::distance::areal_to_areal
  109. <
  110. Areal1, Areal2, Strategy
  111. >
  112. {};
  113. } // namespace dispatch
  114. #endif // DOXYGEN_NO_DISPATCH
  115. }} // namespace boost::geometry
  116. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_LINEAR_OR_AREAL_TO_AREAL_HPP