1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
5 // This file was modified by Oracle on 2018.
6 // Modifications copyright (c) 2018, Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
14 #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP
15 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP
19 #include <boost/range/value_type.hpp>
21 #include <boost/geometry/core/access.hpp>
22 #include <boost/geometry/strategies/buffer.hpp>
23 #include <boost/geometry/util/math.hpp>
25 namespace boost { namespace geometry
28 namespace strategy { namespace buffer
32 \brief Create a squared form buffer around a point
34 \details This strategy can be used as PointStrategy for the buffer algorithm.
35 It creates a square from each point, where the point lies in the center.
36 It can be applied for points and multi_points, but also for a linestring (if it is degenerate,
37 so consisting of only one point) and for polygons (if it is degenerate).
38 This strategy is only applicable for Cartesian coordinate systems.
44 [$img/strategies/buffer_point_square.png]
46 \* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
47 \* [link geometry.reference.strategies.strategy_buffer_point_circle point_circle]
48 \* [link geometry.reference.strategies.strategy_buffer_geographic_point_circle geographic_point_circle]
56 typename DistanceType,
59 inline void add_point(Point const& point,
60 DistanceType const& distance,
61 DistanceType const& x,
62 DistanceType const& y,
63 OutputRange& output_range) const
65 typename boost::range_value<OutputRange>::type p;
66 set<0>(p, get<0>(point) + x * distance);
67 set<1>(p, get<1>(point) + y * distance);
68 output_range.push_back(p);
74 typename DistanceType,
77 inline void add_points(Point const& point,
78 DistanceType const& distance,
79 OutputRange& output_range) const
81 add_point(point, distance, -1.0, -1.0, output_range);
82 add_point(point, distance, -1.0, +1.0, output_range);
83 add_point(point, distance, +1.0, +1.0, output_range);
84 add_point(point, distance, +1.0, -1.0, output_range);
87 output_range.push_back(output_range.front());
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 //! Fills output_range with a square around point using distance_strategy
97 typename DistanceStrategy,
100 inline void apply(Point const& point,
101 DistanceStrategy const& distance_strategy,
102 OutputRange& output_range) const
104 add_points(point, distance_strategy.apply(point, point,
105 strategy::buffer::buffer_side_left), output_range);
107 #endif // DOXYGEN_SHOULD_SKIP_THIS
112 }} // namespace strategy::buffer
114 }} // namespace boost::geometry
116 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP