[geos-commits] [SCM] geos branch master updated. 63410b14d1ca1117a91b2e31928d893cf78fa1fb
git at osgeo.org
git at osgeo.org
Wed Jul 19 14:59:28 PDT 2017
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, master has been updated
via 63410b14d1ca1117a91b2e31928d893cf78fa1fb (commit)
from 869e009e6c9b9d0d570d09bc24e711acdffc6548 (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 63410b14d1ca1117a91b2e31928d893cf78fa1fb
Author: Sandro Santilli <strk at kbt.io>
Date: Wed Jul 19 23:58:28 2017 +0200
Add support for testing prepared geometries operations in XMLTester
Add 3 more tests from JTS testsuite now that they can be run
See #694
diff --git a/tests/xmltester/Makefile.am b/tests/xmltester/Makefile.am
index 588c364..37928b0 100644
--- a/tests/xmltester/Makefile.am
+++ b/tests/xmltester/Makefile.am
@@ -62,6 +62,9 @@ SAFE_XMLTESTS=$(srcdir)/tests/testLeaksBig.xml \
$(srcdir)/tests/general/TestFunctionPL.xml \
$(srcdir)/tests/general/TestFunctionPP.xml \
$(srcdir)/tests/general/TestInteriorPoint.xml \
+ $(srcdir)/tests/general/TestPreparedPointPredicate.xml \
+ $(srcdir)/tests/general/TestPreparedPolygonPredicate.xml \
+ $(srcdir)/tests/general/TestPreparedPredicatesWithGeometryCollection.xml \
$(srcdir)/tests/general/TestRectanglePredicate.xml \
$(srcdir)/tests/general/TestRelateAA.xml \
$(srcdir)/tests/general/TestRelateLA.xml \
diff --git a/tests/xmltester/XMLTester.cpp b/tests/xmltester/XMLTester.cpp
index bb30b7c..d4e7d75 100644
--- a/tests/xmltester/XMLTester.cpp
+++ b/tests/xmltester/XMLTester.cpp
@@ -32,6 +32,8 @@
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/IntersectionMatrix.h>
#include <geos/geom/PrecisionModel.h>
+#include <geos/geom/prep/PreparedGeometry.h>
+#include <geos/geom/prep/PreparedGeometryFactory.h>
#include <geos/geom/BinaryOp.h>
#include <geos/operation/overlay/OverlayOp.h>
#include <geos/operation/overlay/snap/GeometrySnapper.h>
@@ -84,10 +86,15 @@
using namespace geos;
using namespace geos::operation::polygonize;
using namespace geos::operation::linemerge;
+using namespace geos::geom::prep;
using std::runtime_error;
namespace {
+std::auto_ptr<const PreparedGeometry> prepare( const geom::Geometry *g ) {
+ return std::auto_ptr<const PreparedGeometry> ( PreparedGeometryFactory::prepare(g) );
+}
+
// Asymmetric Rounding Algorithm - equivalent to Java Math.round()
// Copy from geos/util/math.cpp
double java_math_round(double val)
@@ -469,11 +476,31 @@ XMLTester::parseRun(const TiXmlNode* node)
if ( el ) parsePrecisionModel(el);
else pm.reset(new PrecisionModel());
+ // Look for geometryOperation, if any
+ usePrepared = false;
+ el = node->FirstChildElement("geometryOperation");
+ if ( el ) {
+ const TiXmlNode* txt = el->FirstChild();
+ if ( txt ) {
+ std::string op = trimBlanks(txt->Value());
+ if ( op.find("PreparedGeometryOperation") ) {
+ usePrepared = true;
+ } else {
+ std::cerr << *curr_file
+ <<": WARNING: unknown geometryOperation: "
+ << op << std::endl;
+ }
+ }
+ }
+
if (verbose > 1)
{
- std::cerr << *curr_file <<": run: Precision Model: " << pm->toString() <<std::endl;
+ std::cerr << *curr_file <<": run: Precision Model: " << pm->toString();
+ if ( usePrepared ) std::cerr << " (prepared)";
+ std::cerr << std::endl;
}
+
factory = geom::GeometryFactory::create(pm.get());
wktreader.reset(new io::WKTReader(factory.get()));
wktwriter.reset(new io::WKTWriter());
@@ -536,7 +563,6 @@ XMLTester::parsePrecisionModel(const TiXmlElement* el)
}
}
-
bool
XMLTester::testValid(const geom::Geometry* g, const std::string& label)
{
@@ -932,8 +958,12 @@ XMLTester::parseTest(const TiXmlNode* node)
geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
- if (g1->intersects(g2)) actual_result="true";
- else actual_result="false";
+ actual_result="false";
+ if ( usePrepared )
+ {
+ if ( prepare(g1)->intersects(g2) ) actual_result="true";
+ }
+ else if (g1->intersects(g2)) actual_result="true";
if (actual_result==opRes) success=1;
}
@@ -943,8 +973,12 @@ XMLTester::parseTest(const TiXmlNode* node)
geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
- if (g1->contains(g2)) actual_result="true";
- else actual_result="false";
+ actual_result="false";
+ if ( usePrepared )
+ {
+ if ( prepare(g1)->contains(g2) ) actual_result="true";
+ }
+ else if (g1->contains(g2)) actual_result="true";
if (actual_result==opRes) success=1;
}
@@ -954,8 +988,12 @@ XMLTester::parseTest(const TiXmlNode* node)
geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
- if (g1->within(g2)) actual_result="true";
- else actual_result="false";
+ actual_result="false";
+ if ( usePrepared )
+ {
+ if ( prepare(g1)->within(g2) ) actual_result="true";
+ }
+ else if (g1->within(g2)) actual_result="true";
if (actual_result==opRes) success=1;
}
@@ -965,8 +1003,12 @@ XMLTester::parseTest(const TiXmlNode* node)
geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
- if (g1->covers(g2)) actual_result="true";
- else actual_result="false";
+ actual_result="false";
+ if ( usePrepared )
+ {
+ if ( prepare(g1)->covers(g2) ) actual_result="true";
+ }
+ else if (g1->covers(g2)) actual_result="true";
if (actual_result==opRes) success=1;
}
@@ -976,8 +1018,12 @@ XMLTester::parseTest(const TiXmlNode* node)
geom::Geometry *g1 = opArg1 == "B" ? gB : gA;
geom::Geometry *g2 = opArg2 == "B" ? gB : gA;
- if (g1->coveredBy(g2)) actual_result="true";
- else actual_result="false";
+ actual_result="false";
+ if ( usePrepared )
+ {
+ if ( prepare(g1)->coveredBy(g2) ) actual_result="true";
+ }
+ else if (g1->coveredBy(g2)) actual_result="true";
if (actual_result==opRes) success=1;
}
@@ -1483,6 +1529,14 @@ XMLTester::runPredicates(const geom::Geometry *gA, const geom::Geometry *gB)
std::cout << "\t Within:\tAB=" << (gA->within(gB)?"T":"F") << ", BA=" << (gB->within(gA)?"T":"F") << std::endl;
std::cout << "\t Contains:\tAB=" << (gA->contains(gB)?"T":"F") << ", BA=" << (gB->contains(gA)?"T":"F") << std::endl;
std::cout << "\t Overlaps:\tAB=" << (gA->overlaps(gB)?"T":"F") << ", BA=" << (gB->overlaps(gA)?"T":"F") << std::endl;
+
+ std::cout << "\t Prepared Disjoint:\tAB=" << (prepare(gA)->disjoint(gB)?"T":"F") << ", BA=" << (prepare(gB)->disjoint(gA)?"T":"F") << std::endl;
+ std::cout << "\tPrepared Intersects:\tAB=" << (prepare(gA)->intersects(gB)?"T":"F") << ", BA=" << (prepare(gB)->intersects(gA)?"T":"F") << std::endl;
+ std::cout << "\t Prepared Touches:\tAB=" << (prepare(gA)->touches(gB)?"T":"F") << ", BA=" << (prepare(gB)->touches(gA)?"T":"F") << std::endl;
+ std::cout << "\t Prepared Crosses:\tAB=" << (prepare(gA)->crosses(gB)?"T":"F") << ", BA=" << (prepare(gB)->crosses(gA)?"T":"F") << std::endl;
+ std::cout << "\t Prepared Within:\tAB=" << (prepare(gA)->within(gB)?"T":"F") << ", BA=" << (prepare(gB)->within(gA)?"T":"F") << std::endl;
+ std::cout << "\t Prepared Contains:\tAB=" << (prepare(gA)->contains(gB)?"T":"F") << ", BA=" << (prepare(gB)->contains(gA)?"T":"F") << std::endl;
+ std::cout << "\t Prepared Overlaps:\tAB=" << (prepare(gA)->overlaps(gB)?"T":"F") << ", BA=" << (prepare(gB)->overlaps(gA)?"T":"F") << std::endl;
}
XMLTester::~XMLTester()
diff --git a/tests/xmltester/XMLTester.h b/tests/xmltester/XMLTester.h
index 8f517f3..a867ed9 100644
--- a/tests/xmltester/XMLTester.h
+++ b/tests/xmltester/XMLTester.h
@@ -50,6 +50,7 @@ private:
geom::Geometry *gB;
geom::Geometry *gT;
+ bool usePrepared;
std::auto_ptr<geom::PrecisionModel> pm;
geom::GeometryFactory::unique_ptr factory;
std::auto_ptr<io::WKTReader> wktreader;
diff --git a/tests/xmltester/tests/general/MISSING b/tests/xmltester/tests/general/MISSING
index 9bdbb96..3928e7a 100644
--- a/tests/xmltester/tests/general/MISSING
+++ b/tests/xmltester/tests/general/MISSING
@@ -4,11 +4,3 @@ Tests found in JTS/testxml/general and not ported as of rev 3991 (Jun 30 2014)
TestDensify.xml
- requires densify::Densifier still unported
-TestPreparedPointPredicate.xml
- - requires using custom operation (PreparedGeometryOperation)
-
-TestPreparedPolygonPredicate.xml
- - requires using custom operation (PreparedGeometryOperation)
-
-TestPreparedPredicatesWithGeometryCollection.xml
- - requires using custom operation (PreparedGeometryOperation)
diff --git a/tests/xmltester/tests/general/TestPreparedPointPredicate.xml b/tests/xmltester/tests/general/TestPreparedPointPredicate.xml
new file mode 100644
index 0000000..5c353df
--- /dev/null
+++ b/tests/xmltester/tests/general/TestPreparedPointPredicate.xml
@@ -0,0 +1,34 @@
+<run>
+ <desc>Test cases for PreparedPoint predicates</desc>
+ <precisionModel type="FLOATING"/>
+ <geometryOperation>org.locationtech.jtstest.geomop.PreparedGeometryOperation</geometryOperation>
+
+<case>
+<desc> P/A - point in interior of poly</desc>
+ <a> POINT (100 100)
+ </a>
+ <b> POLYGON ((50 130, 150 130, 100 50, 50 130))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+<desc> P/A - point on boundary of poly</desc>
+ <a> POINT (100 50)
+ </a>
+ <b> POLYGON ((50 130, 150 130, 100 50, 50 130))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+<desc> P/A - point outside poly</desc>
+ <a> POINT (200 200)
+ </a>
+ <b> POLYGON ((50 130, 150 130, 100 50, 50 130))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> false </op> </test>
+</case>
+
+
+</run>
diff --git a/tests/xmltester/tests/general/TestPreparedPolygonPredicate.xml b/tests/xmltester/tests/general/TestPreparedPolygonPredicate.xml
new file mode 100644
index 0000000..04ca2e6
--- /dev/null
+++ b/tests/xmltester/tests/general/TestPreparedPolygonPredicate.xml
@@ -0,0 +1,191 @@
+<run>
+ <desc>Test cases for PreparedGeometry predicates using polygons as input</desc>
+ <precisionModel type="FLOATING"/>
+ <geometryOperation>org.locationtech.jtstest.geomop.PreparedGeometryOperation</geometryOperation>
+
+<case>
+ <desc>A/P - point equal to start point of polygon
+ </desc>
+ <a>
+ POLYGON ((10 10, 60 100, 110 10, 10 10))
+ </a>
+ <b>
+ POINT (10 10)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/P - point equal to start point of polygon
+ </desc>
+ <a>
+ POLYGON ((10 10, 60 100, 110 10, 10 10))
+ </a>
+ <b>
+ POINT (10 20)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> false </op> </test>
+</case>
+
+<case>
+ <desc>mA/L
+ A has 2 shells touching at one vertex and one non-vertex.
+ B passes between the shells, but is wholely contained
+ </desc>
+ <a>
+ MULTIPOLYGON (((100 30, 30 110, 150 110, 100 30)),
+ ((90 110, 30 170, 140 170, 90 110)))
+ </a>
+ <b>
+ LINESTRING (90 80, 90 150)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>mA/L
+ A has 2 shells touching at one vertex and one non-vertex
+ B passes between the shells, but is NOT contained (since it is slightly offset)
+
+ </desc>
+ <a>
+ MULTIPOLYGON (((100 30, 30 110, 150 110, 100 30)),
+ ((90 110, 30 170, 140 170, 90 110)))
+ </a>
+ <b>
+ LINESTRING (90.1 80, 90 150)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>mA/L - 2 disjoint shells with line crossing between them </desc>
+ <a>
+ MULTIPOLYGON (((50 20, 10 70, 80 70, 50 20)),
+ ((10 90, 80 90, 50 140, 10 90)))
+ </a>
+ <b>
+ LINESTRING (50 110, 50 60)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - proper intersection crossing bdy
+ </desc>
+ <a>
+ POLYGON ((10 10, 10 100, 120 110, 120 30, 10 10))
+ </a>
+ <b>
+ LINESTRING (60 60, 70 140)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - non-proper intersection crossing bdy
+ </desc>
+ <a>
+ POLYGON ((10 10, 60 100, 110 10, 10 10))
+ </a>
+ <b>
+ LINESTRING (60 60, 60 140)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - wholely contained
+ </desc>
+ <a> POLYGON ((10 10, 60 100, 110 10, 10 10))
+ </a>
+ <b> LINESTRING (50 30, 70 60)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - contained but touching bdy at interior point
+ </desc>
+ <a>
+ POLYGON ((10 10, 60 100, 110 10, 10 10))
+ </a>
+ <b>
+ LINESTRING (60 10, 70 60)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - line in bdy - covered but not contained
+ </desc>
+ <a>
+ POLYGON ((10 10, 60 100, 110 10, 10 10))
+ </a>
+ <b>
+ LINESTRING (30 10, 90 10)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/A - two equal polygons
+ </desc>
+ <a>
+ POLYGON((20 20, 20 100, 120 100, 140 20, 20 20))
+ </a>
+ <b>
+ POLYGON((20 20, 20 100, 120 100, 140 20, 20 20))
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - line with repeated points
+ </desc>
+ <a>
+ POLYGON((20 20, 20 100, 120 100, 140 20, 20 20))
+ </a>
+ <b>
+ LINESTRING (10 60, 50 60, 60 30, 60 30, 90 80, 90 80, 160 70)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>A/L - polygon and line with repeated points
+ </desc>
+ <a>
+ POLYGON((20 20, 20 100, 120 100, 120 100, 120 100, 140 20, 140 20, 140 20, 20 20))
+ </a>
+ <b>
+ LINESTRING (10 60, 50 60, 60 30, 60 30, 90 80, 90 80, 160 70)
+ </b>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+
+</run>
diff --git a/tests/xmltester/tests/general/TestPreparedPredicatesWithGeometryCollection.xml b/tests/xmltester/tests/general/TestPreparedPredicatesWithGeometryCollection.xml
new file mode 100644
index 0000000..9ea3821
--- /dev/null
+++ b/tests/xmltester/tests/general/TestPreparedPredicatesWithGeometryCollection.xml
@@ -0,0 +1,81 @@
+<run>
+ <desc>Test cases for PreparedGeometry predicates using GeometryCollections as test geometry.
+ This tests the various combinations of target geometry and predicate which support
+ GCs as the test geometry.
+ </desc>
+ <precisionModel type="FLOATING"/>
+ <geometryOperation>org.locationtech.jtstest.geomop.PreparedGeometryOperation</geometryOperation>
+
+<case>
+ <desc>Box against GC
+ </desc>
+ <a>
+ POLYGON ((0 0, 0 100, 200 100, 200 0, 0 0))
+ </a>
+ <b>
+ GEOMETRYCOLLECTION (POLYGON ((50 160, 110 60, 150 160, 50 160)),
+ LINESTRING (50 40, 170 120))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> false </op> </test>
+</case>
+
+<case>
+ <desc>Box against GC, with containment
+ </desc>
+ <a>
+ POLYGON ((0 0, 0 200, 200 200, 200 0, 0 0))
+ </a>
+ <b>
+ GEOMETRYCOLLECTION (POLYGON ((50 160, 110 60, 150 160, 50 160)),
+ LINESTRING (50 40, 170 120))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="contains" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="covers" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>Polygon-with-hole against GC
+ </desc>
+ <a>
+ POLYGON ((0 0, 0 270, 200 270, 200 0, 0 0),
+ (30 210, 170 210, 60 20, 30 210))
+ </a>
+ <b>
+ GEOMETRYCOLLECTION (POLYGON ((50 160, 110 60, 150 160, 50 160)),
+ LINESTRING (50 40, 170 120))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+<test> <op name="contains" arg1="A" arg2="B"> false </op> </test>
+</case>
+
+<case>
+ <desc>Linestring against GC
+ </desc>
+ <a>
+ LINESTRING (20 90, 90 190, 170 50)
+ </a>
+ <b>
+ GEOMETRYCOLLECTION (POLYGON ((50 160, 110 60, 150 160, 50 160)),
+ LINESTRING (50 40, 170 120))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+<case>
+ <desc>Linestring against GC, with containment
+ </desc>
+ <a>
+ LINESTRING (20 20, 100 100, 180 20)
+ </a>
+ <b>
+ GEOMETRYCOLLECTION (LINESTRING (40 40, 80 80), POINT (120 80))
+ </b>
+<test> <op name="intersects" arg1="A" arg2="B"> true </op> </test>
+</case>
+
+
+
+</run>
-----------------------------------------------------------------------
Summary of changes:
tests/xmltester/Makefile.am | 3 +
tests/xmltester/XMLTester.cpp | 78 ++++++--
tests/xmltester/XMLTester.h | 1 +
tests/xmltester/tests/general/MISSING | 8 -
.../tests/general/TestPreparedPointPredicate.xml | 34 ++++
.../tests/general/TestPreparedPolygonPredicate.xml | 191 ++++++++++++++++++++
...estPreparedPredicatesWithGeometryCollection.xml | 81 +++++++++
7 files changed, 376 insertions(+), 20 deletions(-)
create mode 100644 tests/xmltester/tests/general/TestPreparedPointPredicate.xml
create mode 100644 tests/xmltester/tests/general/TestPreparedPolygonPredicate.xml
create mode 100644 tests/xmltester/tests/general/TestPreparedPredicatesWithGeometryCollection.xml
hooks/post-receive
--
geos
More information about the geos-commits
mailing list