123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #ifndef BOOST_GEOMETRY_SRS_SPHEROID_HPP
- #define BOOST_GEOMETRY_SRS_SPHEROID_HPP
- #include <cstddef>
- #include <boost/static_assert.hpp>
- #include <boost/geometry/core/radius.hpp>
- #include <boost/geometry/core/tag.hpp>
- #include <boost/geometry/core/tags.hpp>
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- #include <boost/geometry/core/assert.hpp>
- #endif
- namespace boost { namespace geometry
- {
- namespace srs
- {
- template <typename RadiusType>
- class spheroid
- {
- public:
- spheroid(RadiusType const& a, RadiusType const& b)
- : m_a(a)
- , m_b(b)
- {
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- m_created = 1;
- #endif
- }
- spheroid()
- : m_a(RadiusType(6378137.0))
- , m_b(RadiusType(6356752.3142451793))
- {
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- m_created = 1;
- #endif
- }
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- ~spheroid()
- {
- m_created = 0;
- }
- #endif
- template <std::size_t I>
- RadiusType get_radius() const
- {
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- if (m_created != 1)
- {
- int a = 10;
- }
- BOOST_GEOMETRY_ASSERT(m_created == 1);
- #endif
- BOOST_STATIC_ASSERT(I < 3);
- return I < 2 ? m_a : m_b;
- }
- template <std::size_t I>
- void set_radius(RadiusType const& radius)
- {
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- BOOST_GEOMETRY_ASSERT(m_created == 1);
- #endif
- BOOST_STATIC_ASSERT(I < 3);
- (I < 2 ? m_a : m_b) = radius;
- }
- private:
- RadiusType m_a, m_b;
- #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
- int m_created;
- #endif
- };
- }
- #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
- namespace traits
- {
- template <typename RadiusType>
- struct tag< srs::spheroid<RadiusType> >
- {
- typedef srs_spheroid_tag type;
- };
- template <typename RadiusType>
- struct radius_type< srs::spheroid<RadiusType> >
- {
- typedef RadiusType type;
- };
- template <typename RadiusType, std::size_t Dimension>
- struct radius_access<srs::spheroid<RadiusType>, Dimension>
- {
- typedef srs::spheroid<RadiusType> spheroid_type;
- static inline RadiusType get(spheroid_type const& s)
- {
- return s.template get_radius<Dimension>();
- }
- static inline void set(spheroid_type& s, RadiusType const& value)
- {
- s.template set_radius<Dimension>(value);
- }
- };
- }
- #endif
- }}
- #endif
|