Opened 4 years ago
Closed 3 years ago
#1048 closed defect (fixed)
WKB representation of POINT EMPTY has 3 dimensions
Reported by: | Mike Taves | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Default | Version: | main |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
This is related to #1005
An empty point geometry can be created using either POINT EMPTY
or with GEOSGeom_createEmptyPoint_r
. This geometry returns 0 from GEOSHasZ_r
and the WKT representation is POINT EMPTY
, as expected.
However, the WKB representation is 0101000080000000000000F87F000000000000F87F000000000000F87F
or POINT Z EMPTY
. The expected result should be 0101000000000000000000F87F000000000000F87F
.
The only workaround is to use GEOSWKBWriter_setOutputDimension_r
to write a 2D representation.
Note that WKB representations of MULTIPOINT EMPTY
or GEOSGeom_createEmptyLineString_r
do not contain Z coordinate info, for any WKB writer output dimension setting.
Change History (5)
comment:2 by , 4 years ago
Another related inconsistency GEOMETRYCOLLECTION (POINT(1 2), POINT EMPTY)
returns 0107000080020000000101000000000000000000F03F00000000000000400101000080000000000000F87F000000000000F87F000000000000F87F
, which is not portable WKB. Handing this to PostGIS raises "Dimensions mismatch in lwcollection", because of the extra coordinate surprise.
comment:3 by , 3 years ago
In general the WKT reader and default creators try to create things with 3d coordinates, which is counter to my own sense of "least surprise". Directly relating to this ticket, the EMPTY case in WKT reader fails to note the presence of any dimensionality tags in the input (POINT Z EMPTY) and just creates a 3d empty every time. Looks like most types will need to be touched to put this completely right.
comment:4 by , 3 years ago
In general the WKT parser did not parse in "GEOMETRY Z EMPTY" forms and notice there was a Z there. Point was fiddly to fix, and that still left other types, so I figured I'd fix them all... turns out the core model of GEOS/JTS can't even represent a "GEOMETRYCOLLECTION Z EMPTY" of any type. There's nowhere for the dimensionality to live!
Also! The question of what to instantiate for a "POINT EMPTY", dimensionally speaking. The default in the code was a 3D empty. That seemed wrong to me, so I've moved it down to a 2D empty. That should also cause other things to harmonize. There was also a bug hiding, in the clone() method, that incorrectly cloned 2D POINT EMPTY.
Anyways, just waiting for a CI build before merging, but suffice to say this isn't a *comprehensive* fix, since that requires some larger restructuring to even be able to represent some of these concepts that are expressible in WKT and WKB.
Also, unsure if this is directly related, but WKT
GEOMETRYCOLLECTION (POINT EMPTY)
returns WKB0107000080010000000101000080000000000000F87F000000000000F87F000000000000F87F
orGEOMETRYCOLLECTION Z (POINT Z EMPTY)
Whereas
GEOMETRYCOLLECTION (MULTIPOINT EMPTY)
remains a 2D GeometryCollection with010700000001000000010400000000000000