1 // Boost.Geometry Index
3 // n-dimensional bounds
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
7 // This file was modified by Oracle on 2019-2021.
8 // Modifications copyright (c) 2019-2021 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
16 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
18 #include <boost/geometry/algorithms/convert.hpp>
19 #include <boost/geometry/algorithms/detail/covered_by/interface.hpp>
20 #include <boost/geometry/algorithms/detail/envelope/interface.hpp>
21 #include <boost/geometry/algorithms/detail/expand/interface.hpp>
23 #include <boost/geometry/index/detail/bounded_view.hpp>
25 namespace boost { namespace geometry { namespace index { namespace detail
31 template <typename Geometry,
33 typename TagGeometry = typename geometry::tag<Geometry>::type,
34 typename TagBounds = typename geometry::tag<Bounds>::type>
37 template <typename Strategy>
38 static inline void apply(Geometry const& g, Bounds & b, Strategy const& )
40 geometry::convert(g, b);
44 template <typename Geometry, typename Bounds>
45 struct bounds<Geometry, Bounds, segment_tag, box_tag>
47 template <typename Strategy>
48 static inline void apply(Geometry const& g, Bounds & b, Strategy const& s)
50 index::detail::bounded_view<Geometry, Bounds, Strategy> v(g, s);
51 geometry::convert(v, b);
56 } // namespace dispatch
59 template <typename Geometry, typename Bounds, typename Strategy>
60 inline void bounds(Geometry const& g, Bounds & b, Strategy const& s)
62 concepts::check_concepts_and_equal_dimensions<Geometry const, Bounds>();
63 dispatch::bounds<Geometry, Bounds>::apply(g, b, s);
70 template <typename Bounds,
72 typename TagBounds = typename geometry::tag<Bounds>::type,
73 typename TagGeometry = typename geometry::tag<Geometry>::type>
79 template <typename Bounds, typename Geometry>
80 struct expand<Bounds, Geometry, box_tag, point_tag>
82 static inline void apply(Bounds & b, Geometry const& g)
84 geometry::expand(b, g);
87 template <typename Strategy>
88 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
90 geometry::expand(b, g, s);
94 template <typename Bounds, typename Geometry>
95 struct expand<Bounds, Geometry, box_tag, box_tag>
97 static inline void apply(Bounds & b, Geometry const& g)
99 geometry::expand(b, g);
102 template <typename Strategy>
103 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
105 geometry::expand(b, g, s);
109 template <typename Bounds, typename Geometry>
110 struct expand<Bounds, Geometry, box_tag, segment_tag>
112 static inline void apply(Bounds & b, Geometry const& g)
114 geometry::expand(b, g);
117 template <typename Strategy>
118 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
120 geometry::expand(b, geometry::return_envelope<Bounds>(g, s), s);
121 // requires additional strategy
122 //geometry::expand(b, g, s);
127 } // namespace dispatch
130 template <typename Bounds, typename Geometry, typename Strategy>
131 inline void expand(Bounds & b, Geometry const& g, Strategy const& s)
133 dispatch::expand<Bounds, Geometry>::apply(b, g, s);
136 template <typename Bounds, typename Geometry>
137 inline void expand(Bounds & b, Geometry const& g, default_strategy const& )
139 dispatch::expand<Bounds, Geometry>::apply(b, g);
147 template <typename Geometry,
149 typename TagGeometry = typename geometry::tag<Geometry>::type,
150 typename TagBounds = typename geometry::tag<Bounds>::type>
151 struct covered_by_bounds
154 template <typename Geometry, typename Bounds>
155 struct covered_by_bounds<Geometry, Bounds, point_tag, box_tag>
157 static inline bool apply(Geometry const& g, Bounds & b)
159 return geometry::covered_by(g, b);
162 template <typename Strategy>
163 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
165 return geometry::covered_by(g, b, s);
169 template <typename Geometry, typename Bounds>
170 struct covered_by_bounds<Geometry, Bounds, box_tag, box_tag>
172 static inline bool apply(Geometry const& g, Bounds & b)
174 return geometry::covered_by(g, b);
177 template <typename Strategy>
178 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
180 return geometry::covered_by(g, b, s);
184 template <typename Geometry, typename Bounds>
185 struct covered_by_bounds<Geometry, Bounds, segment_tag, box_tag>
187 static inline bool apply(Geometry const& g, Bounds & b)
189 typedef typename point_type<Geometry>::type point_type;
190 typedef geometry::model::box<point_type> bounds_type;
191 typedef index::detail::bounded_view<Geometry, bounds_type, default_strategy> view_type;
193 return geometry::covered_by(view_type(g, default_strategy()), b);
196 template <typename Strategy>
197 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& strategy)
199 typedef typename point_type<Geometry>::type point_type;
200 typedef geometry::model::box<point_type> bounds_type;
201 typedef index::detail::bounded_view<Geometry, bounds_type, Strategy> view_type;
203 return geometry::covered_by(view_type(g, strategy), b, strategy);
208 } // namespace dispatch
211 template <typename Geometry, typename Bounds, typename Strategy>
212 inline bool covered_by_bounds(Geometry const& g, Bounds & b, Strategy const& s)
214 return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b, s);
217 template <typename Geometry, typename Bounds>
218 inline bool covered_by_bounds(Geometry const& g, Bounds & b, default_strategy const& )
220 return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b);
224 }}}} // namespace boost::geometry::index::detail
227 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP