Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:46

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2018-2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP
0013 
0014 #include <boost/geometry/core/assert.hpp>
0015 #include <boost/geometry/core/coordinate_dimension.hpp>
0016 #include <boost/geometry/core/coordinate_type.hpp>
0017 #include <boost/geometry/core/radian_access.hpp>
0018 #include <boost/geometry/srs/spheroid.hpp>
0019 #include <boost/geometry/strategies/line_interpolate.hpp>
0020 #include <boost/geometry/strategies/geographic/parameters.hpp>
0021 #include <boost/geometry/util/select_calculation_type.hpp>
0022 
0023 
0024 namespace boost { namespace geometry
0025 {
0026 
0027 namespace strategy { namespace line_interpolate
0028 {
0029 
0030 
0031 /*!
0032 \brief Interpolate point on a geographic segment.
0033 \ingroup strategies
0034 \tparam FormulaPolicy The geodesic formulas used internally.
0035 \tparam Spheroid The spheroid model.
0036 \tparam CalculationType \tparam_calculation
0037 
0038 \qbk{
0039 [heading See also]
0040 \* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)]
0041 \* [link geometry.reference.srs.srs_spheroid srs::spheroid]
0042 }
0043  */
0044 template
0045 <
0046     typename FormulaPolicy = strategy::andoyer,
0047     typename Spheroid = srs::spheroid<double>,
0048     typename CalculationType = void
0049 >
0050 class geographic
0051 {
0052 public:
0053     geographic() = default;
0054 
0055     explicit geographic(Spheroid const& spheroid)
0056         : m_spheroid(spheroid)
0057     {}
0058 
0059     template <typename Point, typename Fraction, typename Distance>
0060     inline void apply(Point const& p0,
0061                       Point const& p1,
0062                       Fraction const& fraction, //fraction of segment
0063                       Point & p,
0064                       Distance const& distance) const
0065     {
0066         typedef typename select_calculation_type_alt
0067             <
0068                 CalculationType,
0069                 Point
0070             >::type calc_t;
0071 
0072         typedef typename FormulaPolicy::template inverse
0073                 <calc_t, false, true, false, false, false> inverse_t;
0074 
0075         calc_t azimuth = inverse_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
0076                                           get_as_radian<0>(p1), get_as_radian<1>(p1),
0077                                           m_spheroid).azimuth;
0078 
0079         typedef typename FormulaPolicy::template direct
0080                 <calc_t, true, false, false, false> direct_t;
0081 
0082         typename direct_t::result_type
0083         dir_r = direct_t::apply(get_as_radian<0>(p0), get_as_radian<1>(p0),
0084                                 distance * fraction, azimuth,
0085                                 m_spheroid);
0086 
0087         set_from_radian<0>(p, dir_r.lon2);
0088         set_from_radian<1>(p, dir_r.lat2);
0089     }
0090 
0091     inline Spheroid model() const
0092     {
0093         return m_spheroid;
0094     }
0095 
0096 private:
0097     Spheroid m_spheroid;
0098 };
0099 
0100 
0101 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0102 namespace services
0103 {
0104 
0105 template <>
0106 struct default_strategy<geographic_tag>
0107 {
0108     typedef strategy::line_interpolate::geographic<> type;
0109 };
0110 
0111 
0112 } // namespace services
0113 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0114 
0115 
0116 }} // namespace strategy::line_interpolate
0117 
0118 
0119 }} // namespace boost::geometry
0120 
0121 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_LINE_INTERPOLATE_HPP