diff --git a/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp b/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp index 47ebc73e9..9fd6c08fa 100644 --- a/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp +++ b/include/boost/geometry/algorithms/detail/covered_by/implementation.hpp @@ -74,6 +74,23 @@ struct covered_by } }; +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 { diff --git a/test/algorithms/covered_by/covered_by.cpp b/test/algorithms/covered_by/covered_by.cpp index 52506961b..e542f6532 100644 --- a/test/algorithms/covered_by/covered_by.cpp +++ b/test/algorithms/covered_by/covered_by.cpp @@ -119,6 +119,10 @@ void test_all() test_geometry("POINT(1 0)", "BOX(0 0,2 2)", true); test_geometry("POINT(3 3)", "BOX(0 0,2 2)", false); + test_geometry("MULTIPOINT(1 1, 2 1)", "BOX(0 0,3 3)", true); + test_geometry("MULTIPOINT(0 0, 1 1)", "BOX(0 0,2 2)", true); + test_geometry("MULTIPOINT(0 0, 3 4)", "BOX(0 0,2 2)", false); + test_geometry("BOX(1 1,2 2)", "BOX(0 0,3 3)", true); test_geometry("BOX(0 0,3 3)", "BOX(1 1,2 2)", false); test_geometry("BOX(0 0,2 2)", "BOX(0 0,3 3)", true); diff --git a/test/algorithms/covered_by/covered_by_sph_geo.cpp b/test/algorithms/covered_by/covered_by_sph_geo.cpp index 94730d52c..c3a1cd766 100644 --- a/test/algorithms/covered_by/covered_by_sph_geo.cpp +++ b/test/algorithms/covered_by/covered_by_sph_geo.cpp @@ -1,6 +1,8 @@ // Boost.Geometry -// Copyright (c) 2016-2021 Oracle and/or its affiliates. +// Copyright (c) 2016-2022 Oracle and/or its affiliates. + +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -44,6 +46,16 @@ void test_point_box() test_geometry("POINT(-177.872408 1)", "BOX(179.08882 0, 182.127592 2)", true); } +template +void test_multi_point_box() +{ + typedef bg::model::box

box_t; + typedef bg::model::multi_point

mp_t; + + test_geometry("MULTIPOINT(0 0,1 1)", "BOX(0 0, 1 1)", true); + test_geometry("MULTIPOINT(1 1,3 3)", "BOX(0 0, 2 2)", false); +} + template void test_box_box() { @@ -113,6 +125,7 @@ template void test_cs() { test_point_box

(); + test_multi_point_box

(); test_box_box

(); test_point_polygon

(); }