File indexing completed on 2025-01-18 09:36:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP
0014 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP
0015
0016 #include <cstddef>
0017
0018 #include <boost/range/value_type.hpp>
0019
0020 #include <boost/geometry/core/radian_access.hpp>
0021
0022 #include <boost/geometry/srs/spheroid.hpp>
0023 #include <boost/geometry/strategies/buffer.hpp>
0024 #include <boost/geometry/strategies/geographic/buffer_helper.hpp>
0025 #include <boost/geometry/strategies/geographic/parameters.hpp>
0026 #include <boost/geometry/util/math.hpp>
0027 #include <boost/geometry/util/select_calculation_type.hpp>
0028
0029
0030 namespace boost { namespace geometry
0031 {
0032
0033 namespace strategy { namespace buffer
0034 {
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 template
0054 <
0055 typename FormulaPolicy = strategy::andoyer,
0056 typename Spheroid = srs::spheroid<double>,
0057 typename CalculationType = void
0058 >
0059 class geographic_point_circle
0060 {
0061 public :
0062
0063
0064
0065
0066 explicit inline geographic_point_circle(Spheroid const& spheroid,
0067 std::size_t count = default_points_per_circle)
0068 : m_spheroid(spheroid)
0069 , m_count(get_point_count_for_circle(count))
0070 {}
0071
0072
0073
0074 explicit inline geographic_point_circle(std::size_t count = default_points_per_circle)
0075 : m_count(get_point_count_for_circle(count))
0076 {}
0077
0078 #ifndef DOXYGEN_SHOULD_SKIP_THIS
0079
0080 template
0081 <
0082 typename Point,
0083 typename DistanceStrategy,
0084 typename RangeOut
0085 >
0086 inline void apply(Point const& point,
0087 DistanceStrategy const& distance_strategy,
0088 RangeOut& range_out) const
0089 {
0090 using calc_t = typename select_calculation_type
0091 <
0092 Point,
0093 typename boost::range_value<RangeOut>::type,
0094 CalculationType
0095 >::type;
0096
0097 using helper = geographic_buffer_helper<FormulaPolicy, calc_t>;
0098
0099 calc_t const lon_rad = get_as_radian<0>(point);
0100 calc_t const lat_rad = get_as_radian<1>(point);
0101
0102 calc_t const buffer_distance = distance_strategy.apply(point,
0103 point, strategy::buffer::buffer_side_left);
0104
0105 calc_t const two_pi = geometry::math::two_pi<calc_t>();
0106 calc_t const pi = geometry::math::pi<calc_t>();
0107
0108 calc_t const diff = two_pi / calc_t(m_count);
0109 calc_t angle = -pi;
0110
0111 for (std::size_t i = 0; i < m_count; i++, angle += diff)
0112 {
0113
0114 calc_t const eps = angle == 0 ? 1.0e-10 : 0.0;
0115 helper::append_point(lon_rad, lat_rad, buffer_distance, angle + eps, m_spheroid, range_out);
0116 }
0117
0118 {
0119
0120 auto const p = range_out.front();
0121 range_out.push_back(p);
0122 }
0123 }
0124 #endif
0125
0126 private :
0127 Spheroid m_spheroid;
0128 std::size_t m_count;
0129 };
0130
0131 }}
0132
0133 }}
0134
0135 #endif