cartesian.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_LENGTH_CARTESIAN_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_LENGTH_CARTESIAN_HPP
  8. #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
  9. #include <boost/geometry/strategies/detail.hpp>
  10. #include <boost/geometry/strategies/distance/detail.hpp>
  11. #include <boost/geometry/strategies/length/services.hpp>
  12. #include <boost/geometry/util/type_traits.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. namespace strategies { namespace length
  16. {
  17. template <typename CalculationType = void>
  18. struct cartesian
  19. : public strategies::detail::cartesian_base
  20. {
  21. template <typename Geometry1, typename Geometry2>
  22. static auto distance(Geometry1 const&, Geometry2 const&,
  23. distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr)
  24. {
  25. return strategy::distance::pythagoras<CalculationType>();
  26. }
  27. };
  28. namespace services
  29. {
  30. template <typename Geometry>
  31. struct default_strategy<Geometry, cartesian_tag>
  32. {
  33. using type = strategies::length::cartesian<>;
  34. };
  35. template <typename CT>
  36. struct strategy_converter<strategy::distance::pythagoras<CT> >
  37. {
  38. static auto get(strategy::distance::pythagoras<CT> const&)
  39. {
  40. return strategies::length::cartesian<CT>();
  41. }
  42. };
  43. } // namespace services
  44. }} // namespace strategies::length
  45. }} // namespace boost::geometry
  46. #endif // BOOST_GEOMETRY_STRATEGIES_LENGTH_CARTESIAN_HPP