3 // Copyright (c) 2018, Oracle and/or its affiliates.
5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
11 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
13 #include <boost/geometry/core/assert.hpp>
14 #include <boost/geometry/core/coordinate_dimension.hpp>
15 #include <boost/geometry/core/coordinate_type.hpp>
16 #include <boost/geometry/core/radian_access.hpp>
17 #include <boost/geometry/srs/spheroid.hpp>
18 #include <boost/geometry/strategies/line_interpolate.hpp>
19 #include <boost/geometry/strategies/geographic/parameters.hpp>
20 #include <boost/geometry/util/select_calculation_type.hpp>
23 namespace boost { namespace geometry
26 namespace strategy { namespace line_interpolate
31 \brief Interpolate point on a geographic segment.
33 \tparam FormulaPolicy The geodesic formulas used internally.
34 \tparam Spheroid The spheroid model.
35 \tparam CalculationType \tparam_calculation
39 \* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)]
40 \* [link geometry.reference.srs.srs_spheroid srs::spheroid]
45 typename FormulaPolicy = strategy::andoyer,
46 typename Spheroid = srs::spheroid<double>,
47 typename CalculationType = void
56 explicit geographic(Spheroid const& spheroid)
57 : m_spheroid(spheroid)
60 // point-point strategy getters
61 struct distance_pp_strategy
63 typedef distance::geographic<FormulaPolicy, Spheroid, CalculationType> type;
66 inline typename distance_pp_strategy::type get_distance_pp_strategy() const
68 typedef typename distance_pp_strategy::type distance_type;
69 return distance_type(m_spheroid);
72 template <typename Point, typename Fraction, typename Distance>
73 inline void apply(Point const& p0,
75 Fraction const& fraction, //fraction of segment
77 Distance const& distance) const
79 typedef typename select_calculation_type_alt
85 typedef typename FormulaPolicy::template inverse
86 <calc_t, false, true, false, false, false> inverse_t;
88 calc_t azimuth = inverse_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
89 get_as_radian<0>(p1), get_as_radian<1>(p1),
92 typedef typename FormulaPolicy::template direct
93 <calc_t, true, false, false, false> direct_t;
95 typename direct_t::result_type
96 dir_r = direct_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
97 distance * fraction, azimuth,
100 set_from_radian<0>(p, dir_r.lon2);
101 set_from_radian<1>(p, dir_r.lat2);
109 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
114 struct default_strategy<geographic_tag>
116 typedef strategy::line_interpolate::geographic<> type;
120 } // namespace services
121 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
124 }} // namespace strategy::line_interpolate
127 }} // namespace boost::geometry
129 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP