Opened 4 years ago
Closed 3 years ago
#1040 closed defect (fixed)
GeometryCollection with all empty parts does not accurately serialize to WKT or WKB
Reported by: | Mike Taves | Owned by: | strk |
---|---|---|---|
Priority: | major | Milestone: | 3.10.0 |
Component: | Core | Version: | 3.8.0 |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
This is discovered via Shapely version <2 via ctypes. Take a GeometryCollectgion with all empty parts:
from shapely import geos, wkt print(geos.geos_version_string) # 3.8.0-CAPI-1.13.1 g = wkt.loads("GEOMETRYCOLLECTION(LINESTRING EMPTY, POLYGON EMPTY)") # correct behavior for n in range(geos.lgeos.GEOSGetNumGeometries(g._geom)): gn = geos.lgeos.GEOSGetGeometryN(g._geom, n) print('{}: {}'.format(n, geos.lgeos.GEOSGeomToWKT(gn))) # 0: LINESTRING EMPTY # 1: POLYGON EMPTY # incorrect WKT print(g.wkt) # GEOMETRYCOLLECTION EMPTY # incorrect hex-encoded WKB print(g.wkb_hex) # 010700008002000000010200008000000000010300008000000000 # should be 2D: 010700000002000000010200000000000000010300000000000000
The expected WKT should be the same as the input. JTS appears to have this issue too.
The WKB output is a slightly different issue, as it correctly returns a multi-part empty GeometryCollection, but they are surprisingly 3D geometries! PostGIS says it is "GEOMETRYCOLLECTION Z (LINESTRING Z EMPTY,POLYGON Z EMPTY)".
Note:
See TracTickets
for help on using tickets.
I get worried changing things down so low... https://github.com/libgeos/geos/pull/451