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,
57 typename MultiplierType,
60 inline void add_point(Point const& point,
61 DistanceType const& distance,
62 MultiplierType const& x,
63 MultiplierType const& y,
64 OutputRange& output_range) const
66 typename boost::range_value<OutputRange>::type p;
67 set<0>(p, get<0>(point) + x * distance);
68 set<1>(p, get<1>(point) + y * distance);
69 output_range.push_back(p);
75 typename DistanceType,
78 inline void add_points(Point const& point,
79 DistanceType const& distance,
80 OutputRange& output_range) const
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);
85 add_point(point, distance, +1.0, -1.0, output_range);
88 output_range.push_back(output_range.front());
93 #ifndef DOXYGEN_SHOULD_SKIP_THIS
94 //! Fills output_range with a square around point using distance_strategy
98 typename DistanceStrategy,
101 inline void apply(Point const& point,
102 DistanceStrategy const& distance_strategy,
103 OutputRange& output_range) const
105 add_points(point, distance_strategy.apply(point, point,
106 strategy::buffer::buffer_side_left), output_range);
108 #endif // DOXYGEN_SHOULD_SKIP_THIS
113 }} // namespace strategy::buffer
115 }} // namespace boost::geometry
117 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_POINT_SQUARE_HPP