]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/strategies/length/spherical.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / strategies / length / spherical.hpp
CommitLineData
1e59de90
TL
1// Boost.Geometry
2
3// Copyright (c) 2021, Oracle and/or its affiliates.
4
5// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7// Licensed under the Boost Software License version 1.0.
8// http://www.boost.org/users/license.html
9
10#ifndef BOOST_GEOMETRY_STRATEGIES_LENGTH_SPHERICAL_HPP
11#define BOOST_GEOMETRY_STRATEGIES_LENGTH_SPHERICAL_HPP
12
13
14#include <boost/geometry/strategies/detail.hpp>
15#include <boost/geometry/strategies/distance/detail.hpp>
16#include <boost/geometry/strategies/length/services.hpp>
17
18#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
19
20
21namespace boost { namespace geometry
22{
23
24namespace strategies { namespace length
25{
26
27template
28<
29 typename RadiusTypeOrSphere = double,
30 typename CalculationType = void
31>
32class spherical
33 : public strategies::detail::spherical_base<RadiusTypeOrSphere>
34{
35 using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>;
36
37public:
38 spherical() = default;
39
40 template <typename RadiusOrSphere>
41 explicit spherical(RadiusOrSphere const& radius_or_sphere)
42 : base_t(radius_or_sphere)
43 {}
44
45 template <typename Geometry1, typename Geometry2>
46 auto distance(Geometry1 const&, Geometry2 const&,
47 distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const
48 {
49 return strategy::distance::haversine
50 <
51 typename base_t::radius_type, CalculationType
52 >(base_t::radius());
53 }
54};
55
56
57namespace services
58{
59
60template <typename Geometry>
61struct default_strategy<Geometry, spherical_equatorial_tag>
62{
63 using type = strategies::length::spherical<>;
64};
65
66
67template <typename R, typename CT>
68struct strategy_converter<strategy::distance::haversine<R, CT> >
69{
70 static auto get(strategy::distance::haversine<R, CT> const& s)
71 {
72 return strategies::length::spherical<R, CT>(s.radius());
73 }
74};
75
76
77} // namespace services
78
79}} // namespace strategies::length
80
81}} // namespace boost::geometry
82
83#endif // BOOST_GEOMETRY_STRATEGIES_LENGTH_SPHERICAL_HPP