]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/spheroid.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / geometry / srs / spheroid.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
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.
6
7 // This file was modified by Oracle on 2014, 2016, 2017, 2018.
8 // Modifications copyright (c) 2014-2018 Oracle and/or its affiliates.
9
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
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)
18
19 #ifndef BOOST_GEOMETRY_SRS_SPHEROID_HPP
20 #define BOOST_GEOMETRY_SRS_SPHEROID_HPP
21
22
23 #include <cstddef>
24
25 #include <boost/static_assert.hpp>
26
27 #include <boost/geometry/core/radius.hpp>
28 #include <boost/geometry/core/tag.hpp>
29 #include <boost/geometry/core/tags.hpp>
30
31
32 namespace boost { namespace geometry
33 {
34
35 namespace srs
36 {
37
38 /*!
39 \brief Defines spheroid radius values for use in geographical CS calculations
40 \ingroup srs
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
44 */
45 template <typename RadiusType>
46 class spheroid
47 {
48 public:
49 spheroid(RadiusType const& a, RadiusType const& b)
50 : m_a(a)
51 , m_b(b)
52 {}
53
54 spheroid()
55 : m_a(RadiusType(6378137.0))
56 , m_b(RadiusType(6356752.3142451793))
57 {}
58
59 template <std::size_t I>
60 RadiusType get_radius() const
61 {
62 BOOST_STATIC_ASSERT(I < 3);
63
64 return I < 2 ? m_a : m_b;
65 }
66
67 template <std::size_t I>
68 void set_radius(RadiusType const& radius)
69 {
70 BOOST_STATIC_ASSERT(I < 3);
71
72 (I < 2 ? m_a : m_b) = radius;
73 }
74
75 private:
76 RadiusType m_a, m_b; // equatorial radius, polar radius
77 };
78
79 } // namespace srs
80
81 // Traits specializations for spheroid
82 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
83 namespace traits
84 {
85
86 template <typename RadiusType>
87 struct tag< srs::spheroid<RadiusType> >
88 {
89 typedef srs_spheroid_tag type;
90 };
91
92 template <typename RadiusType>
93 struct radius_type< srs::spheroid<RadiusType> >
94 {
95 typedef RadiusType type;
96 };
97
98 template <typename RadiusType, std::size_t Dimension>
99 struct radius_access<srs::spheroid<RadiusType>, Dimension>
100 {
101 typedef srs::spheroid<RadiusType> spheroid_type;
102
103 static inline RadiusType get(spheroid_type const& s)
104 {
105 return s.template get_radius<Dimension>();
106 }
107
108 static inline void set(spheroid_type& s, RadiusType const& value)
109 {
110 s.template set_radius<Dimension>(value);
111 }
112 };
113
114 } // namespace traits
115 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
116
117
118 }} // namespace boost::geometry
119
120
121 #endif // BOOST_GEOMETRY_SRS_SPHEROID_HPP