]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/geographic/line_interpolate.hpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / boost / geometry / strategies / geographic / line_interpolate.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2018-2021, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10
11 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
13
14 #include <boost/geometry/core/assert.hpp>
15 #include <boost/geometry/core/coordinate_dimension.hpp>
16 #include <boost/geometry/core/coordinate_type.hpp>
17 #include <boost/geometry/core/radian_access.hpp>
18 #include <boost/geometry/srs/spheroid.hpp>
19 #include <boost/geometry/strategies/line_interpolate.hpp>
20 #include <boost/geometry/strategies/geographic/parameters.hpp>
21 #include <boost/geometry/util/select_calculation_type.hpp>
22
23
24 namespace boost { namespace geometry
25 {
26
27 namespace strategy { namespace line_interpolate
28 {
29
30
31 /*!
32 \brief Interpolate point on a geographic segment.
33 \ingroup strategies
34 \tparam FormulaPolicy The geodesic formulas used internally.
35 \tparam Spheroid The spheroid model.
36 \tparam CalculationType \tparam_calculation
37
38 \qbk{
39 [heading See also]
40 \* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)]
41 \* [link geometry.reference.srs.srs_spheroid srs::spheroid]
42 }
43 */
44 template
45 <
46 typename FormulaPolicy = strategy::andoyer,
47 typename Spheroid = srs::spheroid<double>,
48 typename CalculationType = void
49 >
50 class geographic
51 {
52 public:
53 geographic() = default;
54
55 explicit geographic(Spheroid const& spheroid)
56 : m_spheroid(spheroid)
57 {}
58
59 template <typename Point, typename Fraction, typename Distance>
60 inline void apply(Point const& p0,
61 Point const& p1,
62 Fraction const& fraction, //fraction of segment
63 Point & p,
64 Distance const& distance) const
65 {
66 typedef typename select_calculation_type_alt
67 <
68 CalculationType,
69 Point
70 >::type calc_t;
71
72 typedef typename FormulaPolicy::template inverse
73 <calc_t, false, true, false, false, false> inverse_t;
74
75 calc_t azimuth = inverse_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
76 get_as_radian<0>(p1), get_as_radian<1>(p1),
77 m_spheroid).azimuth;
78
79 typedef typename FormulaPolicy::template direct
80 <calc_t, true, false, false, false> direct_t;
81
82 typename direct_t::result_type
83 dir_r = direct_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
84 distance * fraction, azimuth,
85 m_spheroid);
86
87 set_from_radian<0>(p, dir_r.lon2);
88 set_from_radian<1>(p, dir_r.lat2);
89 }
90
91 inline Spheroid model() const
92 {
93 return m_spheroid;
94 }
95
96 private:
97 Spheroid m_spheroid;
98 };
99
100
101 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
102 namespace services
103 {
104
105 template <>
106 struct default_strategy<geographic_tag>
107 {
108 typedef strategy::line_interpolate::geographic<> type;
109 };
110
111
112 } // namespace services
113 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
114
115
116 }} // namespace strategy::line_interpolate
117
118
119 }} // namespace boost::geometry
120
121 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP