Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#1005 closed defect (fixed)

Writing POINT EMPTY in WKB

Reported by: Mike Taves Owned by: geos-devel@…
Priority: major Milestone:
Component: Default Version: main
Severity: Annoyance Keywords:
Cc:

Description

An empty point can be created in GEOS by reading the WKT POINT EMPTY or the WKB 0101000000000000000000F87F000000000000F87F (i.e. "POINT(NaN NaN)").

This point can be written back by GEOS as WKT to get POINT EMPTY, however it cannot be converted back to WKB, as WKBWriter.cpp will throw:

util::IllegalArgumentException("Empty Points cannot be represented in WKB")

Given that GEOS is happy to read/write POINT EMPTY and read the WKB, shouldn't it be able to write the WKB geometry too?

See PostGIS ticket #3031 for related discussion.

Change History (9)

comment:1 by Mike Taves, 4 years ago

Or more relevant, see PostGIS #ticket 3181

comment:2 by jorisvandenbossche, 4 years ago

What are the thoughts about adding this special case to GEOS? I think it would be good to have consistency in reading vs writing in GOES, and enable a full roundtrip.

Further, PostGIS does this as well, and I think Shapely/PyGEOS would like to do this as well (in which case they need to add a special case on top of their usage of GEOS if it is not changed in GEOS itself).

comment:3 by mdavis, 4 years ago

+1, especially since this was recently fixed in JTS.

comment:4 by Paul Ramsey <pramsey@…>, 4 years ago

In 466cff1/git:

Output POINT EMPTY in WKB. References #1005

comment:5 by pramsey, 4 years ago

Resolution: fixed
Status: newclosed

comment:6 by Mike Taves, 4 years ago

Just tested master, and I see POINT EMPTY -> 0101000080000000000000F87F000000000000F87F000000000000F87F -> POINT Z EMPTY, which is a bit of a surprise. Three-dimensional empty geometries are getting really abstract. Could this just be WKB for POINT EMPTY?

comment:7 by Mike Taves, 4 years ago

With POINT EMPTY, GEOSGeom_getCoordinateDimension is currently returning 3.

With MULTIPOINT EMPTY this is 2, not 3.

comment:8 by Mike Taves, 4 years ago

A related issue regarding the 3D oddities is in #1048

comment:9 by pramsey, 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.

Note: See TracTickets for help on using tickets.