mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-12 05:51:47 +00:00
[geometry] added tests for touches(Pt, MLs) and touches(Pt, MPoly), fixed error in point_in_geometry(Pt, MLs), fixed error in within(Pt, MLs) tests
This commit is contained in:
parent
437c94ad77
commit
f95efb34ee
@ -99,7 +99,8 @@ struct point_in_geometry_dispatch<G, multi_linestring_tag>
|
|||||||
++boundaries;
|
++boundaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
return boundaries % 2 ? 1 : 0;
|
// if the number of boundaries is odd, the point is on the boundary
|
||||||
|
return boundaries % 2 ? 0 : 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@
|
|||||||
|
|
||||||
#include <boost/geometry/io/wkt/read.hpp>
|
#include <boost/geometry/io/wkt/read.hpp>
|
||||||
|
|
||||||
|
#include <boost/geometry/multi/geometries/multi_linestring.hpp>
|
||||||
|
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
|
||||||
|
#include <boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp>
|
||||||
|
|
||||||
|
#include <boost/geometry/multi/io/wkt/read.hpp>
|
||||||
|
|
||||||
template <typename Geometry1, typename Geometry2>
|
template <typename Geometry1, typename Geometry2>
|
||||||
void test_touches(std::string const& wkt1,
|
void test_touches(std::string const& wkt1,
|
||||||
std::string const& wkt2, bool expected)
|
std::string const& wkt2, bool expected)
|
||||||
|
@ -22,6 +22,8 @@ void test_all()
|
|||||||
{
|
{
|
||||||
typedef bg::model::polygon<P> polygon;
|
typedef bg::model::polygon<P> polygon;
|
||||||
typedef bg::model::linestring<P> linestring;
|
typedef bg::model::linestring<P> linestring;
|
||||||
|
typedef bg::model::multi_polygon<polygon> mpolygon;
|
||||||
|
typedef bg::model::multi_linestring<linestring> mlinestring;
|
||||||
|
|
||||||
// Just a normal polygon
|
// Just a normal polygon
|
||||||
test_self_touches<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false);
|
test_self_touches<polygon>("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<P, polygon>("POINT(50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
|
test_touches<P, polygon>("POINT(50 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
|
||||||
test_touches<P, polygon>("POINT(30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
|
test_touches<P, polygon>("POINT(30 50)", "POLYGON((40 40,40 60,60 60,60 40,40 40))", false);
|
||||||
|
|
||||||
|
// Point-MultiPolygon
|
||||||
|
test_touches<P, mpolygon>("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
|
// Point-Linestring
|
||||||
test_touches<P, linestring>("POINT(0 0)", "LINESTRING(0 0, 2 2, 10 2)", true);
|
test_touches<P, linestring>("POINT(0 0)", "LINESTRING(0 0, 2 2, 10 2)", true);
|
||||||
test_touches<P, linestring>("POINT(2 2)", "LINESTRING(0 0, 2 2, 10 2)", false);
|
test_touches<P, linestring>("POINT(2 2)", "LINESTRING(0 0, 2 2, 10 2)", false);
|
||||||
test_touches<P, linestring>("POINT(1 1)", "LINESTRING(0 0, 2 2, 10 2)", false);
|
test_touches<P, linestring>("POINT(1 1)", "LINESTRING(0 0, 2 2, 10 2)", false);
|
||||||
test_touches<P, linestring>("POINT(5 5)", "LINESTRING(0 0, 2 2, 10 2)", false);
|
test_touches<P, linestring>("POINT(5 5)", "LINESTRING(0 0, 2 2, 10 2)", false);
|
||||||
|
|
||||||
|
// Point-MultiLinestring
|
||||||
|
test_touches<P, mlinestring>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(5 5, 6 6))", true);
|
||||||
|
test_touches<P, mlinestring>("POINT(0 0)", "MULTILINESTRING((0 0, 2 2, 10 2),(0 0, 6 6))", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ void test_all()
|
|||||||
|
|
||||||
// multi_linestrings
|
// multi_linestrings
|
||||||
typedef bg::model::multi_linestring<ls> mls;
|
typedef bg::model::multi_linestring<ls> mls;
|
||||||
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", false);
|
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", true);
|
||||||
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", true);
|
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", false);
|
||||||
|
|
||||||
typedef bg::model::box<P> box_type;
|
typedef bg::model::box<P> box_type;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user