3 // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP
10 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP
14 #include <boost/range.hpp>
16 #include <boost/geometry/util/math.hpp>
18 #include <boost/geometry/strategies/buffer.hpp>
21 namespace boost { namespace geometry
24 namespace strategy { namespace buffer
28 \brief Create a circular buffer around a point, on the Earth
30 \details This strategy can be used as PointStrategy for the buffer algorithm.
31 It creates a circular buffer around a point, on the Earth. It can be applied
32 for points and multi_points.
36 [buffer_geographic_point_circle]
37 [buffer_geographic_point_circle_output]
39 \* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
40 \* [link geometry.reference.strategies.strategy_buffer_point_circle point_circle]
41 \* [link geometry.reference.strategies.strategy_buffer_point_square point_square]
46 typename FormulaPolicy = strategy::andoyer,
47 typename Spheroid = srs::spheroid<double>,
48 typename CalculationType = void
50 class geographic_point_circle
53 //! \brief Constructs the strategy
54 //! \param count number of points for the created circle (if count
55 //! is smaller than 3, count is internally set to 3)
56 explicit geographic_point_circle(std::size_t count = 90)
57 : m_count((count < 3u) ? 3u : count)
60 #ifndef DOXYGEN_SHOULD_SKIP_THIS
61 //! Fills output_range with a circle around point using distance_strategy
66 typename DistanceStrategy
68 inline void apply(Point const& point,
69 DistanceStrategy const& distance_strategy,
70 OutputRange& output_range) const
72 typedef typename boost::range_value<OutputRange>::type output_point_type;
74 typedef typename select_most_precise
76 typename geometry::coordinate_type<Point>::type,
77 typename geometry::coordinate_type<output_point_type>::type,
80 >::type calculation_type;
82 calculation_type const buffer_distance = distance_strategy.apply(point, point,
83 strategy::buffer::buffer_side_left);
85 typedef typename FormulaPolicy::template direct
87 calculation_type, true, false, false, false
90 calculation_type const two_pi = geometry::math::two_pi<calculation_type>();
91 calculation_type const pi = geometry::math::pi<calculation_type>();
93 calculation_type const diff = two_pi / calculation_type(m_count);
94 // TODO: after calculation of some angles is corrected,
95 // we can start at 0.0
96 calculation_type angle = 0.001;
98 for (std::size_t i = 0; i < m_count; i++, angle += diff)
105 typename direct_t::result_type
106 dir_r = direct_t::apply(get_as_radian<0>(point), get_as_radian<1>(point),
107 buffer_distance, angle,
110 set_from_radian<0>(p, dir_r.lon2);
111 set_from_radian<1>(p, dir_r.lat2);
112 output_range.push_back(p);
117 const output_point_type p = output_range.front();
118 output_range.push_back(p);
121 #endif // DOXYGEN_SHOULD_SKIP_THIS
129 }} // namespace strategy::buffer
131 }} // namespace boost::geometry
133 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_BUFFER_POINT_CIRCLE_HPP