File indexing completed on 2025-01-18 09:36:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef BOOST_GEOMETRY_SRS_SPHERE_HPP
0020 #define BOOST_GEOMETRY_SRS_SPHERE_HPP
0021
0022
0023 #include <cstddef>
0024
0025 #include <boost/static_assert.hpp>
0026
0027 #include <boost/geometry/core/radius.hpp>
0028 #include <boost/geometry/core/tag.hpp>
0029 #include <boost/geometry/core/tags.hpp>
0030
0031
0032 namespace boost { namespace geometry
0033 {
0034
0035 namespace srs
0036 {
0037
0038
0039
0040
0041
0042
0043 template <typename RadiusType>
0044 class sphere
0045 {
0046 public:
0047 explicit sphere(RadiusType const& r)
0048 : m_r(r)
0049 {}
0050
0051 sphere()
0052 : m_r(RadiusType((2.0 * 6378137.0 + 6356752.3142451793) / 3.0))
0053 {}
0054
0055 template <std::size_t I>
0056 RadiusType get_radius() const
0057 {
0058 BOOST_STATIC_ASSERT(I < 3);
0059
0060 return m_r;
0061 }
0062
0063 template <std::size_t I>
0064 void set_radius(RadiusType const& radius)
0065 {
0066 BOOST_STATIC_ASSERT(I < 3);
0067
0068 m_r = radius;
0069 }
0070
0071 private:
0072 RadiusType m_r;
0073 };
0074
0075 }
0076
0077
0078 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0079 namespace traits
0080 {
0081
0082 template <typename RadiusType>
0083 struct tag< srs::sphere<RadiusType> >
0084 {
0085 typedef srs_sphere_tag type;
0086 };
0087
0088 template <typename RadiusType>
0089 struct radius_type< srs::sphere<RadiusType> >
0090 {
0091 typedef RadiusType type;
0092 };
0093
0094 template <typename RadiusType, std::size_t Dimension>
0095 struct radius_access<srs::sphere<RadiusType>, Dimension>
0096 {
0097 typedef srs::sphere<RadiusType> sphere_type;
0098
0099 static inline RadiusType get(sphere_type const& s)
0100 {
0101 return s.template get_radius<Dimension>();
0102 }
0103
0104 static inline void set(sphere_type& s, RadiusType const& value)
0105 {
0106 s.template set_radius<Dimension>(value);
0107 }
0108 };
0109
0110 }
0111 #endif
0112
0113
0114 }}
0115
0116
0117 #endif