get_radius.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
  3. // Copyright (c) 2016-2018 Oracle and/or its affiliates.
  4. // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_GET_RADIUS_HPP
  10. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_GET_RADIUS_HPP
  11. #include <boost/geometry/core/coordinate_type.hpp>
  12. #include <boost/geometry/core/radius.hpp>
  13. #include <boost/geometry/core/tag.hpp>
  14. #include <boost/geometry/core/tags.hpp>
  15. #include <boost/geometry/util/select_most_precise.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace strategy_detail
  20. {
  21. template
  22. <
  23. typename RadiusTypeOrSphere,
  24. typename Tag = typename tag<RadiusTypeOrSphere>::type
  25. >
  26. struct get_radius
  27. {
  28. typedef typename geometry::radius_type<RadiusTypeOrSphere>::type type;
  29. static type apply(RadiusTypeOrSphere const& sphere)
  30. {
  31. return geometry::get_radius<0>(sphere);
  32. }
  33. };
  34. template <typename RadiusTypeOrSphere>
  35. struct get_radius<RadiusTypeOrSphere, void>
  36. {
  37. typedef RadiusTypeOrSphere type;
  38. static type apply(RadiusTypeOrSphere const& radius)
  39. {
  40. return radius;
  41. }
  42. };
  43. // For backward compatibility
  44. template <typename Point>
  45. struct get_radius<Point, point_tag>
  46. {
  47. typedef typename select_most_precise
  48. <
  49. typename coordinate_type<Point>::type,
  50. double
  51. >::type type;
  52. template <typename RadiusOrSphere>
  53. static typename get_radius<RadiusOrSphere>::type
  54. apply(RadiusOrSphere const& radius_or_sphere)
  55. {
  56. return get_radius<RadiusOrSphere>::apply(radius_or_sphere);
  57. }
  58. };
  59. } // namespace strategy_detail
  60. #endif // DOXYGEN_NO_DETAIL
  61. }} // namespace boost::geometry
  62. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_GET_RADIUS_HPP