[geos-commits] [SCM] GEOS branch main-relate-ng updated. 02aae25f7a243d65e2dcf4092dd6be84a731f818
git at osgeo.org
git at osgeo.org
Mon Jul 29 12:01:09 PDT 2024
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, main-relate-ng has been updated
via 02aae25f7a243d65e2dcf4092dd6be84a731f818 (commit)
from 1888b581f77146f16ee5f4d4fa36f97a91270837 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 02aae25f7a243d65e2dcf4092dd6be84a731f818
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Mon Jul 29 11:58:18 2024 -0700
Add remaining RelateNG tests
diff --git a/tests/unit/operation/relateng/RelateNGGCTest.cpp b/tests/unit/operation/relateng/RelateNGGCTest.cpp
new file mode 100644
index 000000000..0e0467222
--- /dev/null
+++ b/tests/unit/operation/relateng/RelateNGGCTest.cpp
@@ -0,0 +1,306 @@
+//
+// Test Suite for geos::operation::relateng::RelateNG class.
+
+#include <tut/tut.hpp>
+#include <utility.h>
+
+// geos
+#include "RelateNGTest.h"
+
+using namespace geos::geom;
+using namespace geos::operation::relateng;
+using geos::io::WKTReader;
+using geos::io::WKTWriter;
+
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by all tests
+struct test_relatenggc_data : test_relateng_support {
+
+ const char* wktAdjacentPolys = "GEOMETRYCOLLECTION (POLYGON ((5 5, 2 9, 9 9, 9 5, 5 5)), POLYGON ((3 1, 5 5, 9 5, 9 1, 3 1)), POLYGON ((1 9, 2 9, 5 5, 3 1, 1 1, 1 9)))";
+
+};
+
+
+typedef test_group<test_relatenggc_data> group;
+typedef group::object object;
+
+group test_relatenggc_group("geos::operation::relateng::RelateNGGC");
+
+
+// testDimensionWithEmpty
+template<>
+template<>
+void object::test<1> ()
+{
+ std::string a = "LINESTRING(0 0, 1 1)";
+ std::string b = "GEOMETRYCOLLECTION(POLYGON EMPTY,LINESTRING(0 0, 1 1))";
+ checkCoversCoveredBy(a, b, true);
+ checkEquals(a, b, true);
+}
+
+// see https://github.com/libgeos/geos/issues/1027
+// testMP_GLP_GEOS1027
+template<>
+template<>
+void object::test<2> ()
+{
+ std::string a = "MULTIPOLYGON (((0 0, 3 0, 3 3, 0 3, 0 0)))";
+ std::string b = "GEOMETRYCOLLECTION ( LINESTRING (1 2, 1 1), POINT (0 0))";
+ checkRelate(a, b, "1020F1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkContainsWithin(a, b, true);
+ checkCrosses(a, b, false);
+ checkEquals(a, b, false);
+}
+
+// see https://github.com/libgeos/geos/issues/1022
+// testGPL_A
+template<>
+template<>
+void object::test<3> ()
+{
+ std::string a = "GEOMETRYCOLLECTION (POINT (7 1), LINESTRING (6 5, 6 4))";
+ std::string b = "POLYGON ((7 1, 1 3, 3 9, 7 1))";
+ checkRelate(a, b, "F01FF0212");
+ checkIntersectsDisjoint(a, b, true);
+ checkContainsWithin(a, b, false);
+ checkCrosses(a, b, false);
+ checkTouches(a, b, true);
+ checkEquals(a, b, false);
+}
+
+// see https://github.com/libgeos/geos/issues/982
+// testP_GPL
+template<>
+template<>
+void object::test<4> ()
+{
+ std::string a = "POINT(0 0)";
+ std::string b = "GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 1 0))";
+ checkRelate(a, b, "F0FFFF102");
+ checkIntersectsDisjoint(a, b, true);
+ checkContainsWithin(a, b, false);
+ checkCrosses(a, b, false);
+ checkTouches(a, b, true);
+ checkEquals(a, b, false);
+}
+
+// testLineInOverlappingPolygonsTouchingInteriorEdge
+template<>
+template<>
+void object::test<5> ()
+{
+ std::string a = "LINESTRING (3 7, 7 3)";
+ std::string b = "GEOMETRYCOLLECTION (POLYGON ((1 9, 7 9, 7 3, 1 3, 1 9)), POLYGON ((9 1, 3 1, 3 7, 9 7, 9 1)))";
+ checkRelate(a, b, "1FF0FF212");
+ checkContainsWithin(b, a, true);
+}
+
+// testLineInOverlappingPolygonsCrossingInteriorEdgeAtVertex
+template<>
+template<>
+void object::test<6> ()
+{
+ std::string a = "LINESTRING (2 2, 8 8)";
+ std::string b = "GEOMETRYCOLLECTION (POLYGON ((1 1, 1 7, 7 7, 7 1, 1 1)), POLYGON ((9 9, 9 3, 3 3, 3 9, 9 9)))";
+ checkRelate(a, b, "1FF0FF212");
+ checkContainsWithin(b, a, true);
+}
+
+// testLineInOverlappingPolygonsCrossingInteriorEdgeProper
+template<>
+template<>
+void object::test<7> ()
+{
+ std::string a = "LINESTRING (2 4, 6 8)";
+ std::string b = "GEOMETRYCOLLECTION (POLYGON ((1 1, 1 7, 7 7, 7 1, 1 1)), POLYGON ((9 9, 9 3, 3 3, 3 9, 9 9)))";
+ checkRelate(a, b, "1FF0FF212");
+ checkContainsWithin(b, a, true);
+}
+
+// testPolygonInOverlappingPolygonsTouchingBoundaries
+template<>
+template<>
+void object::test<8> ()
+{
+ std::string a = "GEOMETRYCOLLECTION (POLYGON ((1 9, 6 9, 6 4, 1 4, 1 9)), POLYGON ((9 1, 4 1, 4 6, 9 6, 9 1)) )";
+ std::string b = "POLYGON ((2 6, 6 2, 8 4, 4 8, 2 6))";
+ checkRelate(a, b, "212F01FF2");
+ checkContainsWithin(a, b, true);
+}
+
+// testLineInOverlappingPolygonsBoundaries
+template<>
+template<>
+void object::test<9> ()
+{
+ std::string a = "LINESTRING (1 6, 9 6, 9 1, 1 1, 1 6)";
+ std::string b = "GEOMETRYCOLLECTION (POLYGON ((1 1, 1 6, 6 6, 6 1, 1 1)), POLYGON ((9 1, 4 1, 4 6, 9 6, 9 1)))";
+ checkRelate(a, b, "F1FFFF2F2");
+ checkContainsWithin(a, b, false);
+ checkCoversCoveredBy(a, b, false);
+ checkCoversCoveredBy(b, a, true);
+}
+
+// testLineCoversOverlappingPolygonsBoundaries
+template<>
+template<>
+void object::test<10> ()
+{
+ std::string a = "LINESTRING (1 6, 9 6, 9 1, 1 1, 1 6)";
+ std::string b = "GEOMETRYCOLLECTION (POLYGON ((1 1, 1 6, 6 6, 6 1, 1 1)), POLYGON ((9 1, 4 1, 4 6, 9 6, 9 1)))";
+ checkRelate(a, b, "F1FFFF2F2");
+ checkContainsWithin(b, a, false);
+ checkCoversCoveredBy(b, a, true);
+}
+
+// testAdjacentPolygonsContainedInAdjacentPolygons
+template<>
+template<>
+void object::test<11> ()
+{
+ std::string a = "GEOMETRYCOLLECTION (POLYGON ((2 2, 2 5, 4 5, 4 2, 2 2)), POLYGON ((8 2, 4 3, 4 4, 8 5, 8 2)))";
+ std::string b = "GEOMETRYCOLLECTION (POLYGON ((1 1, 1 6, 4 6, 4 1, 1 1)), POLYGON ((9 1, 4 1, 4 6, 9 6, 9 1)))";
+ checkRelate(a, b, "2FF1FF212");
+ checkContainsWithin(b, a, true);
+ checkCoversCoveredBy(b, a, true);
+}
+
+// testGCMultiPolygonIntersectsPolygon
+template<>
+template<>
+void object::test<12> ()
+{
+ std::string a = "POLYGON ((2 5, 3 5, 3 3, 2 3, 2 5))";
+ std::string b = "GEOMETRYCOLLECTION (MULTIPOLYGON (((1 4, 4 4, 4 1, 1 1, 1 4)), ((5 4, 8 4, 8 1, 5 1, 5 4))))";
+ checkRelate(a, b, "212101212");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(b, a, false);
+}
+
+
+// testPolygonContainsGCMultiPolygonElement
+template<>
+template<>
+void object::test<13> ()
+{
+ std::string a = "POLYGON ((0 5, 4 5, 4 1, 0 1, 0 5))";
+ std::string b = "GEOMETRYCOLLECTION (MULTIPOLYGON (((1 4, 3 4, 3 2, 1 2, 1 4)), ((6 4, 8 4, 8 2, 6 2, 6 4))))";
+ checkRelate(a, b, "212FF1212");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(b, a, false);
+}
+
+ /**
+ * Demonstrates the need for assigning computed nodes to their rings,
+ * so that subsequent PIP testing can report node as being on ring boundary.
+ */
+// testPolygonOverlappingGCPolygon
+template<>
+template<>
+void object::test<14> ()
+{
+ std::string a = "GEOMETRYCOLLECTION (POLYGON ((18.6 40.8, 16.8825 39.618567, 16.9319 39.5461, 17.10985 39.485133, 16.6143 38.4302, 16.43145 38.313267, 16.2 37.5, 14.8 37.8, 14.96475 40.474933, 18.6 40.8)))";
+ std::string b = "POLYGON ((16.3649953125 38.37219358064516, 16.3649953125 39.545924774193544, 17.949465625000002 39.545924774193544, 17.949465625000002 38.37219358064516, 16.3649953125 38.37219358064516))";
+ checkRelate(b, a, "212101212");
+ checkRelate(a, b, "212101212");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, false);
+}
+
+
+// testAdjPolygonsCoverPolygonWithEndpointInside
+template<>
+template<>
+void object::test<15> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "POLYGON ((3 7, 7 7, 7 3, 3 3, 3 7))";
+ checkRelate(b, a, "2FF1FF212");
+ checkRelate(a, b, "212FF1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, true);
+}
+
+// testAdjPolygonsCoverPointAtNode
+template<>
+template<>
+void object::test<16> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "POINT (5 5)";
+ checkRelate(b, a, "0FFFFF212");
+ checkRelate(a, b, "0F2FF1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, true);
+}
+
+// testAdjPolygonsCoverPointOnEdge
+template<>
+template<>
+void object::test<17> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "POINT (7 5)";
+ checkRelate(b, a, "0FFFFF212");
+ checkRelate(a, b, "0F2FF1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, true);
+}
+
+// testAdjPolygonsContainingPolygonTouchingInteriorEndpoint
+template<>
+template<>
+void object::test<18> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "POLYGON ((5 5, 7 5, 7 3, 5 3, 5 5))";
+ checkRelate(a, b, "212FF1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, true);
+}
+
+// testAdjPolygonsOverlappedByPolygonWithHole
+template<>
+template<>
+void object::test<19> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "POLYGON ((0 10, 10 10, 10 0, 0 0, 0 10), (2 8, 8 8, 8 2, 2 2, 2 8))";
+ checkRelate(a, b, "2121FF212");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, false);
+}
+
+// testAdjPolygonsContainingLine
+template<>
+template<>
+void object::test<20> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "LINESTRING (5 5, 7 7)";
+ checkRelate(a, b, "102FF1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, true);
+}
+
+// testAdjPolygonsContainingLineAndPoint
+template<>
+template<>
+void object::test<21> ()
+{
+ std::string a = wktAdjacentPolys;
+ std::string b = "GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (5 7, 7 7))";
+ checkRelate(a, b, "102FF1FF2");
+ checkIntersectsDisjoint(a, b, true);
+ checkCoversCoveredBy(a, b, true);
+}
+
+
+
+
+} // namespace tut
diff --git a/tests/unit/operation/relateng/RelateNGRobustnessTest.cpp b/tests/unit/operation/relateng/RelateNGRobustnessTest.cpp
new file mode 100644
index 000000000..95b8f545c
--- /dev/null
+++ b/tests/unit/operation/relateng/RelateNGRobustnessTest.cpp
@@ -0,0 +1,269 @@
+//
+// Test Suite for geos::operation::relateng::RelateNG class.
+
+#include <tut/tut.hpp>
+#include <utility.h>
+
+// geos
+#include "RelateNGTest.h"
+
+using namespace geos::geom;
+using namespace geos::operation::relateng;
+using geos::io::WKTReader;
+using geos::io::WKTWriter;
+
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by all tests
+struct test_relatengrobuestness_data : test_relateng_support {};
+
+
+typedef test_group<test_relatengrobuestness_data> group;
+typedef group::object object;
+
+group test_relatengrobuestness_group("geos::operation::relateng::RelateNGRobustness");
+
+
+//--------------------------------------------------------
+// GeometryCollection semantics
+//--------------------------------------------------------
+
+// see https://github.com/libgeos/geos/issues/1033
+// testGEOS_1033
+template<>
+template<>
+void object::test<1> ()
+{
+ checkContainsWithin("POLYGON((1 0,0 4,2 2,1 0))",
+ "GEOMETRYCOLLECTION(POINT(2 2),POINT(1 0),LINESTRING(1 2,1 1))",
+ true);
+}
+
+// https://github.com/libgeos/geos/issues/1027
+// testGEOS_1027
+template<>
+template<>
+void object::test<2> ()
+{
+ checkCoversCoveredBy("MULTIPOLYGON (((0 0, 3 0, 3 3, 0 3, 0 0)))",
+ "GEOMETRYCOLLECTION ( LINESTRING (1 2, 1 1), POINT (0 0))",
+ true);
+}
+
+// https://github.com/libgeos/geos/issues/1022
+// testGEOS_1022
+template<>
+template<>
+void object::test<3> ()
+{
+ checkCrosses("GEOMETRYCOLLECTION (POINT (7 1), LINESTRING (6 5, 6 4))",
+ "POLYGON ((7 1, 1 3, 3 9, 7 1))",
+ false);
+}
+
+// https://github.com/libgeos/geos/issues/1011
+// testGEOS_1011
+template<>
+template<>
+void object::test<4> ()
+{
+ std::string a = "LINESTRING(75 15,55 43)";
+ std::string b = "GEOMETRYCOLLECTION(POLYGON EMPTY,LINESTRING(75 15,55 43))";
+ checkCoversCoveredBy(a, b, true);
+ checkEquals(a, b, true);
+}
+
+// https://github.com/libgeos/geos/issues/983
+// testGEOS_983
+template<>
+template<>
+void object::test<5> ()
+{
+ std::string a = "POINT(0 0)";
+ std::string b = "GEOMETRYCOLLECTION(POINT (1 1), LINESTRING (1 1, 2 2))";
+ checkIntersectsDisjoint(a, b, false);
+}
+
+// https://github.com/libgeos/geos/issues/982
+// testGEOS_982
+template<>
+template<>
+void object::test<6> ()
+{
+ std::string a = "POINT(0 0)";
+ std::string b1 = "GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 1 0))";
+ checkContainsWithin(b1, a, false);
+ checkCoversCoveredBy(b1, a, true);
+
+ std::string b2 = "GEOMETRYCOLLECTION(LINESTRING(0 0, 1 0), POINT(0 0))";
+ checkContainsWithin(b2, a, false);
+ checkCoversCoveredBy(b2, a, true);
+}
+
+// https://github.com/libgeos/geos/issues/981
+// testGEOS_981
+template<>
+template<>
+void object::test<7> ()
+{
+ std::string a = "POINT(0 0)";
+ std::string b = "GEOMETRYCOLLECTION(LINESTRING(0 1, 0 0), POINT(0 0))";
+ checkRelateMatches(b, a, IntersectionMatrixPattern::CONTAINS_PROPERLY, false);
+}
+
+
+//--------------------------------------------------------
+// Noding robustness problems
+//--------------------------------------------------------
+
+// https://github.com/libgeos/geos/issues/1053
+// testGEOS_1053
+template<>
+template<>
+void object::test<8> ()
+{
+ std::string a = "MULTILINESTRING((2 4, 10 10),(15 10,10 5,5 10))";
+ std::string b = "MULTILINESTRING((2 4, 10 10))";
+ checkRelate(a, b, "1F1F00FF2");
+}
+
+// https://github.com/libgeos/geos/issues/968
+// testGEOS_968
+template<>
+template<>
+void object::test<9> ()
+{
+ std::string a2 = "LINESTRING(10 0, 0 20)";
+ std::string b2 = "POINT (9 2)";
+ checkCoversCoveredBy(a2, b2, true);
+}
+
+// xtestGEOS_968_2
+template<>
+template<>
+void object::test<10> ()
+{
+ std::string a = "LINESTRING(1 0, 0 2)";
+ std::string b = "POINT (0.9 0.2)";
+ //-- this case doesn't work due to numeric rounding for Orientation test
+ checkCoversCoveredBy(a, b,true);
+}
+
+// https://github.com/libgeos/geos/issues/933
+// testGEOS_933
+template<>
+template<>
+void object::test<11> ()
+{
+ std::string a = "LINESTRING (0 0, 1 1)";
+ std::string b = "LINESTRING (0.2 0.2, 0.5 0.5)";
+ checkCoversCoveredBy(a, b, true);
+}
+
+// https://github.com/libgeos/geos/issues/740
+// testGEOS_740
+template<>
+template<>
+void object::test<12> ()
+{
+ std::string a = "POLYGON ((1454700 -331500, 1455100 -330700, 1455466.6191038645 -331281.94727476506, 1455467.8182005754 -331293.26796732045, 1454700 -331500))";
+ std::string b = "LINESTRING (1455389.376551584 -331255.3803222172, 1455467.2422460222 -331287.83037053316)";
+ checkContainsWithin(a, b, false);
+}
+
+//--------------------------------------------------------
+// Robustness failures (TopologyException in old code)
+//--------------------------------------------------------
+
+// https://github.com/libgeos/geos/issues/766
+// testGEOS_766
+template<>
+template<>
+void object::test<13> ()
+{
+ std::string a = "POLYGON ((26639.240191093646 6039.3615818717535, 26639.240191093646 5889.361620883223, 28000.000095100608 5889.362081553552, 28000.000095100608 6039.361620882992, 28700.00019021402 6039.361620882992, 28700.00019021402 5889.361822800367, 29899.538842431968 5889.362160452064, 32465.59665091549 5889.362882757903, 32969.2837182586 -1313.697771558439, 31715.832811969216 -1489.87008918589, 31681.039836323587 -1242.3030298361555, 32279.3890331618 -1158.210534269224, 32237.63710287376 -861.1301136466199, 32682.89764107368 -802.0828534499739, 32247.445200905553 5439.292852892075, 31797.06861513178 5439.292852892075, 31797.06861513178 5639.36178850523, 29899.538849750803 5639.361268079038, 26167.69458275995 5639.3602445643955, 26379.03654594742 2617.0293071870683, 26778.062167926924 2644.9318977193907, 26792.01346261031 2445.419086759444, 26193.472956813417 2403.5650586598513, 25939.238114175267 6039.361685403233, 26639.240191093646 6039.3615818717535), (32682.89764107368
-802.0828534499738, 32682.89764107378 -802.0828534499669, 32247.445200905655 5439.292852892082, 32247.445200905553 5439.292852892075, 32682.89764107368 -802.0828534499738))";
+ std::string b = "POLYGON ((32450.100392347143 5889.362314133216, 32050.104955691 5891.272957209961, 32100.021071878822 16341.272221116333, 32500.016508656867 16339.361578039587, 32450.100392347143 5889.362314133216))";
+ checkIntersectsDisjoint(a, b, true);
+}
+
+// https://github.com/libgeos/geos/issues/1026
+// testGEOS_1026
+template<>
+template<>
+void object::test<14> ()
+{
+ std::string a = "POLYGON((335645.7810000004 5677846.65,335648.6579999998 5677845.801999999,335650.8630842535 5677845.143617179,335650.77673334075 5677844.7250704905,335642.90299999993 5677847.498,335645.7810000004 5677846.65))";
+ std::string b = "POLYGON((335642.903 5677847.498,335642.894 5677847.459,335645.92 5677846.69,335647.378 5677852.523,335644.403 5677853.285,335644.374 5677853.293,335642.903 5677847.498))";
+ checkTouches(a, b, false);
+}
+
+// https://github.com/libgeos/geos/issues/1069 =- too large to reproduce here
+// https://trac.osgeo.org/postgis/ticket/5583 =- too large to reproduce here
+// https://github.com/locationtech/jts/issues/1051
+// testJTS_1051
+template<>
+template<>
+void object::test<15> ()
+{
+ std::string a = "POLYGON ((414188.5999999999 6422867.1, 414193.7 6422866.5, 414205.1 6422859.4, 414223.7 6422846.8, 414229.6 6422843.2, 414235.2 6422835.4, 414224.7 6422837.9, 414219.4 6422842.1, 414210.9 6422849, 414199.2 6422857.6, 414191.1 6422863.4, 414188.5999999999 6422867.1))";
+ std::string b = "LINESTRING (414187.2 6422831.6, 414179 6422836.1, 414182.2 6422841.8, 414176.7 6422844, 414184.5 6422859.5, 414188.6 6422867.1)";
+ checkIntersectsDisjoint(a, b, true);
+}
+
+// https://trac.osgeo.org/postgis/ticket/5362
+// testPostGIS_5362
+template<>
+template<>
+void object::test<16> ()
+{
+ std::string a = "POLYGON ((-707259.66 -1121493.36, -707205.9 -1121605.808, -707310.5388 -1121540.5446, -707318.8200000001 -1121533.21, -707259.66 -1121493.36))";
+ std::string b = "POLYGON ((-707356.18 -1121550.69, -707332.82 -1121536.63, -707318.82 -1121533.21, -707321.72 -1121535.08, -707327.4 -1121539.21, -707356.18 -1121550.69))";
+ checkRelate(a, b, "2F2101212");
+ checkIntersectsDisjoint(a, b, true);
+}
+
+//--------------------------------------------------------
+// Topological Inconsistency
+//--------------------------------------------------------
+
+// https://github.com/libgeos/geos/issues/1064
+// testGEOS_1064
+template<>
+template<>
+void object::test<17> ()
+{
+ std::string a = "LINESTRING (16.330791631988802 68.75635661578073, 16.332533372319826 68.75496886016562)";
+ std::string b = "LINESTRING (16.30641253121884 68.75189557630306, 16.33167771310482 68.75565061843871)";
+ checkRelate(a, b, "F01FF0102");
+}
+
+// https://github.com/locationtech/jts/issues/396
+// testJTS_396
+template<>
+template<>
+void object::test<18> ()
+{
+ std::string a = "LINESTRING (1 0, 0 2, 0 0, 2 2)";
+ std::string b = "LINESTRING (0 0, 2 2)";
+ checkRelate(a, b, "101F00FF2");
+ checkCoversCoveredBy(a, b, true);
+}
+
+//https://github.com/locationtech/jts/issues/270
+// testJTS_270
+template<>
+template<>
+void object::test<19> ()
+{
+ std::string a = "LINESTRING(0.0 0.0, -10.0 1.2246467991473533E-15)";
+ std::string b = "LINESTRING(-9.999143275740073 -0.13089595571333978, -10.0 1.0535676356486768E-13)";
+ checkRelate(a, b, "FF10F0102");
+ checkIntersectsDisjoint(a, b, true);
+}
+
+
+
+} // namespace tut
diff --git a/tests/unit/operation/relateng/RelateNGTest.cpp b/tests/unit/operation/relateng/RelateNGTest.cpp
index c131746da..f8be3171b 100644
--- a/tests/unit/operation/relateng/RelateNGTest.cpp
+++ b/tests/unit/operation/relateng/RelateNGTest.cpp
@@ -5,16 +5,7 @@
#include <utility.h>
// geos
-#include <geos/io/WKTReader.h>
-// #include <geos/io/WKTWriter.h>
-#include <geos/geom/Geometry.h>
-#include <geos/operation/relateng/RelateNG.h>
-#include <geos/operation/relateng/RelatePredicate.h>
-#include <geos/operation/relateng/RelateMatrixPredicate.h>
-#include <geos/operation/relateng/IntersectionMatrixPattern.h>
-
-// std
-#include <memory>
+#include "RelateNGTest.h"
using namespace geos::geom;
using namespace geos::operation::relateng;
@@ -27,85 +18,8 @@ namespace tut {
//
// Common data used by all tests
-struct test_relateng_data {
+struct test_relateng_data : test_relateng_support {};
- WKTReader r;
- WKTWriter w;
-
- void checkIntersectsDisjoint(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::intersects(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::intersects(), wktb, wkta, expectedValue);
- checkPredicate(*RelatePredicate::disjoint(), wkta, wktb, ! expectedValue);
- checkPredicate(*RelatePredicate::disjoint(), wktb, wkta, ! expectedValue);
- }
-
- void checkContainsWithin(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::contains(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::within(), wktb, wkta, expectedValue);
- }
-
- void checkCoversCoveredBy(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::covers(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::coveredBy(), wktb, wkta, expectedValue);
- }
-
- void checkCrosses(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::crosses(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::crosses(), wktb, wkta, expectedValue);
- }
-
- void checkOverlaps(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::overlaps(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::overlaps(), wktb, wkta, expectedValue);
- }
-
- void checkTouches(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::touches(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::touches(), wktb, wkta, expectedValue);
- }
-
- void checkEquals(const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- checkPredicate(*RelatePredicate::equalsTopo(), wkta, wktb, expectedValue);
- checkPredicate(*RelatePredicate::equalsTopo(), wktb, wkta, expectedValue);
- }
-
- void checkRelate(const std::string& wkta, const std::string& wktb, const std::string expectedValue)
- {
- std::unique_ptr<Geometry> a = r.read(wkta);
- std::unique_ptr<Geometry> b = r.read(wktb);
- RelateMatrixPredicate pred;
- // TopologyPredicate predTrace = trace(pred);
- RelateNG::relate(a.get(), b.get(), pred);
- std::string actualVal = pred.getIM().toString();
- ensure_equals("checkRelate", actualVal, expectedValue);
- }
-
- void checkRelateMatches(const std::string& wkta, const std::string& wktb, const std::string pattern, bool expectedValue)
- {
- auto pred = RelatePredicate::matches(pattern);
- checkPredicate(*pred, wkta, wktb, expectedValue);
- }
-
- void checkPredicate(TopologyPredicate& pred, const std::string& wkta, const std::string& wktb, bool expectedValue)
- {
- std::unique_ptr<Geometry> a = r.read(wkta);
- std::unique_ptr<Geometry> b = r.read(wktb);
- // TopologyPredicate predTrace = trace(pred);
- bool actualVal = RelateNG::relate(a.get(), b.get(), pred);
- if (actualVal != expectedValue) {
- std::cerr << std::endl << w.write(*a) << " " << pred << " " << w.write(*b) << " = " << actualVal << std::endl;
- }
- ensure_equals("checkPredicate", actualVal, expectedValue);
- }
-
-};
typedef test_group<test_relateng_data> group;
typedef group::object object;
diff --git a/tests/unit/operation/relateng/RelateNGTest.h b/tests/unit/operation/relateng/RelateNGTest.h
new file mode 100644
index 000000000..0da34e615
--- /dev/null
+++ b/tests/unit/operation/relateng/RelateNGTest.h
@@ -0,0 +1,106 @@
+
+// geos
+#include <geos/io/WKTReader.h>
+#include <geos/io/WKTWriter.h>
+#include <geos/geom/Geometry.h>
+#include <geos/operation/relateng/RelateNG.h>
+#include <geos/operation/relateng/RelatePredicate.h>
+#include <geos/operation/relateng/RelateMatrixPredicate.h>
+#include <geos/operation/relateng/IntersectionMatrixPattern.h>
+
+// std
+#include <memory>
+
+using namespace geos::geom;
+using namespace geos::operation::relateng;
+using geos::io::WKTReader;
+using geos::io::WKTWriter;
+
+namespace tut {
+//
+// Test Group
+//
+
+// Common data used by all tests
+struct test_relateng_support {
+
+ WKTReader r;
+ WKTWriter w;
+
+ void checkIntersectsDisjoint(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::intersects(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::intersects(), wktb, wkta, expectedValue);
+ checkPredicate(*RelatePredicate::disjoint(), wkta, wktb, ! expectedValue);
+ checkPredicate(*RelatePredicate::disjoint(), wktb, wkta, ! expectedValue);
+ }
+
+ void checkContainsWithin(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::contains(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::within(), wktb, wkta, expectedValue);
+ }
+
+ void checkCoversCoveredBy(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::covers(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::coveredBy(), wktb, wkta, expectedValue);
+ }
+
+ void checkCrosses(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::crosses(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::crosses(), wktb, wkta, expectedValue);
+ }
+
+ void checkOverlaps(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::overlaps(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::overlaps(), wktb, wkta, expectedValue);
+ }
+
+ void checkTouches(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::touches(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::touches(), wktb, wkta, expectedValue);
+ }
+
+ void checkEquals(const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ checkPredicate(*RelatePredicate::equalsTopo(), wkta, wktb, expectedValue);
+ checkPredicate(*RelatePredicate::equalsTopo(), wktb, wkta, expectedValue);
+ }
+
+ void checkRelate(const std::string& wkta, const std::string& wktb, const std::string expectedValue)
+ {
+ std::unique_ptr<Geometry> a = r.read(wkta);
+ std::unique_ptr<Geometry> b = r.read(wktb);
+ RelateMatrixPredicate pred;
+ // TopologyPredicate predTrace = trace(pred);
+ RelateNG::relate(a.get(), b.get(), pred);
+ std::string actualVal = pred.getIM().toString();
+ ensure_equals("checkRelate", actualVal, expectedValue);
+ }
+
+ void checkRelateMatches(const std::string& wkta, const std::string& wktb, const std::string pattern, bool expectedValue)
+ {
+ auto pred = RelatePredicate::matches(pattern);
+ checkPredicate(*pred, wkta, wktb, expectedValue);
+ }
+
+ void checkPredicate(TopologyPredicate& pred, const std::string& wkta, const std::string& wktb, bool expectedValue)
+ {
+ std::unique_ptr<Geometry> a = r.read(wkta);
+ std::unique_ptr<Geometry> b = r.read(wktb);
+ // TopologyPredicate predTrace = trace(pred);
+ bool actualVal = RelateNG::relate(a.get(), b.get(), pred);
+ if (actualVal != expectedValue) {
+ std::cerr << std::endl << w.write(*a) << " " << pred << " " << w.write(*b) << " = " << actualVal << std::endl;
+ }
+ ensure_equals("checkPredicate", actualVal, expectedValue);
+ }
+
+};
+
+
+} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
tests/unit/operation/relateng/RelateNGGCTest.cpp | 306 +++++++++++++++++++++
.../operation/relateng/RelateNGRobustnessTest.cpp | 269 ++++++++++++++++++
tests/unit/operation/relateng/RelateNGTest.cpp | 92 +------
tests/unit/operation/relateng/RelateNGTest.h | 106 +++++++
4 files changed, 684 insertions(+), 89 deletions(-)
create mode 100644 tests/unit/operation/relateng/RelateNGGCTest.cpp
create mode 100644 tests/unit/operation/relateng/RelateNGRobustnessTest.cpp
create mode 100644 tests/unit/operation/relateng/RelateNGTest.h
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list