[geos-commits] r4313 - in branches/3.6: . include/geos/geom/util src/geom/util src/simplify tests/unit/simplify

Sandro Santilli strk at kbt.io
Fri Dec 2 06:01:48 PST 2016


Author: strk
Date: 2016-12-02 06:01:48 -0800 (Fri, 02 Dec 2016)
New Revision: 4313

Modified:
   branches/3.6/NEWS
   branches/3.6/include/geos/geom/util/GeometryTransformer.h
   branches/3.6/src/geom/util/GeometryTransformer.cpp
   branches/3.6/src/simplify/DouglasPeuckerSimplifier.cpp
   branches/3.6/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
Log:
Fix empty GEOSSimplify return on inner ring collapse

Patch by Even Rouault
Closes #741

Modified: branches/3.6/NEWS
===================================================================
--- branches/3.6/NEWS	2016-12-02 14:01:37 UTC (rev 4312)
+++ branches/3.6/NEWS	2016-12-02 14:01:48 UTC (rev 4313)
@@ -5,6 +5,7 @@
   - Fix GEOSSTRtree_nearest_r signature and add implementation (#796)
   - Fix --static-clibs and --static-cclibs returns from geos-config
   - Fix WKB representation of empty polygon (#680).
+  - Fix empty GEOSSimplify return on inner ring collapse (#741)
 
 Changes in 3.6.0
 2016-10-25

Modified: branches/3.6/include/geos/geom/util/GeometryTransformer.h
===================================================================
--- branches/3.6/include/geos/geom/util/GeometryTransformer.h	2016-12-02 14:01:37 UTC (rev 4312)
+++ branches/3.6/include/geos/geom/util/GeometryTransformer.h	2016-12-02 14:01:48 UTC (rev 4313)
@@ -99,6 +99,8 @@
 
 	std::auto_ptr<Geometry> transform(const Geometry* nInputGeom);
 
+	void setSkipTransformedInvalidInteriorRings(bool b);
+
 protected:
 
 	const GeometryFactory* factory;
@@ -178,6 +180,11 @@
 	 */
 	bool preserveType;
 
+	/**
+	 * <code>true</code> if transformed invalid interior rings should be skipped
+	 */
+	bool skipTransformedInvalidInteriorRings;
+
 	// Declare type as noncopyable
 	GeometryTransformer(const GeometryTransformer& other);
 	GeometryTransformer& operator=(const GeometryTransformer& rhs);

Modified: branches/3.6/src/geom/util/GeometryTransformer.cpp
===================================================================
--- branches/3.6/src/geom/util/GeometryTransformer.cpp	2016-12-02 14:01:37 UTC (rev 4312)
+++ branches/3.6/src/geom/util/GeometryTransformer.cpp	2016-12-02 14:01:48 UTC (rev 4313)
@@ -59,13 +59,19 @@
 	pruneEmptyGeometry(true),
 	preserveGeometryCollectionType(true),
 	preserveCollections(false),
-	preserveType(false)
+	preserveType(false),
+	skipTransformedInvalidInteriorRings(false)
 {}
 
 GeometryTransformer::~GeometryTransformer()
 {
 }
 
+void GeometryTransformer::setSkipTransformedInvalidInteriorRings(bool b)
+{
+	skipTransformedInvalidInteriorRings = b;
+}
+
 /*public*/
 auto_ptr<Geometry>
 GeometryTransformer::transform(const Geometry* nInputGeom)
@@ -283,6 +289,8 @@
 
 		if ( ! dynamic_cast<LinearRing*>(hole.get()) )
 		{
+			if ( skipTransformedInvalidInteriorRings )
+			    continue;
 			isAllValidLinearRings = false;
 		}
 

Modified: branches/3.6/src/simplify/DouglasPeuckerSimplifier.cpp
===================================================================
--- branches/3.6/src/simplify/DouglasPeuckerSimplifier.cpp	2016-12-02 14:01:37 UTC (rev 4312)
+++ branches/3.6/src/simplify/DouglasPeuckerSimplifier.cpp	2016-12-02 14:01:48 UTC (rev 4313)
@@ -89,6 +89,7 @@
 	:
 	distanceTolerance(t)
 {
+	setSkipTransformedInvalidInteriorRings(true);
 }
 
 Geometry::AutoPtr

Modified: branches/3.6/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp
===================================================================
--- branches/3.6/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp	2016-12-02 14:01:37 UTC (rev 4312)
+++ branches/3.6/tests/unit/simplify/DouglasPeuckerSimplifierTest.cpp	2016-12-02 14:01:48 UTC (rev 4313)
@@ -331,5 +331,26 @@
         //std::string const simplifiedWkt2 = wktwriter.write(simplified2.get());
 	}
 
+	// 13 - Polygon with inner ring whose extent is less than the simplify distance (#741)
+	template<>
+	template<>
+	void object::test<13>()
+	{
+		std::string wkt_in("POLYGON ((0 0,0 1,1 1,0 0),(0.1 0.1,0.2 0.1,0.2 0.2,0.1 0.1))");
+
+		std::string wkt_ex("POLYGON ((0 0,0 1,1 1,0 0))");
+
+		GeomPtr g(wktreader.read(wkt_in));
+
+		GeomPtr expected(wktreader.read(wkt_ex));
+
+		GeomPtr simplified = DouglasPeuckerSimplifier::simplify(
+			g.get(), 0.5);
+
+		ensure( simplified->isValid() );
+
+		ensure( simplified->equalsExact(expected.get()) );
+	}
+
 } // namespace tut
 



More information about the geos-commits mailing list