• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 
3 // Copyright (c) 2016, 2018 Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 
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)
10 
11 #ifndef BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
12 #define BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
13 
14 #include <boost/geometry/algorithms/not_implemented.hpp>
15 
16 #include <boost/geometry/core/radius.hpp>
17 #include <boost/geometry/core/tag.hpp>
18 #include <boost/geometry/core/tags.hpp>
19 
20 #include <boost/geometry/util/math.hpp>
21 
22 namespace boost { namespace geometry
23 {
24 
25 #ifndef DOXYGEN_NO_DISPATCH
26 namespace formula_dispatch
27 {
28 
29 template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
30 struct eccentricity_sqr
31     : not_implemented<Tag>
32 {};
33 
34 template <typename ResultType, typename Geometry>
35 struct eccentricity_sqr<ResultType, Geometry, srs_sphere_tag>
36 {
applyboost::geometry::formula_dispatch::eccentricity_sqr37     static inline ResultType apply(Geometry const& /*geometry*/)
38     {
39         return ResultType(0);
40     }
41 };
42 
43 template <typename ResultType, typename Geometry>
44 struct eccentricity_sqr<ResultType, Geometry, srs_spheroid_tag>
45 {
applyboost::geometry::formula_dispatch::eccentricity_sqr46     static inline ResultType apply(Geometry const& geometry)
47     {
48         // 1 - (b / a)^2
49         return ResultType(1) - math::sqr(ResultType(get_radius<2>(geometry))
50                                        / ResultType(get_radius<0>(geometry)));
51     }
52 };
53 
54 } // namespace formula_dispatch
55 #endif // DOXYGEN_NO_DISPATCH
56 
57 #ifndef DOXYGEN_NO_DETAIL
58 namespace formula
59 {
60 
61 template <typename ResultType, typename Geometry>
eccentricity_sqr(Geometry const & geometry)62 ResultType eccentricity_sqr(Geometry const& geometry)
63 {
64     return formula_dispatch::eccentricity_sqr<ResultType, Geometry>::apply(geometry);
65 }
66 
67 } // namespace formula
68 #endif // DOXYGEN_NO_DETAIL
69 
70 }} // namespace boost::geometry
71 
72 #endif // BOOST_GEOMETRY_FORMULAS_ECCENCRICITY_SQR_HPP
73