Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:03

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2013-2022.
0008 // Modifications copyright (c) 2013-2022 Oracle and/or its affiliates.
0009 
0010 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0011 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0012 
0013 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0014 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0015 
0016 // Use, modification and distribution is subject to the Boost Software License,
0017 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0018 // http://www.boost.org/LICENSE_1_0.txt)
0019 
0020 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP
0021 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP
0022 
0023 #include <cstddef>
0024 #include <boost/core/ignore_unused.hpp>
0025 #include <boost/geometry/algorithms/detail/covered_by/interface.hpp>
0026 #include <boost/geometry/algorithms/detail/within/implementation.hpp>
0027 #include <boost/geometry/strategies/relate/cartesian.hpp>
0028 #include <boost/geometry/strategies/relate/geographic.hpp>
0029 #include <boost/geometry/strategies/relate/spherical.hpp>
0030 
0031 
0032 namespace boost { namespace geometry
0033 {
0034 
0035 #ifndef DOXYGEN_NO_DETAIL
0036 namespace detail { namespace covered_by {
0037 
0038 struct use_point_in_geometry
0039 {
0040     template <typename Geometry1, typename Geometry2, typename Strategy>
0041     static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
0042                              Strategy const& strategy)
0043     {
0044         return detail::within::covered_by_point_geometry(geometry1, geometry2, strategy);
0045     }
0046 };
0047 
0048 struct use_relate
0049 {
0050     template <typename Geometry1, typename Geometry2, typename Strategy>
0051     static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
0052                              Strategy const& strategy)
0053     {
0054         return detail::relate::relate_impl
0055             <
0056                 detail::de9im::static_mask_covered_by_type,
0057                 Geometry1,
0058                 Geometry2
0059             >::apply(geometry1, geometry2, strategy);
0060     }
0061 };
0062 
0063 struct geometry_covered_by_box
0064 {
0065     template <typename Geometry, typename Box, typename Strategy>
0066     static inline bool apply(Geometry const& geometry, Box const& box, Strategy const& strategy)
0067     {
0068         using point_type = typename point_type<Geometry>::type;
0069         using mutable_point_type = typename helper_geometry<point_type>::type;
0070         using box_type = model::box<mutable_point_type>;
0071 
0072         // TODO: this is not optimal since the process should be able to terminate if a point is found
0073         // outside of the box without computing the whole envelope
0074         box_type box_areal;
0075         geometry::envelope(geometry, box_areal, strategy);
0076         return strategy.covered_by(box_areal, box).apply(box_areal, box);
0077     }
0078 };
0079 
0080 }} // namespace detail::covered_by
0081 #endif // DOXYGEN_NO_DETAIL
0082 
0083 #ifndef DOXYGEN_NO_DISPATCH
0084 namespace dispatch
0085 {
0086 
0087 // P/P
0088 
0089 template <typename Point1, typename Point2>
0090 struct covered_by<Point1, Point2, point_tag, point_tag>
0091     : public detail::covered_by::use_point_in_geometry
0092 {};
0093 
0094 template <typename Point, typename MultiPoint>
0095 struct covered_by<Point, MultiPoint, point_tag, multi_point_tag>
0096     : public detail::covered_by::use_point_in_geometry
0097 {};
0098 
0099 template <typename MultiPoint, typename Point>
0100 struct covered_by<MultiPoint, Point, multi_point_tag, point_tag>
0101     : public detail::within::multi_point_point
0102 {};
0103 
0104 template <typename MultiPoint1, typename MultiPoint2>
0105 struct covered_by<MultiPoint1, MultiPoint2, multi_point_tag, multi_point_tag>
0106     : public detail::within::multi_point_multi_point
0107 {};
0108 
0109 // P/L
0110 
0111 template <typename Point, typename Segment>
0112 struct covered_by<Point, Segment, point_tag, segment_tag>
0113     : public detail::covered_by::use_point_in_geometry
0114 {};
0115 
0116 template <typename Point, typename Linestring>
0117 struct covered_by<Point, Linestring, point_tag, linestring_tag>
0118     : public detail::covered_by::use_point_in_geometry
0119 {};
0120 
0121 template <typename Point, typename MultiLinestring>
0122 struct covered_by<Point, MultiLinestring, point_tag, multi_linestring_tag>
0123     : public detail::covered_by::use_point_in_geometry
0124 {};
0125 
0126 template <typename MultiPoint, typename Segment>
0127 struct covered_by<MultiPoint, Segment, multi_point_tag, segment_tag>
0128     : public detail::within::multi_point_single_geometry<false>
0129 {};
0130 
0131 template <typename MultiPoint, typename Linestring>
0132 struct covered_by<MultiPoint, Linestring, multi_point_tag, linestring_tag>
0133     : public detail::within::multi_point_single_geometry<false>
0134 {};
0135 
0136 template <typename MultiPoint, typename MultiLinestring>
0137 struct covered_by<MultiPoint, MultiLinestring, multi_point_tag, multi_linestring_tag>
0138     : public detail::within::multi_point_multi_geometry<false>
0139 {};
0140 
0141 // P/A
0142 
0143 template <typename Point, typename Ring>
0144 struct covered_by<Point, Ring, point_tag, ring_tag>
0145     : public detail::covered_by::use_point_in_geometry
0146 {};
0147 
0148 template <typename Point, typename Polygon>
0149 struct covered_by<Point, Polygon, point_tag, polygon_tag>
0150     : public detail::covered_by::use_point_in_geometry
0151 {};
0152 
0153 template <typename Point, typename MultiPolygon>
0154 struct covered_by<Point, MultiPolygon, point_tag, multi_polygon_tag>
0155     : public detail::covered_by::use_point_in_geometry
0156 {};
0157 
0158 template <typename MultiPoint, typename Ring>
0159 struct covered_by<MultiPoint, Ring, multi_point_tag, ring_tag>
0160     : public detail::within::multi_point_single_geometry<false>
0161 {};
0162 
0163 template <typename MultiPoint, typename Polygon>
0164 struct covered_by<MultiPoint, Polygon, multi_point_tag, polygon_tag>
0165     : public detail::within::multi_point_single_geometry<false>
0166 {};
0167 
0168 template <typename MultiPoint, typename MultiPolygon>
0169 struct covered_by<MultiPoint, MultiPolygon, multi_point_tag, multi_polygon_tag>
0170     : public detail::within::multi_point_multi_geometry<false>
0171 {};
0172 
0173 // L/L
0174 
0175 template <typename Linestring1, typename Linestring2>
0176 struct covered_by<Linestring1, Linestring2, linestring_tag, linestring_tag>
0177     : public detail::covered_by::use_relate
0178 {};
0179 
0180 template <typename Linestring, typename MultiLinestring>
0181 struct covered_by<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag>
0182     : public detail::covered_by::use_relate
0183 {};
0184 
0185 template <typename MultiLinestring, typename Linestring>
0186 struct covered_by<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag>
0187     : public detail::covered_by::use_relate
0188 {};
0189 
0190 template <typename MultiLinestring1, typename MultiLinestring2>
0191 struct covered_by<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag>
0192     : public detail::covered_by::use_relate
0193 {};
0194 
0195 // L/A
0196 
0197 template <typename Linestring, typename Ring>
0198 struct covered_by<Linestring, Ring, linestring_tag, ring_tag>
0199     : public detail::covered_by::use_relate
0200 {};
0201 
0202 template <typename MultiLinestring, typename Ring>
0203 struct covered_by<MultiLinestring, Ring, multi_linestring_tag, ring_tag>
0204     : public detail::covered_by::use_relate
0205 {};
0206 
0207 template <typename Linestring, typename Polygon>
0208 struct covered_by<Linestring, Polygon, linestring_tag, polygon_tag>
0209     : public detail::covered_by::use_relate
0210 {};
0211 
0212 template <typename MultiLinestring, typename Polygon>
0213 struct covered_by<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag>
0214     : public detail::covered_by::use_relate
0215 {};
0216 
0217 template <typename Linestring, typename MultiPolygon>
0218 struct covered_by<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag>
0219     : public detail::covered_by::use_relate
0220 {};
0221 
0222 template <typename MultiLinestring, typename MultiPolygon>
0223 struct covered_by<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag>
0224     : public detail::covered_by::use_relate
0225 {};
0226 
0227 // A/A
0228 
0229 template <typename Ring1, typename Ring2>
0230 struct covered_by<Ring1, Ring2, ring_tag, ring_tag>
0231     : public detail::covered_by::use_relate
0232 {};
0233 
0234 template <typename Ring, typename Polygon>
0235 struct covered_by<Ring, Polygon, ring_tag, polygon_tag>
0236     : public detail::covered_by::use_relate
0237 {};
0238 
0239 template <typename Polygon, typename Ring>
0240 struct covered_by<Polygon, Ring, polygon_tag, ring_tag>
0241     : public detail::covered_by::use_relate
0242 {};
0243 
0244 template <typename Polygon1, typename Polygon2>
0245 struct covered_by<Polygon1, Polygon2, polygon_tag, polygon_tag>
0246     : public detail::covered_by::use_relate
0247 {};
0248 
0249 template <typename Ring, typename MultiPolygon>
0250 struct covered_by<Ring, MultiPolygon, ring_tag, multi_polygon_tag>
0251     : public detail::covered_by::use_relate
0252 {};
0253 
0254 template <typename MultiPolygon, typename Ring>
0255 struct covered_by<MultiPolygon, Ring, multi_polygon_tag, ring_tag>
0256     : public detail::covered_by::use_relate
0257 {};
0258 
0259 template <typename Polygon, typename MultiPolygon>
0260 struct covered_by<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag>
0261     : public detail::covered_by::use_relate
0262 {};
0263 
0264 template <typename MultiPolygon, typename Polygon>
0265 struct covered_by<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag>
0266     : public detail::covered_by::use_relate
0267 {};
0268 
0269 template <typename MultiPolygon1, typename MultiPolygon2>
0270 struct covered_by<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag>
0271     : public detail::covered_by::use_relate
0272 {};
0273 
0274 // B/A
0275 
0276 template <typename Box, typename Polygon>
0277 struct covered_by<Box, Polygon, box_tag, ring_tag>
0278     : public detail::covered_by::use_relate
0279 {};
0280 
0281 template <typename Box, typename Polygon>
0282 struct covered_by<Box, Polygon, box_tag, polygon_tag>
0283     : public detail::covered_by::use_relate
0284 {};
0285 
0286 template <typename Box, typename Polygon>
0287 struct covered_by<Box, Polygon, box_tag, multi_polygon_tag>
0288     : public detail::covered_by::use_relate
0289 {};
0290 
0291 // Geometry/Box
0292 
0293 template <typename Point, typename Box>
0294 struct covered_by<Point, Box, point_tag, box_tag>
0295 {
0296     template <typename Strategy>
0297     static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
0298     {
0299         return strategy.covered_by(point, box).apply(point, box);
0300     }
0301 };
0302 
0303 template <typename MultiPoint, typename Box>
0304 struct covered_by<MultiPoint, Box, multi_point_tag, box_tag>
0305     : public detail::covered_by::geometry_covered_by_box
0306 {};
0307 
0308 template <typename Linestring, typename Box>
0309 struct covered_by<Linestring, Box, linestring_tag, box_tag>
0310     : public detail::covered_by::geometry_covered_by_box
0311 {};
0312 
0313 template <typename MultiLinestring, typename Box>
0314 struct covered_by<MultiLinestring, Box, multi_linestring_tag, box_tag>
0315     : public detail::covered_by::geometry_covered_by_box
0316 {};
0317 
0318 template <typename Ring, typename Box>
0319 struct covered_by<Ring, Box, ring_tag, box_tag>
0320     : public detail::covered_by::geometry_covered_by_box
0321 {};
0322 
0323 template <typename Polygon, typename Box>
0324 struct covered_by<Polygon, Box, polygon_tag, box_tag>
0325     : public detail::covered_by::geometry_covered_by_box
0326 {};
0327 
0328 template <typename MultiPolygon, typename Box>
0329 struct covered_by<MultiPolygon, Box, multi_polygon_tag, box_tag>
0330     : public detail::covered_by::geometry_covered_by_box
0331 {};
0332 
0333 template <typename Box1, typename Box2>
0334 struct covered_by<Box1, Box2, box_tag, box_tag>
0335 {
0336     template <typename Strategy>
0337     static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
0338     {
0339         assert_dimension_equal<Box1, Box2>();
0340         return strategy.covered_by(box1, box2).apply(box1, box2);
0341     }
0342 };
0343 
0344 } // namespace dispatch
0345 #endif // DOXYGEN_NO_DISPATCH
0346 
0347 }} // namespace boost::geometry
0348 
0349 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP