• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 
3 // Copyright (c) 2014-2016 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_FLATTENING_HPP
12 #define BOOST_GEOMETRY_FORMULAS_FLATTENING_HPP
13 
14 #include <boost/geometry/core/radius.hpp>
15 #include <boost/geometry/core/tag.hpp>
16 #include <boost/geometry/core/tags.hpp>
17 
18 #include <boost/geometry/algorithms/not_implemented.hpp>
19 
20 namespace boost { namespace geometry
21 {
22 
23 #ifndef DOXYGEN_NO_DISPATCH
24 namespace formula_dispatch
25 {
26 
27 template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
28 struct flattening
29     : not_implemented<Tag>
30 {};
31 
32 template <typename ResultType, typename Geometry>
33 struct flattening<ResultType, Geometry, srs_sphere_tag>
34 {
applyboost::geometry::formula_dispatch::flattening35     static inline ResultType apply(Geometry const& /*geometry*/)
36     {
37         return ResultType(0);
38     }
39 };
40 
41 template <typename ResultType, typename Geometry>
42 struct flattening<ResultType, Geometry, srs_spheroid_tag>
43 {
applyboost::geometry::formula_dispatch::flattening44     static inline ResultType apply(Geometry const& geometry)
45     {
46         // (a - b) / a
47         return ResultType(get_radius<0>(geometry) - get_radius<2>(geometry))
48                     / ResultType(get_radius<0>(geometry));
49     }
50 };
51 
52 } // namespace formula_dispatch
53 #endif // DOXYGEN_NO_DISPATCH
54 
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace formula
57 {
58 
59 template <typename ResultType, typename Geometry>
flattening(Geometry const & geometry)60 ResultType flattening(Geometry const& geometry)
61 {
62     return formula_dispatch::flattening<ResultType, Geometry>::apply(geometry);
63 }
64 
65 } // namespace formula
66 #endif // DOXYGEN_NO_DETAIL
67 
68 }} // namespace boost::geometry
69 
70 #endif // BOOST_GEOMETRY_FORMULAS_FLATTENING_HPP
71