]>
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_DISCRETE_DISTANCE_GEOGRAPHIC_HPP | |
11 | #define BOOST_GEOMETRY_STRATEGIES_DISCRETE_DISTANCE_GEOGRAPHIC_HPP | |
12 | ||
13 | ||
14 | #include <boost/geometry/strategies/detail.hpp> | |
15 | #include <boost/geometry/strategies/discrete_distance/services.hpp> | |
16 | #include <boost/geometry/strategies/distance/comparable.hpp> | |
17 | #include <boost/geometry/strategies/distance/detail.hpp> | |
18 | ||
19 | #include <boost/geometry/strategies/geographic/distance.hpp> | |
20 | // TODO - for backwards compatibility, remove? | |
21 | #include <boost/geometry/strategies/geographic/distance_andoyer.hpp> | |
22 | #include <boost/geometry/strategies/geographic/distance_thomas.hpp> | |
23 | #include <boost/geometry/strategies/geographic/distance_vincenty.hpp> | |
24 | ||
25 | ||
26 | namespace boost { namespace geometry | |
27 | { | |
28 | ||
29 | namespace strategies { namespace discrete_distance | |
30 | { | |
31 | ||
32 | template | |
33 | < | |
34 | typename FormulaPolicy = strategy::andoyer, | |
35 | typename Spheroid = srs::spheroid<double>, | |
36 | typename CalculationType = void | |
37 | > | |
38 | class geographic | |
39 | : public strategies::detail::geographic_base<Spheroid> | |
40 | { | |
41 | using base_t = strategies::detail::geographic_base<Spheroid>; | |
42 | ||
43 | public: | |
44 | geographic() = default; | |
45 | ||
46 | explicit geographic(Spheroid const& spheroid) | |
47 | : base_t(spheroid) | |
48 | {} | |
49 | ||
50 | template <typename Geometry1, typename Geometry2> | |
51 | auto distance(Geometry1 const&, Geometry2 const&, | |
52 | distance::detail::enable_if_pp_t<Geometry1, Geometry2> * = nullptr) const | |
53 | { | |
54 | return strategy::distance::geographic | |
55 | < | |
56 | FormulaPolicy, Spheroid, CalculationType | |
57 | >(base_t::m_spheroid); | |
58 | } | |
59 | }; | |
60 | ||
61 | ||
62 | namespace services | |
63 | { | |
64 | ||
65 | template <typename Geometry1, typename Geometry2> | |
66 | struct default_strategy<Geometry1, Geometry2, geographic_tag, geographic_tag> | |
67 | { | |
68 | using type = strategies::discrete_distance::geographic<>; | |
69 | }; | |
70 | ||
71 | ||
72 | template <typename FP, typename S, typename CT> | |
73 | struct strategy_converter<strategy::distance::geographic<FP, S, CT> > | |
74 | { | |
75 | static auto get(strategy::distance::geographic<FP, S, CT> const& s) | |
76 | { | |
77 | return strategies::discrete_distance::geographic<FP, S, CT>(s.model()); | |
78 | } | |
79 | }; | |
80 | // TODO - for backwards compatibility, remove? | |
81 | template <typename S, typename CT> | |
82 | struct strategy_converter<strategy::distance::andoyer<S, CT> > | |
83 | { | |
84 | static auto get(strategy::distance::andoyer<S, CT> const& s) | |
85 | { | |
86 | return strategies::discrete_distance::geographic<strategy::andoyer, S, CT>(s.model()); | |
87 | } | |
88 | }; | |
89 | // TODO - for backwards compatibility, remove? | |
90 | template <typename S, typename CT> | |
91 | struct strategy_converter<strategy::distance::thomas<S, CT> > | |
92 | { | |
93 | static auto get(strategy::distance::thomas<S, CT> const& s) | |
94 | { | |
95 | return strategies::discrete_distance::geographic<strategy::thomas, S, CT>(s.model()); | |
96 | } | |
97 | }; | |
98 | // TODO - for backwards compatibility, remove? | |
99 | template <typename S, typename CT> | |
100 | struct strategy_converter<strategy::distance::vincenty<S, CT> > | |
101 | { | |
102 | static auto get(strategy::distance::vincenty<S, CT> const& s) | |
103 | { | |
104 | return strategies::discrete_distance::geographic<strategy::vincenty, S, CT>(s.model()); | |
105 | } | |
106 | }; | |
107 | ||
108 | ||
109 | } // namespace services | |
110 | ||
111 | }} // namespace strategies::discrete_distance | |
112 | ||
113 | }} // namespace boost::geometry | |
114 | ||
115 | #endif // BOOST_GEOMETRY_STRATEGIES_DISCRETE_DISTANCE_GEOGRAPHIC_HPP |