1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2014, 2016, 2017, 2018.
8 // Modifications copyright (c) 2014-2018 Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_SRS_SPHEROID_HPP
20 #define BOOST_GEOMETRY_SRS_SPHEROID_HPP
25 #include <boost/static_assert.hpp>
27 #include <boost/geometry/core/radius.hpp>
28 #include <boost/geometry/core/tag.hpp>
29 #include <boost/geometry/core/tags.hpp>
32 namespace boost { namespace geometry
39 \brief Defines spheroid radius values for use in geographical CS calculations
41 \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth
42 and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
43 \tparam RadiusType tparam_radius
45 template <typename RadiusType>
49 spheroid(RadiusType const& a, RadiusType const& b)
55 : m_a(RadiusType(6378137.0))
56 , m_b(RadiusType(6356752.3142451793))
59 template <std::size_t I>
60 RadiusType get_radius() const
62 BOOST_STATIC_ASSERT(I < 3);
64 return I < 2 ? m_a : m_b;
67 template <std::size_t I>
68 void set_radius(RadiusType const& radius)
70 BOOST_STATIC_ASSERT(I < 3);
72 (I < 2 ? m_a : m_b) = radius;
76 RadiusType m_a, m_b; // equatorial radius, polar radius
81 // Traits specializations for spheroid
82 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
86 template <typename RadiusType>
87 struct tag< srs::spheroid<RadiusType> >
89 typedef srs_spheroid_tag type;
92 template <typename RadiusType>
93 struct radius_type< srs::spheroid<RadiusType> >
95 typedef RadiusType type;
98 template <typename RadiusType, std::size_t Dimension>
99 struct radius_access<srs::spheroid<RadiusType>, Dimension>
101 typedef srs::spheroid<RadiusType> spheroid_type;
103 static inline RadiusType get(spheroid_type const& s)
105 return s.template get_radius<Dimension>();
108 static inline void set(spheroid_type& s, RadiusType const& value)
110 s.template set_radius<Dimension>(value);
114 } // namespace traits
115 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
118 }} // namespace boost::geometry
121 #endif // BOOST_GEOMETRY_SRS_SPHEROID_HPP