Closed otan closed 4 years ago
Iterating on this:
encoding/ewkb
should copy exactly what PostGIS does for exactly the reason you propose. Very good idea.POINT EMPTY
, I think encoding/wkb
should return an error cannot encode geometry
or similar when asked to encode one. Similarly, since POINT EMPTY
has no representation in WKB, encoding/wkb
should under no circumstances return POINT EMPTY
and instead return an error.encoding/ewkb
could potentially wrap encoding/wkb
, for example by translating POINT EMPTY
into POINT(NaN NaN)
and vice versa.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.
It seems as if
POINT EMPTY
when encoded to a WKB with encoding/wkb and then decoded will error withEOF
as it tries to read more points, but there not any (withReadFloatArray
). Unfortunately this presents an annoying behaviour whereEncode(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:
POINT EMPTY
error when decoding to a WKB?POINT EMPTY
if there are 0 bytes left to read? (not sure that's possible as theio.Reader
has noBytesRemaining
which is kind of annoying)?NaN, NaN
syntax as previously put forward by https://github.com/twpayne/go-geom/pull/161?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.