]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/formulas/mean_radius.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / formulas / mean_radius.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2017 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_MEAN_RADIUS_HPP
12 #define BOOST_GEOMETRY_FORMULAS_MEAN_RADIUS_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 mean_radius
29 : not_implemented<Tag>
30 {};
31
32 template <typename ResultType, typename Geometry>
33 struct mean_radius<ResultType, Geometry, srs_sphere_tag>
34 {
35 static inline ResultType apply(Geometry const& geometry)
36 {
37 return ResultType(get_radius<0>(geometry));
38 }
39 };
40
41 template <typename ResultType, typename Geometry>
42 struct mean_radius<ResultType, Geometry, srs_spheroid_tag>
43 {
44 static inline ResultType apply(Geometry const& geometry)
45 {
46 // (2*a + b) / 3
47 return (ResultType(2) * ResultType(get_radius<0>(geometry))
48 + ResultType(get_radius<2>(geometry)))
49 / ResultType(3);
50 }
51 };
52
53 } // namespace formula_dispatch
54 #endif // DOXYGEN_NO_DISPATCH
55
56 #ifndef DOXYGEN_NO_DETAIL
57 namespace formula
58 {
59
60 template <typename ResultType, typename Geometry>
61 inline ResultType mean_radius(Geometry const& geometry)
62 {
63 return formula_dispatch::mean_radius<ResultType, Geometry>::apply(geometry);
64 }
65
66 } // namespace formula
67 #endif // DOXYGEN_NO_DETAIL
68
69 }} // namespace boost::geometry
70
71 #endif // BOOST_GEOMETRY_FORMULAS_MEAN_RADIUS_HPP