Chris@102: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@102: Chris@102: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@102: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@102: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@102: Chris@102: // This file was modified by Oracle on 2014. Chris@102: // Modifications copyright (c) 2014 Oracle and/or its affiliates. Chris@102: Chris@102: // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle Chris@102: Chris@102: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@102: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@102: Chris@102: // Use, modification and distribution is subject to the Boost Software License, Chris@102: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: Chris@102: #ifndef BOOST_GEOMETRY_CORE_SRS_HPP Chris@102: #define BOOST_GEOMETRY_CORE_SRS_HPP Chris@102: Chris@102: Chris@102: #include Chris@102: Chris@102: #include Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: Chris@102: namespace boost { namespace geometry Chris@102: { Chris@102: Chris@102: namespace srs Chris@102: { Chris@102: Chris@102: /*! Chris@102: \brief Defines spheroid radius values for use in geographical CS calculations Chris@102: \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth Chris@102: and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84 Chris@102: */ Chris@102: template Chris@102: class spheroid Chris@102: { Chris@102: public: Chris@102: spheroid(RadiusType const& a, RadiusType const& b) Chris@102: : m_a(a) Chris@102: , m_b(b) Chris@102: {} Chris@102: Chris@102: spheroid() Chris@102: : m_a(RadiusType(6378137.0)) Chris@102: , m_b(RadiusType(6356752.314245)) Chris@102: {} Chris@102: Chris@102: template Chris@102: RadiusType get_radius() const Chris@102: { Chris@102: BOOST_STATIC_ASSERT(I < 3); Chris@102: Chris@102: return I < 2 ? m_a : m_b; Chris@102: } Chris@102: Chris@102: template Chris@102: void set_radius(RadiusType const& radius) Chris@102: { Chris@102: BOOST_STATIC_ASSERT(I < 3); Chris@102: Chris@102: (I < 2 ? m_a : m_b) = radius; Chris@102: } Chris@102: Chris@102: private: Chris@102: RadiusType m_a, m_b; // equatorial radius, polar radius Chris@102: }; Chris@102: Chris@102: } // namespace srs Chris@102: Chris@102: // Traits specializations for spheroid Chris@102: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@102: namespace traits Chris@102: { Chris@102: Chris@102: template Chris@102: struct tag< srs::spheroid > Chris@102: { Chris@102: typedef srs_spheroid_tag type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_type< srs::spheroid > Chris@102: { Chris@102: typedef RadiusType type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_access, Dimension> Chris@102: { Chris@102: typedef srs::spheroid spheroid_type; Chris@102: Chris@102: static inline RadiusType get(spheroid_type const& s) Chris@102: { Chris@102: return s.template get_radius(); Chris@102: } Chris@102: Chris@102: static inline void set(spheroid_type& s, RadiusType const& value) Chris@102: { Chris@102: s.template set_radius(value); Chris@102: } Chris@102: }; Chris@102: Chris@102: } // namespace traits Chris@102: #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@102: Chris@102: Chris@102: namespace srs Chris@102: { Chris@102: Chris@102: /*! Chris@102: \brief Defines sphere radius value for use in spherical CS calculations Chris@102: */ Chris@102: template Chris@102: class sphere Chris@102: { Chris@102: public: Chris@102: explicit sphere(RadiusType const& r) Chris@102: : m_r(r) Chris@102: {} Chris@102: sphere() Chris@102: : m_r(RadiusType((2.0 * 6378137.0 + 6356752.314245) / 3.0)) Chris@102: {} Chris@102: Chris@102: template Chris@102: RadiusType get_radius() const Chris@102: { Chris@102: BOOST_STATIC_ASSERT(I < 3); Chris@102: Chris@102: return m_r; Chris@102: } Chris@102: Chris@102: template Chris@102: void set_radius(RadiusType const& radius) Chris@102: { Chris@102: BOOST_STATIC_ASSERT(I < 3); Chris@102: Chris@102: m_r = radius; Chris@102: } Chris@102: Chris@102: private: Chris@102: RadiusType m_r; // radius Chris@102: }; Chris@102: Chris@102: } // namespace srs Chris@102: Chris@102: // Traits specializations for sphere Chris@102: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@102: namespace traits Chris@102: { Chris@102: Chris@102: template Chris@102: struct tag< srs::sphere > Chris@102: { Chris@102: typedef srs_sphere_tag type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_type< srs::sphere > Chris@102: { Chris@102: typedef RadiusType type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct radius_access, Dimension> Chris@102: { Chris@102: typedef srs::sphere sphere_type; Chris@102: Chris@102: static inline RadiusType get(sphere_type const& s) Chris@102: { Chris@102: return s.template get_radius(); Chris@102: } Chris@102: Chris@102: static inline void set(sphere_type& s, RadiusType const& value) Chris@102: { Chris@102: s.template set_radius(value); Chris@102: } Chris@102: }; Chris@102: Chris@102: } // namespace traits Chris@102: #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@102: Chris@102: Chris@102: }} // namespace boost::geometry Chris@102: Chris@102: Chris@102: #endif // BOOST_GEOMETRY_CORE_SRS_HPP