File indexing completed on 2025-01-18 09:36:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_SIDE_STRAIGHT_HPP
0010 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_SIDE_STRAIGHT_HPP
0011
0012 #include <cstddef>
0013
0014 #include <boost/range/value_type.hpp>
0015
0016 #include <boost/geometry/core/radian_access.hpp>
0017
0018 #include <boost/geometry/srs/spheroid.hpp>
0019 #include <boost/geometry/strategies/buffer.hpp>
0020 #include <boost/geometry/strategies/geographic/buffer_helper.hpp>
0021 #include <boost/geometry/strategies/geographic/parameters.hpp>
0022 #include <boost/geometry/util/math.hpp>
0023 #include <boost/geometry/util/select_calculation_type.hpp>
0024
0025
0026 namespace boost { namespace geometry
0027 {
0028
0029 namespace strategy { namespace buffer
0030 {
0031
0032
0033
0034
0035
0036
0037 template
0038 <
0039 typename FormulaPolicy = strategy::andoyer,
0040 typename Spheroid = srs::spheroid<double>,
0041 typename CalculationType = void
0042 >
0043 class geographic_side_straight
0044 {
0045 public :
0046
0047
0048 explicit inline geographic_side_straight(Spheroid const& spheroid)
0049 : m_spheroid(spheroid)
0050 {}
0051
0052
0053 inline geographic_side_straight()
0054 {}
0055
0056 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0057
0058 static inline bool equidistant()
0059 {
0060 return true;
0061 }
0062
0063
0064 template
0065 <
0066 typename Point,
0067 typename DistanceStrategy,
0068 typename RangeOut
0069 >
0070 inline result_code apply(Point const& input_p1, Point const& input_p2,
0071 buffer_side_selector side,
0072 DistanceStrategy const& distance_strategy,
0073 RangeOut& range_out) const
0074 {
0075 using calc_t = typename select_calculation_type
0076 <
0077 Point,
0078 typename boost::range_value<RangeOut>::type,
0079 CalculationType
0080 >::type;
0081
0082 using helper = geographic_buffer_helper<FormulaPolicy, calc_t>;
0083
0084 calc_t const lon1_rad = get_as_radian<0>(input_p1);
0085 calc_t const lat1_rad = get_as_radian<1>(input_p1);
0086 calc_t const lon2_rad = get_as_radian<0>(input_p2);
0087 calc_t const lat2_rad = get_as_radian<1>(input_p2);
0088 if (lon1_rad == lon2_rad && lat1_rad == lat2_rad)
0089 {
0090
0091
0092
0093 return result_no_output;
0094 }
0095
0096
0097
0098
0099 auto const inv = helper::azimuth(lon1_rad, lat1_rad, input_p2, m_spheroid);
0100 auto const angle = math::wrap_azimuth_in_radian(inv - geometry::math::half_pi<calc_t>());
0101
0102
0103 auto const distance = distance_strategy.apply(input_p1, input_p2, side);
0104 helper::append_point(lon1_rad, lat1_rad, distance, angle, m_spheroid, range_out);
0105 helper::append_point(lon2_rad, lat2_rad, distance, angle, m_spheroid, range_out);
0106
0107 return result_normal;
0108 }
0109 #endif
0110
0111 private :
0112 Spheroid m_spheroid;
0113 };
0114
0115 }}
0116
0117 }}
0118
0119 #endif