cartesian.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Boost.Geometry
  2. // Copyright (c) 2021, 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_STRATEGIES_DISCRETE_DISTANCE_CARTESIAN_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_DISCRETE_DISTANCE_CARTESIAN_HPP
  8. #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
  9. #include <boost/geometry/strategies/detail.hpp>
  10. #include <boost/geometry/strategies/discrete_distance/services.hpp>
  11. #include <boost/geometry/strategies/distance/comparable.hpp>
  12. #include <boost/geometry/strategies/distance/detail.hpp>
  13. #include <boost/geometry/util/type_traits.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. namespace strategies { namespace discrete_distance
  17. {
  18. template <typename CalculationType = void>
  19. struct cartesian
  20. : public strategies::detail::cartesian_base
  21. {
  22. template <typename Geometry1, typename Geometry2>
  23. static auto distance(Geometry1 const&, Geometry2 const&,
  24. distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr)
  25. {
  26. return strategy::distance::pythagoras<CalculationType>();
  27. }
  28. };
  29. namespace services
  30. {
  31. template <typename Geometry1, typename Geometry2>
  32. struct default_strategy<Geometry1, Geometry2, cartesian_tag, cartesian_tag>
  33. {
  34. using type = strategies::discrete_distance::cartesian<>;
  35. };
  36. template <typename CT>
  37. struct strategy_converter<strategy::distance::pythagoras<CT> >
  38. {
  39. static auto get(strategy::distance::pythagoras<CT> const&)
  40. {
  41. return strategies::discrete_distance::cartesian<CT>();
  42. }
  43. };
  44. template <typename CT>
  45. struct strategy_converter<strategy::distance::comparable::pythagoras<CT> >
  46. {
  47. static auto get(strategy::distance::comparable::pythagoras<CT> const&)
  48. {
  49. return strategies::distance::detail::make_comparable(
  50. strategies::discrete_distance::cartesian<CT>());
  51. }
  52. };
  53. } // namespace services
  54. }} // namespace strategies::discrete_distance
  55. }} // namespace boost::geometry
  56. #endif // BOOST_GEOMETRY_STRATEGIES_DISCRETE_DISTANCE_CARTESIAN_HPP