Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2017 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_MEAN_RADIUS_HPP
0012 #define BOOST_GEOMETRY_FORMULAS_MEAN_RADIUS_HPP
0013 
0014 #include <boost/geometry/core/radius.hpp>
0015 #include <boost/geometry/core/tag.hpp>
0016 #include <boost/geometry/core/tags.hpp>
0017 
0018 #include <boost/geometry/algorithms/not_implemented.hpp>
0019 
0020 namespace boost { namespace geometry
0021 {
0022 
0023 #ifndef DOXYGEN_NO_DISPATCH
0024 namespace formula_dispatch
0025 {
0026 
0027 template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
0028 struct mean_radius
0029     : not_implemented<Tag>
0030 {};
0031 
0032 template <typename ResultType, typename Geometry>
0033 struct mean_radius<ResultType, Geometry, srs_sphere_tag>
0034 {
0035     static inline ResultType apply(Geometry const& geometry)
0036     {
0037         return ResultType(get_radius<0>(geometry));
0038     }
0039 };
0040 
0041 template <typename ResultType, typename Geometry>
0042 struct mean_radius<ResultType, Geometry, srs_spheroid_tag>
0043 {
0044     static inline ResultType apply(Geometry const& geometry)
0045     {
0046         // (2*a + b) / 3
0047         return (ResultType(2) * ResultType(get_radius<0>(geometry))
0048                 + ResultType(get_radius<2>(geometry)))
0049              / ResultType(3);
0050     }
0051 };
0052 
0053 } // namespace formula_dispatch
0054 #endif // DOXYGEN_NO_DISPATCH
0055 
0056 #ifndef DOXYGEN_NO_DETAIL
0057 namespace formula
0058 {
0059 
0060 template <typename ResultType, typename Geometry>
0061 inline ResultType mean_radius(Geometry const& geometry)
0062 {
0063     return formula_dispatch::mean_radius<ResultType, Geometry>::apply(geometry);
0064 }
0065 
0066 } // namespace formula
0067 #endif // DOXYGEN_NO_DETAIL
0068 
0069 }} // namespace boost::geometry
0070 
0071 #endif // BOOST_GEOMETRY_FORMULAS_MEAN_RADIUS_HPP