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.
8 // Modifications copyright (c) 2014-2017 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_CORE_SRS_HPP
20 #define BOOST_GEOMETRY_CORE_SRS_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
40 \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth
41 and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
43 template <typename RadiusType>
47 spheroid(RadiusType const& a, RadiusType const& b)
53 : m_a(RadiusType(6378137.0))
54 , m_b(RadiusType(6356752.3142451793))
57 template <std::size_t I>
58 RadiusType get_radius() const
60 BOOST_STATIC_ASSERT(I < 3);
62 return I < 2 ? m_a : m_b;
65 template <std::size_t I>
66 void set_radius(RadiusType const& radius)
68 BOOST_STATIC_ASSERT(I < 3);
70 (I < 2 ? m_a : m_b) = radius;
74 RadiusType m_a, m_b; // equatorial radius, polar radius
79 // Traits specializations for spheroid
80 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
84 template <typename RadiusType>
85 struct tag< srs::spheroid<RadiusType> >
87 typedef srs_spheroid_tag type;
90 template <typename RadiusType>
91 struct radius_type< srs::spheroid<RadiusType> >
93 typedef RadiusType type;
96 template <typename RadiusType, std::size_t Dimension>
97 struct radius_access<srs::spheroid<RadiusType>, Dimension>
99 typedef srs::spheroid<RadiusType> spheroid_type;
101 static inline RadiusType get(spheroid_type const& s)
103 return s.template get_radius<Dimension>();
106 static inline void set(spheroid_type& s, RadiusType const& value)
108 s.template set_radius<Dimension>(value);
112 } // namespace traits
113 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
120 \brief Defines sphere radius value for use in spherical CS calculations
122 template <typename RadiusType>
126 explicit sphere(RadiusType const& r)
131 : m_r(RadiusType((2.0 * 6378137.0 + 6356752.3142451793) / 3.0))
134 template <std::size_t I>
135 RadiusType get_radius() const
137 BOOST_STATIC_ASSERT(I < 3);
142 template <std::size_t I>
143 void set_radius(RadiusType const& radius)
145 BOOST_STATIC_ASSERT(I < 3);
151 RadiusType m_r; // radius
156 // Traits specializations for sphere
157 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
161 template <typename RadiusType>
162 struct tag< srs::sphere<RadiusType> >
164 typedef srs_sphere_tag type;
167 template <typename RadiusType>
168 struct radius_type< srs::sphere<RadiusType> >
170 typedef RadiusType type;
173 template <typename RadiusType, std::size_t Dimension>
174 struct radius_access<srs::sphere<RadiusType>, Dimension>
176 typedef srs::sphere<RadiusType> sphere_type;
178 static inline RadiusType get(sphere_type const& s)
180 return s.template get_radius<Dimension>();
183 static inline void set(sphere_type& s, RadiusType const& value)
185 s.template set_radius<Dimension>(value);
189 } // namespace traits
190 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
193 }} // namespace boost::geometry
196 #endif // BOOST_GEOMETRY_CORE_SRS_HPP