File indexing completed on 2025-01-18 09:35:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_FORMULAS_AUTHALIC_RADIUS_SQR_HPP
0012 #define BOOST_GEOMETRY_FORMULAS_AUTHALIC_RADIUS_SQR_HPP
0013
0014 #include <boost/geometry/core/radius.hpp>
0015 #include <boost/geometry/core/tag.hpp>
0016 #include <boost/geometry/core/tags.hpp>
0017
0018 #include <boost/geometry/formulas/eccentricity_sqr.hpp>
0019
0020 #include <boost/geometry/util/math.hpp>
0021
0022 #include <boost/geometry/algorithms/not_implemented.hpp>
0023
0024 #include <boost/math/special_functions/atanh.hpp>
0025
0026 namespace boost { namespace geometry
0027 {
0028
0029 #ifndef DOXYGEN_NO_DISPATCH
0030 namespace formula_dispatch
0031 {
0032
0033 template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
0034 struct authalic_radius_sqr
0035 : not_implemented<Tag>
0036 {};
0037
0038 template <typename ResultType, typename Geometry>
0039 struct authalic_radius_sqr<ResultType, Geometry, srs_sphere_tag>
0040 {
0041 static inline ResultType apply(Geometry const& geometry)
0042 {
0043 return math::sqr<ResultType>(get_radius<0>(geometry));
0044 }
0045 };
0046
0047 template <typename ResultType, typename Geometry>
0048 struct authalic_radius_sqr<ResultType, Geometry, srs_spheroid_tag>
0049 {
0050 static inline ResultType apply(Geometry const& geometry)
0051 {
0052 ResultType const a2 = math::sqr<ResultType>(get_radius<0>(geometry));
0053 ResultType const e2 = formula::eccentricity_sqr<ResultType>(geometry);
0054
0055 return apply(a2, e2);
0056 }
0057
0058 static inline ResultType apply(ResultType const& a2, ResultType const& e2)
0059 {
0060 ResultType const c0 = 0;
0061
0062 if (math::equals(e2, c0))
0063 {
0064 return a2;
0065 }
0066
0067 ResultType const e = math::sqrt(e2);
0068 ResultType const c2 = 2;
0069
0070
0071
0072
0073 ResultType const c1 = 1;
0074 return (a2 / c2) * ( c1 + (c1 - e2) * boost::math::atanh(e) / e );
0075 }
0076 };
0077
0078 }
0079 #endif
0080
0081 #ifndef DOXYGEN_NO_DETAIL
0082 namespace formula
0083 {
0084
0085 template <typename ResultType, typename Geometry>
0086 inline ResultType authalic_radius_sqr(Geometry const& geometry)
0087 {
0088 return formula_dispatch::authalic_radius_sqr<ResultType, Geometry>::apply(geometry);
0089 }
0090
0091 }
0092 #endif
0093
0094 }}
0095
0096 #endif