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_SPHEROID_HPP
0020 #define BOOST_GEOMETRY_SRS_SPHEROID_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 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0032 #include <boost/geometry/core/assert.hpp>
0033 #endif
0034
0035
0036 namespace boost { namespace geometry
0037 {
0038
0039 namespace srs
0040 {
0041
0042
0043
0044
0045
0046
0047
0048
0049 template <typename RadiusType>
0050 class spheroid
0051 {
0052 public:
0053 spheroid(RadiusType const& a, RadiusType const& b)
0054 : m_a(a)
0055 , m_b(b)
0056 {
0057 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0058 m_created = 1;
0059 #endif
0060 }
0061
0062 spheroid()
0063 : m_a(RadiusType(6378137.0))
0064 , m_b(RadiusType(6356752.3142451793))
0065 {
0066 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0067 m_created = 1;
0068 #endif
0069 }
0070
0071 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0072 ~spheroid()
0073 {
0074 m_created = 0;
0075 }
0076 #endif
0077
0078 template <std::size_t I>
0079 RadiusType get_radius() const
0080 {
0081 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0082 if (m_created != 1)
0083 {
0084 int a = 10;
0085 }
0086 BOOST_GEOMETRY_ASSERT(m_created == 1);
0087 #endif
0088
0089 BOOST_STATIC_ASSERT(I < 3);
0090
0091 return I < 2 ? m_a : m_b;
0092 }
0093
0094 template <std::size_t I>
0095 void set_radius(RadiusType const& radius)
0096 {
0097 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0098 BOOST_GEOMETRY_ASSERT(m_created == 1);
0099 #endif
0100
0101 BOOST_STATIC_ASSERT(I < 3);
0102
0103 (I < 2 ? m_a : m_b) = radius;
0104 }
0105
0106 private:
0107 RadiusType m_a, m_b;
0108
0109 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0110 int m_created;
0111 #endif
0112 };
0113
0114 }
0115
0116
0117 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0118 namespace traits
0119 {
0120
0121 template <typename RadiusType>
0122 struct tag< srs::spheroid<RadiusType> >
0123 {
0124 typedef srs_spheroid_tag type;
0125 };
0126
0127 template <typename RadiusType>
0128 struct radius_type< srs::spheroid<RadiusType> >
0129 {
0130 typedef RadiusType type;
0131 };
0132
0133 template <typename RadiusType, std::size_t Dimension>
0134 struct radius_access<srs::spheroid<RadiusType>, Dimension>
0135 {
0136 typedef srs::spheroid<RadiusType> spheroid_type;
0137
0138 static inline RadiusType get(spheroid_type const& s)
0139 {
0140 return s.template get_radius<Dimension>();
0141 }
0142
0143 static inline void set(spheroid_type& s, RadiusType const& value)
0144 {
0145 s.template set_radius<Dimension>(value);
0146 }
0147 };
0148
0149 }
0150 #endif
0151
0152
0153 }}
0154
0155
0156 #endif