Back to home page

EIC code displayed by LXR

 
 

    


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

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_SPHERICAL_LINE_INTERPOLATE_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_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/formulas/interpolate_point_spherical.hpp>
0019 #include <boost/geometry/srs/spheroid.hpp>
0020 #include <boost/geometry/strategies/line_interpolate.hpp>
0021 #include <boost/geometry/strategies/spherical/distance_haversine.hpp>
0022 #include <boost/geometry/util/select_calculation_type.hpp>
0023 
0024 
0025 namespace boost { namespace geometry
0026 {
0027 
0028 namespace strategy { namespace line_interpolate
0029 {
0030 
0031 
0032 /*!
0033 \brief Interpolate point on a spherical segment.
0034 \ingroup strategies
0035 \tparam CalculationType \tparam_calculation
0036 \tparam DistanceStrategy The underlying point-point distance strategy
0037 
0038 \qbk{
0039 [heading See also]
0040 \* [link geometry.reference.algorithms.line_interpolate.line_interpolate_4_with_strategy line_interpolate (with strategy)]
0041 }
0042 
0043  */
0044 template
0045 <
0046     typename CalculationType = void,
0047     typename DistanceStrategy = distance::haversine<double, CalculationType>
0048 >
0049 class spherical
0050 {
0051 public:
0052 
0053     typedef typename DistanceStrategy::radius_type radius_type;
0054 
0055     spherical() = default;
0056 
0057     explicit inline spherical(typename DistanceStrategy::radius_type const& r)
0058         : m_strategy(r)
0059     {}
0060 
0061     inline spherical(DistanceStrategy const& s)
0062         : m_strategy(s)
0063     {}
0064 
0065     template <typename Point, typename Fraction, typename Distance>
0066     inline void apply(Point const& p0,
0067                       Point const& p1,
0068                       Fraction const& fraction,
0069                       Point & p,
0070                       Distance const&) const
0071     {
0072         typedef typename select_calculation_type_alt
0073         <
0074             CalculationType,
0075             Point
0076         >::type calc_t;
0077 
0078         formula::interpolate_point_spherical<calc_t> formula;
0079 
0080         calc_t angle01;
0081         formula.compute_angle(p0, p1, angle01);
0082         formula.compute_axis(p0, angle01);
0083 
0084         calc_t a = angle01 * fraction;
0085         formula.compute_point(a, p);
0086     }
0087 
0088     inline radius_type radius() const
0089     {
0090         return m_strategy.radius();
0091     }
0092 
0093 private :
0094     DistanceStrategy m_strategy;
0095 };
0096 
0097 
0098 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0099 namespace services
0100 {
0101 
0102 template <>
0103 struct default_strategy<spherical_equatorial_tag>
0104 {
0105     typedef strategy::line_interpolate::spherical<> type;
0106 };
0107 
0108 
0109 } // namespace services
0110 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0111 
0112 
0113 }} // namespace strategy::line_interpolate
0114 
0115 
0116 }} // namespace boost::geometry
0117 
0118 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_LINE_INTERPOLATE_HPP