twpayne / go-geom

Package geom implements efficient geometry types for geospatial applications.
BSD 2-Clause "Simplified" License
841 stars 104 forks source link

encoding/wkb: POINT EMPTY encodes and decodes differently #164

Closed otan closed 4 years ago

otan commented 4 years ago

It seems as if POINT EMPTY when encoded to a WKB with encoding/wkb and then decoded will error with EOF as it tries to read more points, but there not any (with ReadFloatArray). Unfortunately this presents an annoying behaviour where Encode(Decode('POINT EMPTY')) != "POINT EMPTY')

From https://github.com/twpayne/go-geom/pull/161#issuecomment-631539451, it appears there's no WKB compliant way of representing POINT EMPTY.

Here are a few options we can do:

I'm also for the argument that for EWKB, we should copy exactly what PostGIS does - after all, EWKB seems to be PostGIS specific. This backtracks my previous support for option 3 of https://github.com/twpayne/go-geom/pull/161#issuecomment-631539451.

twpayne commented 4 years ago

Iterating on this:

I'm idly wondering if we should create wkb.Encoder type with functional options, which would potentially allow a unification of the encoding/{wkb,ewkb,wkbcommon} code, but this requires more thought.