1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 6 7 // This file was modified by Oracle on 2013, 2014, 2017, 2019. 8 // Modifications copyright (c) 2013-2019 Oracle and/or its affiliates. 9 10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 11 12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 14 15 // Use, modification and distribution is subject to the Boost Software License, 16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 17 // http://www.boost.org/LICENSE_1_0.txt) 18 19 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP 20 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP 21 22 #include <cstddef> 23 #include <boost/core/ignore_unused.hpp> 24 #include <boost/geometry/algorithms/detail/covered_by/interface.hpp> 25 #include <boost/geometry/algorithms/detail/within/implementation.hpp> 26 27 28 namespace boost { namespace geometry 29 { 30 31 #ifndef DOXYGEN_NO_DETAIL 32 namespace detail { namespace covered_by { 33 34 struct use_point_in_geometry 35 { 36 template <typename Geometry1, typename Geometry2, typename Strategy> applyboost::geometry::detail::covered_by::use_point_in_geometry37 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) 38 { 39 return detail::within::covered_by_point_geometry(geometry1, geometry2, strategy); 40 } 41 }; 42 43 struct use_relate 44 { 45 template <typename Geometry1, typename Geometry2, typename Strategy> applyboost::geometry::detail::covered_by::use_relate46 static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) 47 { 48 typedef typename detail::de9im::static_mask_covered_by_type 49 < 50 Geometry1, Geometry2 51 >::type covered_by_mask; 52 return geometry::relate(geometry1, geometry2, covered_by_mask(), strategy); 53 } 54 }; 55 56 }} // namespace detail::covered_by 57 #endif // DOXYGEN_NO_DETAIL 58 59 #ifndef DOXYGEN_NO_DISPATCH 60 namespace dispatch 61 { 62 63 template <typename Point, typename Box> 64 struct covered_by<Point, Box, point_tag, box_tag> 65 { 66 template <typename Strategy> applyboost::geometry::dispatch::covered_by67 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy) 68 { 69 ::boost::ignore_unused(strategy); 70 return strategy.apply(point, box); 71 } 72 }; 73 74 template <typename Box1, typename Box2> 75 struct covered_by<Box1, Box2, box_tag, box_tag> 76 { 77 template <typename Strategy> applyboost::geometry::dispatch::covered_by78 static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) 79 { 80 assert_dimension_equal<Box1, Box2>(); 81 ::boost::ignore_unused(strategy); 82 return strategy.apply(box1, box2); 83 } 84 }; 85 86 87 // P/P 88 89 template <typename Point1, typename Point2> 90 struct covered_by<Point1, Point2, point_tag, point_tag> 91 : public detail::covered_by::use_point_in_geometry 92 {}; 93 94 template <typename Point, typename MultiPoint> 95 struct covered_by<Point, MultiPoint, point_tag, multi_point_tag> 96 : public detail::covered_by::use_point_in_geometry 97 {}; 98 99 template <typename MultiPoint, typename Point> 100 struct covered_by<MultiPoint, Point, multi_point_tag, point_tag> 101 : public detail::within::multi_point_point 102 {}; 103 104 template <typename MultiPoint1, typename MultiPoint2> 105 struct covered_by<MultiPoint1, MultiPoint2, multi_point_tag, multi_point_tag> 106 : public detail::within::multi_point_multi_point 107 {}; 108 109 // P/L 110 111 template <typename Point, typename Segment> 112 struct covered_by<Point, Segment, point_tag, segment_tag> 113 : public detail::covered_by::use_point_in_geometry 114 {}; 115 116 template <typename Point, typename Linestring> 117 struct covered_by<Point, Linestring, point_tag, linestring_tag> 118 : public detail::covered_by::use_point_in_geometry 119 {}; 120 121 template <typename Point, typename MultiLinestring> 122 struct covered_by<Point, MultiLinestring, point_tag, multi_linestring_tag> 123 : public detail::covered_by::use_point_in_geometry 124 {}; 125 126 template <typename MultiPoint, typename Segment> 127 struct covered_by<MultiPoint, Segment, multi_point_tag, segment_tag> 128 : public detail::within::multi_point_single_geometry<false> 129 {}; 130 131 template <typename MultiPoint, typename Linestring> 132 struct covered_by<MultiPoint, Linestring, multi_point_tag, linestring_tag> 133 : public detail::within::multi_point_single_geometry<false> 134 {}; 135 136 template <typename MultiPoint, typename MultiLinestring> 137 struct covered_by<MultiPoint, MultiLinestring, multi_point_tag, multi_linestring_tag> 138 : public detail::within::multi_point_multi_geometry<false> 139 {}; 140 141 // P/A 142 143 template <typename Point, typename Ring> 144 struct covered_by<Point, Ring, point_tag, ring_tag> 145 : public detail::covered_by::use_point_in_geometry 146 {}; 147 148 template <typename Point, typename Polygon> 149 struct covered_by<Point, Polygon, point_tag, polygon_tag> 150 : public detail::covered_by::use_point_in_geometry 151 {}; 152 153 template <typename Point, typename MultiPolygon> 154 struct covered_by<Point, MultiPolygon, point_tag, multi_polygon_tag> 155 : public detail::covered_by::use_point_in_geometry 156 {}; 157 158 template <typename MultiPoint, typename Ring> 159 struct covered_by<MultiPoint, Ring, multi_point_tag, ring_tag> 160 : public detail::within::multi_point_single_geometry<false> 161 {}; 162 163 template <typename MultiPoint, typename Polygon> 164 struct covered_by<MultiPoint, Polygon, multi_point_tag, polygon_tag> 165 : public detail::within::multi_point_single_geometry<false> 166 {}; 167 168 template <typename MultiPoint, typename MultiPolygon> 169 struct covered_by<MultiPoint, MultiPolygon, multi_point_tag, multi_polygon_tag> 170 : public detail::within::multi_point_multi_geometry<false> 171 {}; 172 173 // L/L 174 175 template <typename Linestring1, typename Linestring2> 176 struct covered_by<Linestring1, Linestring2, linestring_tag, linestring_tag> 177 : public detail::covered_by::use_relate 178 {}; 179 180 template <typename Linestring, typename MultiLinestring> 181 struct covered_by<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag> 182 : public detail::covered_by::use_relate 183 {}; 184 185 template <typename MultiLinestring, typename Linestring> 186 struct covered_by<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag> 187 : public detail::covered_by::use_relate 188 {}; 189 190 template <typename MultiLinestring1, typename MultiLinestring2> 191 struct covered_by<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag> 192 : public detail::covered_by::use_relate 193 {}; 194 195 // L/A 196 197 template <typename Linestring, typename Ring> 198 struct covered_by<Linestring, Ring, linestring_tag, ring_tag> 199 : public detail::covered_by::use_relate 200 {}; 201 202 template <typename MultiLinestring, typename Ring> 203 struct covered_by<MultiLinestring, Ring, multi_linestring_tag, ring_tag> 204 : public detail::covered_by::use_relate 205 {}; 206 207 template <typename Linestring, typename Polygon> 208 struct covered_by<Linestring, Polygon, linestring_tag, polygon_tag> 209 : public detail::covered_by::use_relate 210 {}; 211 212 template <typename MultiLinestring, typename Polygon> 213 struct covered_by<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag> 214 : public detail::covered_by::use_relate 215 {}; 216 217 template <typename Linestring, typename MultiPolygon> 218 struct covered_by<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag> 219 : public detail::covered_by::use_relate 220 {}; 221 222 template <typename MultiLinestring, typename MultiPolygon> 223 struct covered_by<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag> 224 : public detail::covered_by::use_relate 225 {}; 226 227 // A/A 228 229 template <typename Ring1, typename Ring2> 230 struct covered_by<Ring1, Ring2, ring_tag, ring_tag> 231 : public detail::covered_by::use_relate 232 {}; 233 234 template <typename Ring, typename Polygon> 235 struct covered_by<Ring, Polygon, ring_tag, polygon_tag> 236 : public detail::covered_by::use_relate 237 {}; 238 239 template <typename Polygon, typename Ring> 240 struct covered_by<Polygon, Ring, polygon_tag, ring_tag> 241 : public detail::covered_by::use_relate 242 {}; 243 244 template <typename Polygon1, typename Polygon2> 245 struct covered_by<Polygon1, Polygon2, polygon_tag, polygon_tag> 246 : public detail::covered_by::use_relate 247 {}; 248 249 template <typename Ring, typename MultiPolygon> 250 struct covered_by<Ring, MultiPolygon, ring_tag, multi_polygon_tag> 251 : public detail::covered_by::use_relate 252 {}; 253 254 template <typename MultiPolygon, typename Ring> 255 struct covered_by<MultiPolygon, Ring, multi_polygon_tag, ring_tag> 256 : public detail::covered_by::use_relate 257 {}; 258 259 template <typename Polygon, typename MultiPolygon> 260 struct covered_by<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag> 261 : public detail::covered_by::use_relate 262 {}; 263 264 template <typename MultiPolygon, typename Polygon> 265 struct covered_by<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag> 266 : public detail::covered_by::use_relate 267 {}; 268 269 template <typename MultiPolygon1, typename MultiPolygon2> 270 struct covered_by<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag> 271 : public detail::covered_by::use_relate 272 {}; 273 274 } // namespace dispatch 275 #endif // DOXYGEN_NO_DISPATCH 276 277 }} // namespace boost::geometry 278 279 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP 280