geographic.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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_GEOGRAPHIC_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_LENGTH_GEOGRAPHIC_HPP
  8. #include <boost/geometry/strategies/detail.hpp>
  9. #include <boost/geometry/strategies/distance/detail.hpp>
  10. #include <boost/geometry/strategies/length/services.hpp>
  11. #include <boost/geometry/strategies/geographic/distance.hpp>
  12. // TODO - for backwards compatibility, remove?
  13. #include <boost/geometry/strategies/geographic/distance_andoyer.hpp>
  14. #include <boost/geometry/strategies/geographic/distance_thomas.hpp>
  15. #include <boost/geometry/strategies/geographic/distance_vincenty.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. namespace strategies { namespace length
  19. {
  20. template
  21. <
  22. typename FormulaPolicy = strategy::andoyer,
  23. typename Spheroid = srs::spheroid<double>,
  24. typename CalculationType = void
  25. >
  26. class geographic
  27. : public strategies::detail::geographic_base<Spheroid>
  28. {
  29. using base_t = strategies::detail::geographic_base<Spheroid>;
  30. public:
  31. geographic() = default;
  32. explicit geographic(Spheroid const& spheroid)
  33. : base_t(spheroid)
  34. {}
  35. template <typename Geometry1, typename Geometry2>
  36. auto distance(Geometry1 const&, Geometry2 const&,
  37. distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
  38. {
  39. return strategy::distance::geographic
  40. <
  41. FormulaPolicy, Spheroid, CalculationType
  42. >(base_t::m_spheroid);
  43. }
  44. };
  45. namespace services
  46. {
  47. template <typename Geometry>
  48. struct default_strategy<Geometry, geographic_tag>
  49. {
  50. using type = strategies::length::geographic<>;
  51. };
  52. template <typename FP, typename S, typename CT>
  53. struct strategy_converter<strategy::distance::geographic<FP, S, CT> >
  54. {
  55. static auto get(strategy::distance::geographic<FP, S, CT> const& s)
  56. {
  57. return strategies::length::geographic<FP, S, CT>(s.model());
  58. }
  59. };
  60. // TODO - for backwards compatibility, remove?
  61. template <typename S, typename CT>
  62. struct strategy_converter<strategy::distance::andoyer<S, CT> >
  63. {
  64. static auto get(strategy::distance::andoyer<S, CT> const& s)
  65. {
  66. return strategies::length::geographic<strategy::andoyer, S, CT>(s.model());
  67. }
  68. };
  69. // TODO - for backwards compatibility, remove?
  70. template <typename S, typename CT>
  71. struct strategy_converter<strategy::distance::thomas<S, CT> >
  72. {
  73. static auto get(strategy::distance::thomas<S, CT> const& s)
  74. {
  75. return strategies::length::geographic<strategy::thomas, S, CT>(s.model());
  76. }
  77. };
  78. // TODO - for backwards compatibility, remove?
  79. template <typename S, typename CT>
  80. struct strategy_converter<strategy::distance::vincenty<S, CT> >
  81. {
  82. static auto get(strategy::distance::vincenty<S, CT> const& s)
  83. {
  84. return strategies::length::geographic<strategy::vincenty, S, CT>(s.model());
  85. }
  86. };
  87. } // namespace services
  88. }} // namespace strategies::length
  89. }} // namespace boost::geometry
  90. #endif // BOOST_GEOMETRY_STRATEGIES_LENGTH_GEOGRAPHIC_HPP