[geos-commits] [SCM] GEOS branch master updated. 6ef28f282e6a336302267b249fcac6cc59c54cae

git at osgeo.org git at osgeo.org
Thu Nov 15 14:37:36 PST 2018


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  6ef28f282e6a336302267b249fcac6cc59c54cae (commit)
      from  88f21460756bb1eec852ac70f981581755fe07a0 (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 6ef28f282e6a336302267b249fcac6cc59c54cae
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu Nov 15 14:37:10 2018 -0800

    Update handling of EMPTY geometry typing to match JTS current version and update test cases to match.

diff --git a/include/geos/operation/overlay/OverlayOp.h b/include/geos/operation/overlay/OverlayOp.h
index ac52b2b..0ed54cf 100644
--- a/include/geos/operation/overlay/OverlayOp.h
+++ b/include/geos/operation/overlay/OverlayOp.h
@@ -21,10 +21,11 @@
 
 #include <geos/export.h>
 
-#include <geos/operation/GeometryGraphOperation.h> // for inheritance
-#include <geos/geomgraph/EdgeList.h> // for composition
 #include <geos/algorithm/PointLocator.h> // for composition
+#include <geos/geom/Dimension.h> // for Dimension::DimensionType
+#include <geos/geomgraph/EdgeList.h> // for composition
 #include <geos/geomgraph/PlanarGraph.h> // for inline (GeometryGraph->PlanarGraph)
+#include <geos/operation/GeometryGraphOperation.h> // for inheritance
 
 #include <vector>
 
@@ -327,6 +328,29 @@ private:
 	 */
 	bool isCovered(const geom::Coordinate& coord,
 			std::vector<geom::LineString*> *geomList);
+	/**
+	* For empty result, what is the correct geometry type to apply to 
+	* the empty?
+	*/
+	geom::Dimension::DimensionType resultDimension(OverlayOp::OpCode overlayOpCode, 
+		const geom::Geometry *g0, const geom::Geometry *g1);
+
+	/**
+	* Creates an empty result geometry of the appropriate dimension,
+	* based on the given overlay operation and the dimensions of the inputs.
+	* The created geometry is always an atomic geometry, 
+	* not a collection.
+	*  
+	* The empty result is constructed using the following rules:
+	*  
+	* * #opINTERSECTION  result has the dimension of the lowest input dimension
+	* * #opUNION - result has the dimension of the highest input dimension
+	* * #opDIFFERENCE - result has the dimension of the left-hand input
+	* * #opSYMDIFFERENCE - result has the dimension of the highest input dimension
+	*/
+	geom::Geometry* createEmptyResult(
+		OverlayOp::OpCode overlayOpCode, const geom::Geometry *a, 
+		const geom::Geometry *b, const geom::GeometryFactory *geomFact);
 
 	/**
 	 * Build a Geometry containing all Geometries in the given vectors.
@@ -335,7 +359,8 @@ private:
 	geom::Geometry* computeGeometry(
 			std::vector<geom::Point*> *nResultPointList,
 			std::vector<geom::LineString*> *nResultLineList,
-			std::vector<geom::Polygon*> *nResultPolyList);
+			std::vector<geom::Polygon*> *nResultPolyList,
+			OverlayOp::OpCode opCode);
 
 	/// Caches for memory management
 	std::vector<geomgraph::Edge *>dupEdges;
diff --git a/src/operation/overlay/OverlayOp.cpp b/src/operation/overlay/OverlayOp.cpp
index 1677858..11a858a 100644
--- a/src/operation/overlay/OverlayOp.cpp
+++ b/src/operation/overlay/OverlayOp.cpp
@@ -639,11 +639,62 @@ OverlayOp::isCovered(const Coordinate& coord,vector<Polygon*> *geomList)
 	return false;
 }
 
+Dimension::DimensionType
+OverlayOp::resultDimension(OverlayOp::OpCode overlayOpCode, 
+                const Geometry *g0, const Geometry *g1)
+{
+	Dimension::DimensionType dim0 = g0->getDimension();
+	Dimension::DimensionType dim1 = g1->getDimension();
+
+	Dimension::DimensionType resultDimension = Dimension::False;
+	switch (overlayOpCode) 
+	{
+		case OverlayOp::opINTERSECTION: 
+			resultDimension = min(dim0, dim1);
+			break;
+		case OverlayOp::opUNION: 
+			resultDimension = max(dim0, dim1);
+			break;
+		case OverlayOp::opDIFFERENCE: 
+			resultDimension = dim0;
+			break;
+		case OverlayOp::opSYMDIFFERENCE: 
+			resultDimension = max(dim0, dim1);
+			break;
+	}
+	return resultDimension;
+}
+
+geom::Geometry*
+OverlayOp::createEmptyResult(OverlayOp::OpCode overlayOpCode, 
+                             const geom::Geometry *a, const geom::Geometry *b, 
+                             const GeometryFactory *geomFact)
+{
+	geom::Geometry *result = nullptr;
+	switch (resultDimension(overlayOpCode, a, b)) 
+	{
+		case Dimension::P:
+			result = geomFact->createPoint();
+			break;
+		case Dimension::L:
+			result = geomFact->createLineString();
+			break;
+		case Dimension::A:
+			result = geomFact->createPolygon();
+			break;
+		default:
+			result = geomFact->createGeometryCollection();
+			break;
+	}
+	return result;
+}
+
 /*private*/
 Geometry*
 OverlayOp::computeGeometry(vector<Point*> *nResultPointList,
-                              vector<LineString*> *nResultLineList,
-                              vector<Polygon*> *nResultPolyList)
+                           vector<LineString*> *nResultLineList,
+                           vector<Polygon*> *nResultPolyList,
+                           OverlayOp::OpCode opCode)
 {
 	size_t nPoints=nResultPointList->size();
 	size_t nLines=nResultLineList->size();
@@ -665,6 +716,12 @@ OverlayOp::computeGeometry(vector<Point*> *nResultPointList,
 			nResultPolyList->begin(),
 			nResultPolyList->end());
 
+
+	if (geomList->empty())
+	{
+		return createEmptyResult(opCode, arg[0]->getGeometry(), 
+		                         arg[1]->getGeometry(), geomFact);
+	}
 	// build the most specific geometry possible
 	Geometry *g=geomFact->buildGeometry(geomList);
 	return g;
@@ -836,7 +893,7 @@ OverlayOp::computeOverlay(OverlayOp::OpCode opCode)
 
 	// gather the results from all calculations into a single
 	// Geometry for the result set
-	resultGeom=computeGeometry(resultPointList,resultLineList,resultPolyList);
+	resultGeom=computeGeometry(resultPointList,resultLineList,resultPolyList,opCode);
 
 	checkObviouslyWrongResult(opCode);
 
diff --git a/tests/xmltester/Makefile.am b/tests/xmltester/Makefile.am
index eef563a..61017b7 100644
--- a/tests/xmltester/Makefile.am
+++ b/tests/xmltester/Makefile.am
@@ -101,7 +101,9 @@ INVALID_OUTPUT_XMLTESTS =
 
 FAILING_XMLTESTS = \
 	$(srcdir)/tests/failure/TestOverlay.xml \
-	$(srcdir)/tests/ticket/bug488.xml
+	$(srcdir)/tests/ticket/bug488.xml \
+	$(srcdir)/tests/ticket/bug344.xml \
+	$(srcdir)/tests/TestBigNastyBuffer.xml
 
 XMLTESTS=$(SAFE_XMLTESTS) $(INVALID_OUTPUT_XMLTESTS) $(FAILING_XMLTESTS)
 
diff --git a/tests/xmltester/tests/general/TestFunctionAA.xml b/tests/xmltester/tests/general/TestFunctionAA.xml
index d0d713a..ef006bd 100644
--- a/tests/xmltester/tests/general/TestFunctionAA.xml
+++ b/tests/xmltester/tests/general/TestFunctionAA.xml
@@ -630,4 +630,34 @@
 </test>
 </case>
 
+<case>
+  <desc>AA - Polygons which stress hole assignment</desc>
+  <a>
+POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 1, 1 1), (1 2, 1 3, 2 3, 1 2), (2 3, 3 3, 3 2, 2 3))
+  </a>
+  <b>
+POLYGON ((2 1, 3 1, 3 2, 2 1))
+  </b>
+<test>
+  <op name="intersection" arg1="A" arg2="B">
+POLYGON ((3 2, 3 1, 2 1, 3 2))
+  </op>
+</test>
+<test>
+  <op name="union" arg1="A" arg2="B">
+POLYGON ((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 1 2), (1 2, 2 3, 1 3, 1 2), (2 3, 3 2, 3 3, 2 3))
+  </op>
+</test>
+<test>
+  <op name="difference" arg1="A" arg2="B">
+MULTIPOLYGON (((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 3 1, 3 2, 3 3, 2 3, 1 3, 1 2)), ((2 1, 1 2, 2 3, 3 2, 2 1)))
+  </op>
+</test>
+<test>
+  <op name="symdifference" arg1="A" arg2="B">
+MULTIPOLYGON (((0 0, 0 4, 4 4, 4 0, 0 0), (1 2, 1 1, 2 1, 3 1, 3 2, 3 3, 2 3, 1 3, 1 2)), ((2 1, 1 2, 2 3, 3 2, 2 1)))
+  </op>
+</test>
+</case>
+
 </run>
