3 // Copyright (c) 2018-2021, Oracle and/or its affiliates.
5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
11 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
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>
24 namespace boost { namespace geometry
27 namespace strategy { namespace line_interpolate
32 \brief Interpolate point on a geographic segment.
34 \tparam FormulaPolicy The geodesic formulas used internally.
35 \tparam Spheroid The spheroid model.
36 \tparam CalculationType \tparam_calculation
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]
46 typename FormulaPolicy = strategy::andoyer,
47 typename Spheroid = srs::spheroid<double>,
48 typename CalculationType = void
53 geographic() = default;
55 explicit geographic(Spheroid const& spheroid)
56 : m_spheroid(spheroid)
59 template <typename Point, typename Fraction, typename Distance>
60 inline void apply(Point const& p0,
62 Fraction const& fraction, //fraction of segment
64 Distance const& distance) const
66 typedef typename select_calculation_type_alt
72 typedef typename FormulaPolicy::template inverse
73 <calc_t, false, true, false, false, false> inverse_t;
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),
79 typedef typename FormulaPolicy::template direct
80 <calc_t, true, false, false, false> direct_t;
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,
87 set_from_radian<0>(p, dir_r.lon2);
88 set_from_radian<1>(p, dir_r.lat2);
91 inline Spheroid model() const
101 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
106 struct default_strategy<geographic_tag>
108 typedef strategy::line_interpolate::geographic<> type;
112 } // namespace services
113 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
116 }} // namespace strategy::line_interpolate
119 }} // namespace boost::geometry
121 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP