distance.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
  6. // This file was modified by Oracle on 2014-2021.
  7. // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Use, modification and distribution is subject to the Boost Software License,
  13. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #ifndef BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP
  16. #define BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP
  17. #include <boost/geometry/algorithms/not_implemented.hpp>
  18. #include <boost/geometry/core/reverse_dispatch.hpp>
  19. #include <boost/geometry/core/tag.hpp>
  20. #include <boost/geometry/core/tag_cast.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. #include <boost/geometry/strategies/detail.hpp>
  23. #include <boost/geometry/strategies/distance.hpp>
  24. #include <boost/geometry/strategies/distance/services.hpp>
  25. namespace boost { namespace geometry
  26. {
  27. #ifndef DOXYGEN_NO_DISPATCH
  28. namespace dispatch
  29. {
  30. template
  31. <
  32. typename Geometry1, typename Geometry2, typename Strategies,
  33. bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategies>::value,
  34. bool Reverse = reverse_dispatch<Geometry1, Geometry2>::value
  35. >
  36. struct distance_strategy_type
  37. {
  38. typedef decltype(std::declval<Strategies>().distance(std::declval<Geometry1>(), std::declval<Geometry2>())) type;
  39. };
  40. // TODO: right now legacy single strategy can be passed here in some cases
  41. // so for now dispatch also by IsUmbrella. Later this could be removed.
  42. template <typename Geometry1, typename Geometry2, typename Strategy, bool Reverse>
  43. struct distance_strategy_type<Geometry1, Geometry2, Strategy, false, Reverse>
  44. {
  45. typedef Strategy type;
  46. };
  47. template <typename Geometry1, typename Geometry2, typename Strategies>
  48. struct distance_strategy_type<Geometry1, Geometry2, Strategies, true, true>
  49. : distance_strategy_type<Geometry2, Geometry1, Strategies, true, false>
  50. {};
  51. template
  52. <
  53. typename Geometry1, typename Geometry2, typename Strategies,
  54. bool IsDynamicOrGC = util::is_dynamic_geometry<Geometry1>::value
  55. || util::is_dynamic_geometry<Geometry2>::value
  56. || util::is_geometry_collection<Geometry1>::value
  57. || util::is_geometry_collection<Geometry2>::value
  58. >
  59. struct distance_strategy_tag
  60. {
  61. using type = void;
  62. };
  63. template <typename Geometry1, typename Geometry2, typename Strategies>
  64. struct distance_strategy_tag<Geometry1, Geometry2, Strategies, false>
  65. {
  66. using type = typename strategy::distance::services::tag
  67. <
  68. typename distance_strategy_type<Geometry1, Geometry2, Strategies>::type
  69. >::type;
  70. };
  71. template
  72. <
  73. typename Geometry1, typename Geometry2,
  74. typename Strategy = typename strategies::distance::services::default_strategy
  75. <
  76. Geometry1, Geometry2
  77. >::type,
  78. typename Tag1 = typename tag_cast
  79. <
  80. typename tag<Geometry1>::type,
  81. segment_tag,
  82. box_tag,
  83. linear_tag,
  84. areal_tag
  85. >::type,
  86. typename Tag2 = typename tag_cast
  87. <
  88. typename tag<Geometry2>::type,
  89. segment_tag,
  90. box_tag,
  91. linear_tag,
  92. areal_tag
  93. >::type,
  94. typename StrategyTag = typename distance_strategy_tag
  95. <
  96. Geometry1, Geometry2, Strategy
  97. >::type,
  98. bool Reverse = reverse_dispatch<Geometry1, Geometry2>::value
  99. >
  100. struct distance : not_implemented<Tag1, Tag2>
  101. {};
  102. } // namespace dispatch
  103. #endif // DOXYGEN_NO_DISPATCH
  104. }} // namespace boost::geometry
  105. #endif // BOOST_GEOMETRY_ALGORITHMS_DISPATCH_DISTANCE_HPP