diff --git a/tests/xmltester/tests/general/TestFunctionLA.xml b/tests/xmltester/tests/general/TestFunctionLA.xml
index 881bbaf..898b1ea 100644
--- a/tests/xmltester/tests/general/TestFunctionLA.xml
+++ b/tests/xmltester/tests/general/TestFunctionLA.xml
@@ -212,7 +212,7 @@
 </test>
 <test>
   <op name="intersection" pattern="FFFFFFFFF" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    LINESTRING EMPTY
   </op>
 </test>
 </case>
diff --git a/tests/xmltester/tests/general/TestFunctionLL.xml b/tests/xmltester/tests/general/TestFunctionLL.xml
index 303b489..5aa2757 100644
--- a/tests/xmltester/tests/general/TestFunctionLL.xml
+++ b/tests/xmltester/tests/general/TestFunctionLL.xml
@@ -97,7 +97,7 @@
 </test>
 <test>
   <op name="intersection" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    LINESTRING EMPTY
   </op>
 </test>
 <test>
@@ -249,12 +249,12 @@
 </test>
 <test>
   <op name="difference" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    LINESTRING EMPTY
   </op>
 </test>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    LINESTRING EMPTY
   </op>
 </test>
 </case>
diff --git a/tests/xmltester/tests/general/TestFunctionPP.xml b/tests/xmltester/tests/general/TestFunctionPP.xml
index d14f74c..f83a79c 100644
--- a/tests/xmltester/tests/general/TestFunctionPP.xml
+++ b/tests/xmltester/tests/general/TestFunctionPP.xml
@@ -26,7 +26,7 @@
   </b>
 <test>
   <op name="intersection" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 <test>
