spherical.hpp 2.1 KB

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