Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:41

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2014, 2016, 2017, 2018, 2020.
0008 // Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
0009 
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
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     \brief Defines spheroid radius values for use in geographical CS calculations
0044     \ingroup srs
0045     \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth
0046           and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
0047     \tparam RadiusType tparam_radius
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; // equatorial radius, polar radius
0108 
0109 #if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
0110     int m_created;
0111 #endif
0112 };
0113 
0114 } // namespace srs
0115 
0116 // Traits specializations for spheroid
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 } // namespace traits
0150 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0151 
0152 
0153 }} // namespace boost::geometry
0154 
0155 
0156 #endif // BOOST_GEOMETRY_SRS_SPHEROID_HPP