@@ -66,7 +66,7 @@
 </test>
 <test>
   <op name="difference" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 <test>
@@ -136,12 +136,12 @@
 </test>
 <test>
   <op name="difference" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 <test>
   <op name="symdifference" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 </case>
@@ -166,7 +166,7 @@
 </test>
 <test>
   <op name="intersection" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 <test>
@@ -206,7 +206,7 @@
 </test>
 <test>
   <op name="intersection" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 <test>
@@ -246,7 +246,7 @@
 </test>
 <test>
   <op name="intersection" arg1="A" arg2="B">
-    GEOMETRYCOLLECTION EMPTY
+    POINT EMPTY
   </op>
 </test>
 <test>

-----------------------------------------------------------------------

Summary of changes:
 include/geos/operation/overlay/OverlayOp.h       | 31 ++++++++++--
 src/operation/overlay/OverlayOp.cpp              | 63 ++++++++++++++++++++++--
 tests/xmltester/Makefile.am                      |  4 +-
 tests/xmltester/tests/general/TestFunctionAA.xml | 30 +++++++++++
 tests/xmltester/tests/general/TestFunctionLA.xml |  2 +-
 tests/xmltester/tests/general/TestFunctionLL.xml |  6 +--
 tests/xmltester/tests/general/TestFunctionPP.xml | 14 +++---
 7 files changed, 132 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list