mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
Support covered_by(linear,box).
This commit is contained in:
parent
b44e0a9fbe
commit
fd295f15c4
@ -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] ]]
|
||||
|
@ -60,16 +60,16 @@ struct use_relate
|
||||
}
|
||||
};
|
||||
|
||||
struct areal_covered_by_box
|
||||
struct geometry_covered_by_box
|
||||
{
|
||||
template <typename Areal, typename Box, typename Strategy>
|
||||
static inline bool apply(Areal const& areal, Box const& box, Strategy const& strategy)
|
||||
template <typename Geometry, typename Box, typename Strategy>
|
||||
static inline bool apply(Geometry const& geometry, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
typedef typename point_type<Areal>::type point_type;
|
||||
typedef model::box<point_type> box_type;
|
||||
using point_type = typename point_type<Geometry>::type;
|
||||
using box_type = model::box<point_type>;
|
||||
|
||||
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 <typename Point, typename Box>
|
||||
struct covered_by<Point, Box, point_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
return strategy.covered_by(point, box).apply(point, box);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename MultiPoint, typename Box>
|
||||
struct covered_by<MultiPoint, Box, multi_point_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
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 <typename Box1, typename Box2>
|
||||
struct covered_by<Box1, Box2, box_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
|
||||
{
|
||||
assert_dimension_equal<Box1, Box2>();
|
||||
return strategy.covered_by(box1, box2).apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Ring, typename Box>
|
||||
struct covered_by<Ring, Box, ring_tag, box_tag>
|
||||
: public detail::covered_by::areal_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Polygon, typename Box>
|
||||
struct covered_by<Polygon, Box, polygon_tag, box_tag>
|
||||
: public detail::covered_by::areal_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename MultiPolygon, typename Box>
|
||||
struct covered_by<MultiPolygon, Box, multi_polygon_tag, box_tag>
|
||||
: public detail::covered_by::areal_covered_by_box
|
||||
{};
|
||||
|
||||
// P/P
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
@ -338,6 +285,59 @@ struct covered_by<Box, Polygon, box_tag, multi_polygon_tag>
|
||||
: public detail::covered_by::use_relate
|
||||
{};
|
||||
|
||||
// Geometry/Box
|
||||
|
||||
template <typename Point, typename Box>
|
||||
struct covered_by<Point, Box, point_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
return strategy.covered_by(point, box).apply(point, box);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename MultiPoint, typename Box>
|
||||
struct covered_by<MultiPoint, Box, multi_point_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Linestring, typename Box>
|
||||
struct covered_by<Linestring, Box, linestring_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename MultiLinestring, typename Box>
|
||||
struct covered_by<MultiLinestring, Box, multi_linestring_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Ring, typename Box>
|
||||
struct covered_by<Ring, Box, ring_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Polygon, typename Box>
|
||||
struct covered_by<Polygon, Box, polygon_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename MultiPolygon, typename Box>
|
||||
struct covered_by<MultiPolygon, Box, multi_polygon_tag, box_tag>
|
||||
: public detail::covered_by::geometry_covered_by_box
|
||||
{};
|
||||
|
||||
template <typename Box1, typename Box2>
|
||||
struct covered_by<Box1, Box2, box_tag, box_tag>
|
||||
{
|
||||
template <typename Strategy>
|
||||
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
|
||||
{
|
||||
assert_dimension_equal<Box1, Box2>();
|
||||
return strategy.covered_by(box1, box2).apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
@ -116,6 +116,11 @@ void test_all()
|
||||
test_geometry<mpt<P>, box<P>>("MULTIPOINT(0 0, 1 1)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<mpt<P>, box<P>>("MULTIPOINT(0 0, 3 4)", "BOX(0 0,2 2)", false);
|
||||
|
||||
test_geometry<ls<P>, box<P>>("LINESTRING(0 0,1 1,1 2)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<ls<P>, box<P>>("LINESTRING(0 0,1 1,1 2,1 3)", "BOX(0 0,2 2)", false);
|
||||
test_geometry<mls<P>, box<P>>("MULTILINESTRING((0 0,1 1,1 2),(0 1,1 0))", "BOX(0 0,2 2)", true);
|
||||
test_geometry<mls<P>, box<P>>("MULTILINESTRING((0 0,1 1,1 2,1 3),(0 1,1 0))", "BOX(0 0,2 2)", false);
|
||||
|
||||
test_geometry<ring<P>, box<P>>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);
|
||||
test_geometry<ring<P>, box<P>>("POLYGON((0 0,0 3,3 3,5 0,0 0))", "BOX(0 0,4 4)", false);
|
||||
test_geometry<poly<P>, box<P>>("POLYGON((0 0,0 3,3 3,3 0,0 0))", "BOX(0 0,4 4)", true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user