diff --git a/doc/reference/status/covered_by_status.qbk b/doc/reference/status/covered_by_status.qbk index 8389252df..0b63984d0 100644 --- a/doc/reference/status/covered_by_status.qbk +++ b/doc/reference/status/covered_by_status.qbk @@ -3,7 +3,7 @@ [[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]] [[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] [[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] +[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ]] [[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] [[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[Polygon][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] diff --git a/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp b/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp index 58e2e659f..06b60040f 100644 --- a/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp @@ -60,16 +60,16 @@ struct use_relate } }; -struct areal_covered_by_box +struct geometry_covered_by_box { - template - static inline bool apply(Areal const& areal, Box const& box, Strategy const& strategy) + template + static inline bool apply(Geometry const& geometry, Box const& box, Strategy const& strategy) { - typedef typename point_type::type point_type; - typedef model::box box_type; + using point_type = typename point_type::type; + using box_type = model::box; box_type box_areal; - geometry::envelope(areal, box_areal, strategy); + geometry::envelope(geometry, box_areal, strategy); return strategy.covered_by(box_areal, box).apply(box_areal, box); } }; @@ -81,59 +81,6 @@ struct areal_covered_by_box namespace dispatch { -template -struct covered_by -{ - template - static inline bool apply(Point const& point, Box const& box, Strategy const& strategy) - { - return strategy.covered_by(point, box).apply(point, box); - } -}; - -template -struct covered_by -{ - template - static inline bool apply(MultiPoint const& mpoint, Box const& box, Strategy const& strategy) - { - for (auto point : mpoint) - { - if (! strategy.covered_by(point, box).apply(point, box)) - { - return false; - } - } - return true; - } -}; - -template -struct covered_by -{ - template - static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) - { - assert_dimension_equal(); - return strategy.covered_by(box1, box2).apply(box1, box2); - } -}; - -template -struct covered_by - : public detail::covered_by::areal_covered_by_box -{}; - -template -struct covered_by - : public detail::covered_by::areal_covered_by_box -{}; - -template -struct covered_by - : public detail::covered_by::areal_covered_by_box -{}; - // P/P template @@ -338,6 +285,59 @@ struct covered_by : public detail::covered_by::use_relate {}; +// Geometry/Box + +template +struct covered_by +{ + template + static inline bool apply(Point const& point, Box const& box, Strategy const& strategy) + { + return strategy.covered_by(point, box).apply(point, box); + } +}; + +template +struct covered_by + : public detail::covered_by::geometry_covered_by_box +{}; + +template +struct covered_by + : public detail::covered_by::geometry_covered_by_box +{}; + +template +struct covered_by + : public detail::covered_by::geometry_covered_by_box +{}; + +template +struct covered_by + : public detail::covered_by::geometry_covered_by_box +{}; + +template +struct covered_by + : public detail::covered_by::geometry_covered_by_box +{}; + +template +struct covered_by + : public detail::covered_by::geometry_covered_by_box +{}; + +template +struct covered_by +{ + template + static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) + { + assert_dimension_equal(); + return strategy.covered_by(box1, box2).apply(box1, box2); + } +}; + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH diff --git a/test/algorithms/covered_by/covered_by.cpp b/test/algorithms/covered_by/covered_by.cpp index 43ea9b625..84f69b0ce 100644 --- a/test/algorithms/covered_by/covered_by.cpp +++ b/test/algorithms/covered_by/covered_by.cpp @@ -116,6 +116,11 @@ void test_all() test_geometry, box

>("MULTIPOINT(0 0, 1 1)", "BOX(0 0,2 2)", true); test_geometry, box

>("MULTIPOINT(0 0, 3 4)", "BOX(0 0,2 2)", false); + test_geometry, box

>("LINESTRING(0 0,1 1,1 2)", "BOX(0 0,2 2)", true); + test_geometry, box

>("LINESTRING(0 0,1 1,1 2,1 3)", "BOX(0 0,2 2)", false); + test_geometry, box

>("MULTILINESTRING((0 0,1 1,1 2),(0 1,1 0))", "BOX(0 0,2 2)", true); + test_geometry, box

>("MULTILINESTRING((0 0,1 1,1 2,1 3),(0 1,1 0))", "BOX(0 0,2 2)", false); + test_geometry, box

>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true); test_geometry, box

>("POLYGON((0 0,0 3,3 3,5 0,0 0))", "BOX(0 0,4 4)", false); test_geometry, box

>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);