[geos-commits] r4309 - in branches/3.6: . src/io tests/unit/io

Sandro Santilli strk at kbt.io
Thu Dec 1 07:00:35 PST 2016


Author: strk
Date: 2016-12-01 07:00:35 -0800 (Thu, 01 Dec 2016)
New Revision: 4309

Modified:
   branches/3.6/NEWS
   branches/3.6/src/io/WKBWriter.cpp
   branches/3.6/tests/unit/io/WKBWriterTest.cpp
Log:
Fix WKB representation of empty polygon.

Patch by Sergey Fedoseev
Closes #680.

Modified: branches/3.6/NEWS
===================================================================
--- branches/3.6/NEWS	2016-12-01 14:50:01 UTC (rev 4308)
+++ branches/3.6/NEWS	2016-12-01 15:00:35 UTC (rev 4309)
@@ -1,9 +1,10 @@
 Changes in 3.6.1
-2016-MM-DD
+2016-11-30
 
 - Bug fixes / improvements
   - 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).
 
 Changes in 3.6.0
 2016-10-25

Modified: branches/3.6/src/io/WKBWriter.cpp
===================================================================
--- branches/3.6/src/io/WKBWriter.cpp	2016-12-01 14:50:01 UTC (rev 4308)
+++ branches/3.6/src/io/WKBWriter.cpp	2016-12-01 15:00:35 UTC (rev 4309)
@@ -163,6 +163,11 @@
 	
 	writeGeometryType(WKBConstants::wkbPolygon, g.getSRID());
 	writeSRID(g.getSRID());
+
+	if (g.isEmpty()) {
+		writeInt(0);
+		return;
+	}
 	
 	std::size_t nholes = g.getNumInteriorRing();
 	writeInt(nholes+1);

Modified: branches/3.6/tests/unit/io/WKBWriterTest.cpp
===================================================================
--- branches/3.6/tests/unit/io/WKBWriterTest.cpp	2016-12-01 14:50:01 UTC (rev 4308)
+++ branches/3.6/tests/unit/io/WKBWriterTest.cpp	2016-12-01 15:00:35 UTC (rev 4309)
@@ -159,6 +159,30 @@
 
   }
 
+    // 5 - Check WKB representation of empty polygon
+    // See http://trac.osgeo.org/geos/ticket/680
+    template<>
+    template<>
+    void object::test<5>()
+    {
+        geos::geom::Geometry *geom = wktreader.read("POLYGON EMPTY");
+        geom->setSRID(4326);
+        std::stringstream result_stream;
 
+        wkbwriter.setOutputDimension( 2 );
+        wkbwriter.setByteOrder( 1 );
+        wkbwriter.setIncludeSRID( 1 );
+        wkbwriter.writeHEX( *geom, result_stream );
+
+        std::string actual = result_stream.str();
+        ensure_equals( actual, "0103000020E610000000000000" );
+
+        geos::geom::Geometry *geom2 = wkbreader.readHEX(result_stream);
+        assert( geom->equals(geom2) );
+
+        delete geom;
+        delete geom2;
+    }
+
 } // namespace tut
 



More information about the geos-commits mailing list