[geos-commits] [SCM] GEOS branch master updated. 67b3af0b798cd6b7a36ac217923137602deba578

git at osgeo.org git at osgeo.org
Fri Dec 7 11:55:10 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  67b3af0b798cd6b7a36ac217923137602deba578 (commit)
      from  6845c86cdf9a0b6e72294d72c77eff6b557ecef7 (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 67b3af0b798cd6b7a36ac217923137602deba578
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Dec 7 11:54:13 2018 -0800

    Partially harmonize with JTS 8e6abedeca3f3c1905c2f58c0a2dccc77f1f2f12
    Support for ISO WKB types for higher dimensions as well as
    old SFSQL high-bit flags for Z. Commented out support for M
    for a future date when M support is added to GEOS.

diff --git a/src/io/WKBReader.cpp b/src/io/WKBReader.cpp
index 615e8df..7b1265a 100644
--- a/src/io/WKBReader.cpp
+++ b/src/io/WKBReader.cpp
@@ -188,13 +188,21 @@ WKBReader::readGeometry()
                 dis.setOrder(ByteOrderValues::ENDIAN_BIG);
 
 	int typeInt = dis.readInt();
-	int geometryType = typeInt & 0xff;
+	/* Pick up both ISO and SFSQL geometry type */
+	int geometryType = (typeInt & 0xffff) % 1000;
+	/* ISO type range 1000 is Z, 2000 is M, 3000 is ZM */
+	int isoTypeRange = (typeInt & 0xffff) / 1000;
+	int isoHasZ = (isoTypeRange == 1) || (isoTypeRange == 3);
+	//int isoHasM = (isoTypeRange == 2) || (isoTypeRange == 3);
+	/* SFSQL high bit flag for Z, next bit for M */
+	int sfsqlHasZ = (typeInt & 0x80000000) != 0;
+	//int sfsqlHasM = (typeInt & 0x40000000) != 0;
 
 #if DEBUG_WKB_READER
 	cout<<"WKB geometryType: "<<geometryType<<endl;
 #endif
 
-	bool hasZ = ((typeInt & 0x80000000) != 0);
+	bool hasZ = sfsqlHasZ || isoHasZ;
 	if (hasZ) inputDimension = 3;
 	else inputDimension = 2; // doesn't handle M currently
 
diff --git a/tests/unit/io/WKBReaderTest.cpp b/tests/unit/io/WKBReaderTest.cpp
index b500765..c555d27 100644
--- a/tests/unit/io/WKBReaderTest.cpp
+++ b/tests/unit/io/WKBReaderTest.cpp
@@ -51,6 +51,16 @@ namespace tut
 			wktreader(gf.get())
 		{}
 
+		void testInputNdr(const std::string& WKT,
+				const std::string& ndrWKB)
+		{
+			GeomPtr gWKT(wktreader.read(WKT));
+			// NDR input
+			std::stringstream ndr_in(ndrWKB);
+			GeomPtr gWKB_ndr(wkbreader.readHEX(ndr_in));
+			ensure("NDR input", gWKB_ndr->equalsExact(gWKT.get()) );
+		}
+
 		void testInputOutput(const std::string& WKT,
 				const std::string& ndrWKB,
 				const std::string& xdrWKB)
@@ -277,6 +287,83 @@ namespace tut
     ensure_equals(gWKB->getCoordinateDimension(), 3);
   }
 
+	// 10 - Extended WKB with Z
+	template<>
+	template<>
+	void object::test<10>()
+	{
+		testInputNdr(
+			// WKT
+			"POINT Z(1 2 3)",
+			// NDR HEXWKB
+			"01010000A0E6100000000000000000F03F00000000000000400000000000000840"
+		);
+	}
+
+	// 11 - Extended WKB with Z
+	template<>
+	template<>
+	void object::test<11>()
+	{
+		testInputNdr(
+			// WKT
+			"LINESTRING Z(1 2 3, 4 5 6)",
+			// NDR HEXWKB
+			"01020000A0E610000002000000000000000000F03F00000000000000400000000000000840000000000000104000000000000014400000000000001840"
+		);
+	}
+
+	// 12 - Extended WKB with Z
+	template<>
+	template<>
+	void object::test<12>()
+	{
+		testInputNdr(
+			// WKT
+			"POLYGON Z((0 0 100,0 10 100,10 10 100,10 0 100,0 0 100),(1 1 100,1 9 100,9 9 100,9 1 100,1 1 100))",
+			// NDR HEXWKB
+			"01030000A0E6100000020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000F03F000000000000F03F0000000000005940000000000000F03F000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000F03F0000000000005940000000000000F03F000000000000F03F0000000000005940"
+		);
+	}
+
+	// 13 - Extended WKB with Z
+	template<>
+	template<>
+	void object::test<13>()
+	{
+		testInputNdr(
+			// WKT
+			"MULTIPOINT Z(0 1 2, 3 4 5)",
+			// NDR HEXWKB
+			"01040000A0E61000000200000001010000800000000000000000000000000000F03F00000000000000400101000080000000000000084000000000000010400000000000001440"
+		);
+	}
+
+	// 14 - Extended WKB with Z
+	template<>
+	template<>
+	void object::test<14>()
+	{
+		testInputNdr(
+			// WKT
+			"MULTILINESTRING Z((0 1 2,3 4 5),(6 7 8,9 10 11))",
+			// NDR HEXWKB
+			"01050000A0E6100000020000000102000080020000000000000000000000000000000000F03F000000000000004000000000000008400000000000001040000000000000144001020000800200000000000000000018400000000000001C400000000000002040000000000000224000000000000024400000000000002640"
+		);
+	}
+
+	// 15 - Extended WKB with Z
+	template<>
+	template<>
+	void object::test<15>()
+	{
+		testInputNdr(
+			// WKT
+			"MULTIPOLYGON Z(((0 0 100,0 10 100,10 10 100,10 0 100,0 0 100),(1 1 100,1 9 100,9 9 100,9 1 100,1 1 100)),((-9 0 50,-9 10 50,-1 10 50,-1 0 50,-9 0 50)))",
+			// NDR HEXWKB
+			"01060000A0E6100000020000000103000080020000000500000000000000000000000000000000000000000000000000594000000000000000000000000000002440000000000000594000000000000024400000000000002440000000000000594000000000000024400000000000000000000000000000594000000000000000000000000000000000000000000000594005000000000000000000F03F000000000000F03F0000000000005940000000000000F03F000000000000224000000000000059400000000000002240000000000000224000000000000059400000000000002240000000000000F03F0000000000005940000000000000F03F000000000000F03F00000000000059400103000080010000000500000000000000000022C00000000000000000000000000000494000000000000022C000000000000024400000000000004940000000000000F0BF00000000000024400000000000004940000000000000F0BF0000000000000000000000000000494000000000000022C000000000000000000000000000004940"
+		);
+	}
 
 } // namespace tut
 

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

Summary of changes:
 src/io/WKBReader.cpp            | 12 +++++-
 tests/unit/io/WKBReaderTest.cpp | 87 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list