3 // Copyright (c) 2016, 2018 Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
12 #define BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
14 #include <boost/geometry/algorithms/not_implemented.hpp>
16 #include <boost/geometry/core/radius.hpp>
17 #include <boost/geometry/core/tag.hpp>
18 #include <boost/geometry/core/tags.hpp>
20 #include <boost/geometry/util/math.hpp>
22 namespace boost { namespace geometry
25 #ifndef DOXYGEN_NO_DISPATCH
26 namespace formula_dispatch
29 template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
30 struct eccentricity_sqr
31 : not_implemented<Tag>
34 template <typename ResultType, typename Geometry>
35 struct eccentricity_sqr<ResultType, Geometry, srs_sphere_tag>
37 static inline ResultType apply(Geometry const& /*geometry*/)
43 template <typename ResultType, typename Geometry>
44 struct eccentricity_sqr<ResultType, Geometry, srs_spheroid_tag>
46 static inline ResultType apply(Geometry const& geometry)
49 return ResultType(1) - math::sqr(ResultType(get_radius<2>(geometry))
50 / ResultType(get_radius<0>(geometry)));
54 } // namespace formula_dispatch
55 #endif // DOXYGEN_NO_DISPATCH
57 #ifndef DOXYGEN_NO_DETAIL
61 template <typename ResultType, typename Geometry>
62 ResultType eccentricity_sqr(Geometry const& geometry)
64 return formula_dispatch::eccentricity_sqr<ResultType, Geometry>::apply(geometry);
67 } // namespace formula
68 #endif // DOXYGEN_NO_DETAIL
70 }} // namespace boost::geometry
72 #endif // BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP