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.
8 // Modifications copyright (c) 2014 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.314245))
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)
130 : m_r(RadiusType((2.0 * 6378137.0 + 6356752.314245) / 3.0))
133 template <std::size_t I>
134 RadiusType get_radius() const
136 BOOST_STATIC_ASSERT(I < 3);
141 template <std::size_t I>
142 void set_radius(RadiusType const& radius)
144 BOOST_STATIC_ASSERT(I < 3);
150 RadiusType m_r; // radius
155 // Traits specializations for sphere
156 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
160 template <typename RadiusType>
161 struct tag< srs::sphere<RadiusType> >
163 typedef srs_sphere_tag type;
166 template <typename RadiusType>
167 struct radius_type< srs::sphere<RadiusType> >
169 typedef RadiusType type;
172 template <typename RadiusType, std::size_t Dimension>
173 struct radius_access<srs::sphere<RadiusType>, Dimension>
175 typedef srs::sphere<RadiusType> sphere_type;
177 static inline RadiusType get(sphere_type const& s)
179 return s.template get_radius<Dimension>();
182 static inline void set(sphere_type& s, RadiusType const& value)
184 s.template set_radius<Dimension>(value);
188 } // namespace traits
189 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
192 }} // namespace boost::geometry
195 #endif // BOOST_GEOMETRY_CORE_SRS_HPP