// Boost.Geometry // Copyright (c) 2018, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP #include #include #include #include #include #include #include #include namespace boost { namespace geometry { namespace strategy { namespace line_interpolate { /*! \brief Interpolate point on a geographic segment. \ingroup strategies \tparam FormulaPolicy The geodesic formulas used internally. \tparam Spheroid The spheroid model. \tparam CalculationType \tparam_calculation \qbk{ [heading See also] \* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)] \* [link geometry.reference.srs.srs_spheroid srs::spheroid] } */ template < typename FormulaPolicy = strategy::andoyer, typename Spheroid = srs::spheroid, typename CalculationType = void > class geographic { public: geographic() : m_spheroid() {} explicit geographic(Spheroid const& spheroid) : m_spheroid(spheroid) {} // point-point strategy getters struct distance_pp_strategy { typedef distance::geographic type; }; inline typename distance_pp_strategy::type get_distance_pp_strategy() const { typedef typename distance_pp_strategy::type distance_type; return distance_type(m_spheroid); } template inline void apply(Point const& p0, Point const& p1, Fraction const& fraction, //fraction of segment Point & p, Distance const& distance) const { typedef typename select_calculation_type_alt < CalculationType, Point >::type calc_t; typedef typename FormulaPolicy::template inverse inverse_t; calc_t azimuth = inverse_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0), get_as_radian<0>(p1), get_as_radian<1>(p1), m_spheroid).azimuth; typedef typename FormulaPolicy::template direct direct_t; typename direct_t::result_type dir_r = direct_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0), distance * fraction, azimuth, m_spheroid); set_from_radian<0>(p, dir_r.lon2); set_from_radian<1>(p, dir_r.lat2); } private: Spheroid m_spheroid; }; #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS namespace services { template <> struct default_strategy { typedef strategy::line_interpolate::geographic<> type; }; } // namespace services #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS }} // namespace strategy::line_interpolate }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP