Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:24

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2016, 2018 Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Use, modification and distribution is subject to the Boost Software License,
0008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
0012 #define BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
0013 
0014 #include <boost/geometry/algorithms/not_implemented.hpp>
0015 
0016 #include <boost/geometry/core/radius.hpp>
0017 #include <boost/geometry/core/tag.hpp>
0018 #include <boost/geometry/core/tags.hpp>
0019 
0020 #include <boost/geometry/util/math.hpp>
0021 
0022 namespace boost { namespace geometry
0023 {
0024 
0025 #ifndef DOXYGEN_NO_DISPATCH
0026 namespace formula_dispatch
0027 {
0028 
0029 template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
0030 struct eccentricity_sqr
0031     : not_implemented<Tag>
0032 {};
0033 
0034 template <typename ResultType, typename Geometry>
0035 struct eccentricity_sqr<ResultType, Geometry, srs_sphere_tag>
0036 {
0037     static inline ResultType apply(Geometry const& /*geometry*/)
0038     {
0039         return ResultType(0);
0040     }
0041 };
0042 
0043 template <typename ResultType, typename Geometry>
0044 struct eccentricity_sqr<ResultType, Geometry, srs_spheroid_tag>
0045 {
0046     static inline ResultType apply(Geometry const& geometry)
0047     {
0048         // 1 - (b / a)^2
0049         return ResultType(1) - math::sqr(ResultType(get_radius<2>(geometry))
0050                                        / ResultType(get_radius<0>(geometry)));
0051     }
0052 };
0053 
0054 } // namespace formula_dispatch
0055 #endif // DOXYGEN_NO_DISPATCH
0056 
0057 #ifndef DOXYGEN_NO_DETAIL
0058 namespace formula
0059 {
0060 
0061 template <typename ResultType, typename Geometry>
0062 ResultType eccentricity_sqr(Geometry const& geometry)
0063 {
0064     return formula_dispatch::eccentricity_sqr<ResultType, Geometry>::apply(geometry);
0065 }
0066 
0067 } // namespace formula
0068 #endif // DOXYGEN_NO_DETAIL
0069 
0070 }} // namespace boost::geometry
0071 
0072 #endif // BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP