]>
Commit | Line | Data |
---|---|---|
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 | ||
21 | namespace boost { namespace geometry | |
22 | { | |
23 | ||
24 | namespace strategies { namespace length | |
25 | { | |
26 | ||
27 | template | |
28 | < | |
29 | typename RadiusTypeOrSphere = double, | |
30 | typename CalculationType = void | |
31 | > | |
32 | class spherical | |
33 | : public strategies::detail::spherical_base<RadiusTypeOrSphere> | |
34 | { | |
35 | using base_t = strategies::detail::spherical_base<RadiusTypeOrSphere>; | |
36 | ||
37 | public: | |
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 | ||
57 | namespace services | |
58 | { | |
59 | ||
60 | template <typename Geometry> | |
61 | struct default_strategy<Geometry, spherical_equatorial_tag> | |
62 | { | |
63 | using type = strategies::length::spherical<>; | |
64 | }; | |
65 | ||
66 | ||
67 | template <typename R, typename CT> | |
68 | struct 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 |