go-spatial / geom

Geometry interfaces to help drive interoperability within the Go geospatial community
MIT License
168 stars 37 forks source link

wkt: behavior for pointless geometries and empty #68

Closed ear7h closed 4 years ago

ear7h commented 5 years ago

Currently, the encoder will clean up "pointless" (hehe) geometries and count them as empty. For example, from the wkt tests:

{
    Geom: &geom.MultiPolygon{{{}}, {{}}},
    Rep:  "MULTIPOLYGON EMPTY",
},

At the moment, I'm cleaning up the wkt parser and my, simpler, implementation does not do this (yet?). I've been using the postgis the implementations of a wkt {en,de}coder and it seems that it is inconsistent with itself. I believe the fidelity of the structure of the geometries should be kept, but it seems the convention is to remove pointless geometries.

postgis output:

$ psql -d natural_earth -t -c "select ST_AsText(ST_AsBinary('geometrycollection ( linestring empty )'::geometry)::geometry)"
 GEOMETRYCOLLECTION EMPTY
$ psql -d natural_earth -t -c "select ST_AsText(ST_GeomFromText('geometrycollection (linestring empty)'))"   
 GEOMETRYCOLLECTION(LINESTRING EMPTY)
ear7h commented 4 years ago

closed via #69 #78 #83