annotate DEPENDENCIES/generic/include/boost/geometry/core/srs.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@102 2
Chris@102 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@102 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@102 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@102 6
Chris@102 7 // This file was modified by Oracle on 2014.
Chris@102 8 // Modifications copyright (c) 2014 Oracle and/or its affiliates.
Chris@102 9
Chris@102 10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
Chris@102 11
Chris@102 12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@102 13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@102 14
Chris@102 15 // Use, modification and distribution is subject to the Boost Software License,
Chris@102 16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 17 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 18
Chris@102 19 #ifndef BOOST_GEOMETRY_CORE_SRS_HPP
Chris@102 20 #define BOOST_GEOMETRY_CORE_SRS_HPP
Chris@102 21
Chris@102 22
Chris@102 23 #include <cstddef>
Chris@102 24
Chris@102 25 #include <boost/static_assert.hpp>
Chris@102 26
Chris@102 27 #include <boost/geometry/core/radius.hpp>
Chris@102 28 #include <boost/geometry/core/tag.hpp>
Chris@102 29 #include <boost/geometry/core/tags.hpp>
Chris@102 30
Chris@102 31
Chris@102 32 namespace boost { namespace geometry
Chris@102 33 {
Chris@102 34
Chris@102 35 namespace srs
Chris@102 36 {
Chris@102 37
Chris@102 38 /*!
Chris@102 39 \brief Defines spheroid radius values for use in geographical CS calculations
Chris@102 40 \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth
Chris@102 41 and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
Chris@102 42 */
Chris@102 43 template <typename RadiusType>
Chris@102 44 class spheroid
Chris@102 45 {
Chris@102 46 public:
Chris@102 47 spheroid(RadiusType const& a, RadiusType const& b)
Chris@102 48 : m_a(a)
Chris@102 49 , m_b(b)
Chris@102 50 {}
Chris@102 51
Chris@102 52 spheroid()
Chris@102 53 : m_a(RadiusType(6378137.0))
Chris@102 54 , m_b(RadiusType(6356752.314245))
Chris@102 55 {}
Chris@102 56
Chris@102 57 template <std::size_t I>
Chris@102 58 RadiusType get_radius() const
Chris@102 59 {
Chris@102 60 BOOST_STATIC_ASSERT(I < 3);
Chris@102 61
Chris@102 62 return I < 2 ? m_a : m_b;
Chris@102 63 }
Chris@102 64
Chris@102 65 template <std::size_t I>
Chris@102 66 void set_radius(RadiusType const& radius)
Chris@102 67 {
Chris@102 68 BOOST_STATIC_ASSERT(I < 3);
Chris@102 69
Chris@102 70 (I < 2 ? m_a : m_b) = radius;
Chris@102 71 }
Chris@102 72
Chris@102 73 private:
Chris@102 74 RadiusType m_a, m_b; // equatorial radius, polar radius
Chris@102 75 };
Chris@102 76
Chris@102 77 } // namespace srs
Chris@102 78
Chris@102 79 // Traits specializations for spheroid
Chris@102 80 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 81 namespace traits
Chris@102 82 {
Chris@102 83
Chris@102 84 template <typename RadiusType>
Chris@102 85 struct tag< srs::spheroid<RadiusType> >
Chris@102 86 {
Chris@102 87 typedef srs_spheroid_tag type;
Chris@102 88 };
Chris@102 89
Chris@102 90 template <typename RadiusType>
Chris@102 91 struct radius_type< srs::spheroid<RadiusType> >
Chris@102 92 {
Chris@102 93 typedef RadiusType type;
Chris@102 94 };
Chris@102 95
Chris@102 96 template <typename RadiusType, std::size_t Dimension>
Chris@102 97 struct radius_access<srs::spheroid<RadiusType>, Dimension>
Chris@102 98 {
Chris@102 99 typedef srs::spheroid<RadiusType> spheroid_type;
Chris@102 100
Chris@102 101 static inline RadiusType get(spheroid_type const& s)
Chris@102 102 {
Chris@102 103 return s.template get_radius<Dimension>();
Chris@102 104 }
Chris@102 105
Chris@102 106 static inline void set(spheroid_type& s, RadiusType const& value)
Chris@102 107 {
Chris@102 108 s.template set_radius<Dimension>(value);
Chris@102 109 }
Chris@102 110 };
Chris@102 111
Chris@102 112 } // namespace traits
Chris@102 113 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 114
Chris@102 115
Chris@102 116 namespace srs
Chris@102 117 {
Chris@102 118
Chris@102 119 /*!
Chris@102 120 \brief Defines sphere radius value for use in spherical CS calculations
Chris@102 121 */
Chris@102 122 template <typename RadiusType>
Chris@102 123 class sphere
Chris@102 124 {
Chris@102 125 public:
Chris@102 126 explicit sphere(RadiusType const& r)
Chris@102 127 : m_r(r)
Chris@102 128 {}
Chris@102 129 sphere()
Chris@102 130 : m_r(RadiusType((2.0 * 6378137.0 + 6356752.314245) / 3.0))
Chris@102 131 {}
Chris@102 132
Chris@102 133 template <std::size_t I>
Chris@102 134 RadiusType get_radius() const
Chris@102 135 {
Chris@102 136 BOOST_STATIC_ASSERT(I < 3);
Chris@102 137
Chris@102 138 return m_r;
Chris@102 139 }
Chris@102 140
Chris@102 141 template <std::size_t I>
Chris@102 142 void set_radius(RadiusType const& radius)
Chris@102 143 {
Chris@102 144 BOOST_STATIC_ASSERT(I < 3);
Chris@102 145
Chris@102 146 m_r = radius;
Chris@102 147 }
Chris@102 148
Chris@102 149 private:
Chris@102 150 RadiusType m_r; // radius
Chris@102 151 };
Chris@102 152
Chris@102 153 } // namespace srs
Chris@102 154
Chris@102 155 // Traits specializations for sphere
Chris@102 156 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 157 namespace traits
Chris@102 158 {
Chris@102 159
Chris@102 160 template <typename RadiusType>
Chris@102 161 struct tag< srs::sphere<RadiusType> >
Chris@102 162 {
Chris@102 163 typedef srs_sphere_tag type;
Chris@102 164 };
Chris@102 165
Chris@102 166 template <typename RadiusType>
Chris@102 167 struct radius_type< srs::sphere<RadiusType> >
Chris@102 168 {
Chris@102 169 typedef RadiusType type;
Chris@102 170 };
Chris@102 171
Chris@102 172 template <typename RadiusType, std::size_t Dimension>
Chris@102 173 struct radius_access<srs::sphere<RadiusType>, Dimension>
Chris@102 174 {
Chris@102 175 typedef srs::sphere<RadiusType> sphere_type;
Chris@102 176
Chris@102 177 static inline RadiusType get(sphere_type const& s)
Chris@102 178 {
Chris@102 179 return s.template get_radius<Dimension>();
Chris@102 180 }
Chris@102 181
Chris@102 182 static inline void set(sphere_type& s, RadiusType const& value)
Chris@102 183 {
Chris@102 184 s.template set_radius<Dimension>(value);
Chris@102 185 }
Chris@102 186 };
Chris@102 187
Chris@102 188 } // namespace traits
Chris@102 189 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
Chris@102 190
Chris@102 191
Chris@102 192 }} // namespace boost::geometry
Chris@102 193
Chris@102 194
Chris@102 195 #endif // BOOST_GEOMETRY_CORE_SRS_HPP