geographic.hpp 3.4 KB

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