diff --git a/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp index 84d02b794..1ff46d70e 100644 --- a/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp @@ -99,7 +99,8 @@ struct point_in_geometry_dispatch ++boundaries; } - return boundaries % 2 ? 1 : 0; + // if the number of boundaries is odd, the point is on the boundary + return boundaries % 2 ? 0 : 1; } }; diff --git a/test/algorithms/test_touches.hpp b/test/algorithms/test_touches.hpp index 79af24d75..050f9b186 100644 --- a/test/algorithms/test_touches.hpp +++ b/test/algorithms/test_touches.hpp @@ -25,6 +25,12 @@ #include +#include +#include +#include + +#include + template void test_touches(std::string const& wkt1, std::string const& wkt2, bool expected) diff --git a/test/algorithms/touches.cpp b/test/algorithms/touches.cpp index dfea094ac..65c4e3872 100644 --- a/test/algorithms/touches.cpp +++ b/test/algorithms/touches.cpp @@ -22,6 +22,8 @@ void test_all() { typedef bg::model::polygon

polygon; typedef bg::model::linestring

linestring; + typedef bg::model::multi_polygon mpolygon; + typedef bg::model::multi_linestring mlinestring; // Just a normal polygon test_self_touches("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); @@ -137,11 +139,18 @@ void test_all() test_touches("POINT(50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false); test_touches("POINT(30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false); + // Point-MultiPolygon + test_touches("POINT(40 50)", "MULTIPOLYGON(((40 40,40 60,60 60,60 40,40 40)),((0 0,0 10,10 10,10 0)))", true); + // Point-Linestring test_touches("POINT(0 0)", "LINESTRING(0 0, 2 2, 10 2)", true); test_touches("POINT(2 2)", "LINESTRING(0 0, 2 2, 10 2)", false); test_touches("POINT(1 1)", "LINESTRING(0 0, 2 2, 10 2)", false); test_touches("POINT(5 5)", "LINESTRING(0 0, 2 2, 10 2)", false); + + // Point-MultiLinestring + test_touches("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(5 5, 6 6))", true); + test_touches("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(0 0, 6 6))", false); } diff --git a/test/algorithms/within.cpp b/test/algorithms/within.cpp index 175ec8993..8ea79289e 100644 --- a/test/algorithms/within.cpp +++ b/test/algorithms/within.cpp @@ -44,8 +44,8 @@ void test_all() // multi_linestrings typedef bg::model::multi_linestring mls; - test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", false); - test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", true); + test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", true); + test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", false); typedef bg::model::box

box_type;