File indexing completed on 2025-01-18 09:35:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
0017
0018 #include <boost/geometry/algorithms/convert.hpp>
0019 #include <boost/geometry/algorithms/detail/covered_by/interface.hpp>
0020 #include <boost/geometry/algorithms/detail/envelope/interface.hpp>
0021 #include <boost/geometry/algorithms/detail/expand/interface.hpp>
0022
0023 #include <boost/geometry/index/detail/bounded_view.hpp>
0024
0025 namespace boost { namespace geometry { namespace index { namespace detail
0026 {
0027
0028 namespace dispatch
0029 {
0030
0031 template <typename Geometry,
0032 typename Bounds,
0033 typename TagGeometry = typename geometry::tag<Geometry>::type,
0034 typename TagBounds = typename geometry::tag<Bounds>::type>
0035 struct bounds
0036 {
0037 template <typename Strategy>
0038 static inline void apply(Geometry const& g, Bounds & b, Strategy const& )
0039 {
0040 geometry::convert(g, b);
0041 }
0042 };
0043
0044 template <typename Geometry, typename Bounds>
0045 struct bounds<Geometry, Bounds, segment_tag, box_tag>
0046 {
0047 template <typename Strategy>
0048 static inline void apply(Geometry const& g, Bounds & b, Strategy const& s)
0049 {
0050 index::detail::bounded_view<Geometry, Bounds, Strategy> v(g, s);
0051 geometry::convert(v, b);
0052 }
0053 };
0054
0055
0056 }
0057
0058
0059 template <typename Geometry, typename Bounds, typename Strategy>
0060 inline void bounds(Geometry const& g, Bounds & b, Strategy const& s)
0061 {
0062 concepts::check_concepts_and_equal_dimensions<Geometry const, Bounds>();
0063 dispatch::bounds<Geometry, Bounds>::apply(g, b, s);
0064 }
0065
0066
0067 namespace dispatch
0068 {
0069
0070 template <typename Bounds,
0071 typename Geometry,
0072 typename TagBounds = typename geometry::tag<Bounds>::type,
0073 typename TagGeometry = typename geometry::tag<Geometry>::type>
0074 struct expand
0075 {
0076
0077 };
0078
0079 template <typename Bounds, typename Geometry>
0080 struct expand<Bounds, Geometry, box_tag, point_tag>
0081 {
0082 static inline void apply(Bounds & b, Geometry const& g)
0083 {
0084 geometry::expand(b, g);
0085 }
0086
0087 template <typename Strategy>
0088 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
0089 {
0090 geometry::expand(b, g, s);
0091 }
0092 };
0093
0094 template <typename Bounds, typename Geometry>
0095 struct expand<Bounds, Geometry, box_tag, box_tag>
0096 {
0097 static inline void apply(Bounds & b, Geometry const& g)
0098 {
0099 geometry::expand(b, g);
0100 }
0101
0102 template <typename Strategy>
0103 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
0104 {
0105 geometry::expand(b, g, s);
0106 }
0107 };
0108
0109 template <typename Bounds, typename Geometry>
0110 struct expand<Bounds, Geometry, box_tag, segment_tag>
0111 {
0112 static inline void apply(Bounds & b, Geometry const& g)
0113 {
0114 geometry::expand(b, g);
0115 }
0116
0117 template <typename Strategy>
0118 static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
0119 {
0120 geometry::expand(b, geometry::return_envelope<Bounds>(g, s), s);
0121
0122
0123 }
0124 };
0125
0126
0127 }
0128
0129
0130 template <typename Bounds, typename Geometry, typename Strategy>
0131 inline void expand(Bounds & b, Geometry const& g, Strategy const& s)
0132 {
0133 dispatch::expand<Bounds, Geometry>::apply(b, g, s);
0134 }
0135
0136 template <typename Bounds, typename Geometry>
0137 inline void expand(Bounds & b, Geometry const& g, default_strategy const& )
0138 {
0139 dispatch::expand<Bounds, Geometry>::apply(b, g);
0140 }
0141
0142
0143 namespace dispatch
0144 {
0145
0146
0147 template <typename Geometry,
0148 typename Bounds,
0149 typename TagGeometry = typename geometry::tag<Geometry>::type,
0150 typename TagBounds = typename geometry::tag<Bounds>::type>
0151 struct covered_by_bounds
0152 {};
0153
0154 template <typename Geometry, typename Bounds>
0155 struct covered_by_bounds<Geometry, Bounds, point_tag, box_tag>
0156 {
0157 static inline bool apply(Geometry const& g, Bounds & b)
0158 {
0159 return geometry::covered_by(g, b);
0160 }
0161
0162 template <typename Strategy>
0163 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
0164 {
0165 return geometry::covered_by(g, b, s);
0166 }
0167 };
0168
0169 template <typename Geometry, typename Bounds>
0170 struct covered_by_bounds<Geometry, Bounds, box_tag, box_tag>
0171 {
0172 static inline bool apply(Geometry const& g, Bounds & b)
0173 {
0174 return geometry::covered_by(g, b);
0175 }
0176
0177 template <typename Strategy>
0178 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
0179 {
0180 return geometry::covered_by(g, b, s);
0181 }
0182 };
0183
0184 template <typename Geometry, typename Bounds>
0185 struct covered_by_bounds<Geometry, Bounds, segment_tag, box_tag>
0186 {
0187 static inline bool apply(Geometry const& g, Bounds & b)
0188 {
0189 typedef typename point_type<Geometry>::type point_type;
0190 typedef geometry::model::box<point_type> bounds_type;
0191 typedef index::detail::bounded_view<Geometry, bounds_type, default_strategy> view_type;
0192
0193 return geometry::covered_by(view_type(g, default_strategy()), b);
0194 }
0195
0196 template <typename Strategy>
0197 static inline bool apply(Geometry const& g, Bounds & b, Strategy const& strategy)
0198 {
0199 typedef typename point_type<Geometry>::type point_type;
0200 typedef geometry::model::box<point_type> bounds_type;
0201 typedef index::detail::bounded_view<Geometry, bounds_type, Strategy> view_type;
0202
0203 return geometry::covered_by(view_type(g, strategy), b, strategy);
0204 }
0205 };
0206
0207
0208 }
0209
0210
0211 template <typename Geometry, typename Bounds, typename Strategy>
0212 inline bool covered_by_bounds(Geometry const& g, Bounds & b, Strategy const& s)
0213 {
0214 return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b, s);
0215 }
0216
0217 template <typename Geometry, typename Bounds>
0218 inline bool covered_by_bounds(Geometry const& g, Bounds & b, default_strategy const& )
0219 {
0220 return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b);
0221 }
0222
0223
0224 }}}}
0225
0226
0227 #endif