spherical.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Boost.Geometry
  2. // Copyright (c) 2020-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_AREA_SPHERICAL_HPP
  7. #define BOOST_GEOMETRY_STRATEGIES_AREA_SPHERICAL_HPP
  8. #include <boost/geometry/strategy/spherical/area.hpp>
  9. #include <boost/geometry/strategy/spherical/area_box.hpp>
  10. #include <boost/geometry/strategies/area/services.hpp>
  11. #include <boost/geometry/strategies/detail.hpp>
  12. namespace boost { namespace geometry
  13. {
  14. namespace strategies { namespace area
  15. {
  16. template
  17. <
  18. typename RadiusTypeOrSphere = double,
  19. typename CalculationType = void
  20. >
  21. class spherical
  22. : public strategies::detail::spherical_base<RadiusTypeOrSphere>
  23. {
  24. using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
  25. public:
  26. spherical()
  27. : base_t()
  28. {}
  29. template <typename RadiusOrSphere>
  30. explicit spherical(RadiusOrSphere const& radius_or_sphere)
  31. : base_t(radius_or_sphere)
  32. {}
  33. template <typename Geometry>
  34. auto area(Geometry const&,
  35. std::enable_if_t<! util::is_box<Geometry>::value> * = nullptr) const
  36. {
  37. return strategy::area::spherical
  38. <
  39. typename base_t::radius_type, CalculationType
  40. >(base_t::m_radius);
  41. }
  42. template <typename Geometry>
  43. auto area(Geometry const&,
  44. std::enable_if_t<util::is_box<Geometry>::value> * = nullptr) const
  45. {
  46. return strategy::area::spherical_box
  47. <
  48. typename base_t::radius_type, CalculationType
  49. >(base_t::m_radius);
  50. }
  51. };
  52. namespace services
  53. {
  54. template <typename Geometry>
  55. struct default_strategy<Geometry, spherical_tag>
  56. {
  57. using type = strategies::area::spherical<>;
  58. };
  59. template <typename Geometry>
  60. struct default_strategy<Geometry, spherical_equatorial_tag>
  61. {
  62. using type = strategies::area::spherical<>;
  63. };
  64. template <typename Geometry>
  65. struct default_strategy<Geometry, spherical_polar_tag>
  66. {
  67. using type = strategies::area::spherical<>;
  68. };
  69. template <typename R, typename CT>
  70. struct strategy_converter<strategy::area::spherical<R, CT> >
  71. {
  72. static auto get(strategy::area::spherical<R, CT> const& strategy)
  73. {
  74. return strategies::area::spherical<R, CT>(strategy.model());
  75. }
  76. };
  77. } // namespace services
  78. }} // namespace strategies::area
  79. }} // namespace boost::geometry
  80. #endif // BOOST_GEOMETRY_STRATEGIES_AREA_SPHERICAL_HPP