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, 2018.
0008 // Modifications copyright (c) 2014-2018 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_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     \brief Defines sphere radius value for use in spherical CS calculations
0040     \ingroup srs
0041     \tparam RadiusType tparam_radius
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; // radius
0073 };
0074 
0075 } // namespace srs
0076 
0077 // Traits specializations for sphere
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 } // namespace traits
0111 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0112 
0113 
0114 }} // namespace boost::geometry
0115 
0116 
0117 #endif // BOOST_GEOMETRY_SRS_SPHERE_HPP