Skip to content

geo: SpatialObjectToWKT() omits empty shapes in collections  #53632

@erikgrinaker

Description

@erikgrinaker

Describe the problem

While implementing ST_ForceCollection, I have a test case which generates a geometry collection with an empty point. However, calling geo.SpatialObjectToWKT omits the empty point from the output.

To Reproduce

func TestEmptyPointWKT(t *testing.T) {
	gc := geom.NewGeometryCollection().SetSRID(int(geopb.DefaultGeographySRID))
	gc.MustPush(geom.NewPointEmpty(geom.XY))
	g, err := geo.MakeGeographyFromGeomT(gc)
	require.NoError(t, err)
	wkt, err := geo.SpatialObjectToWKT(g.SpatialObject(), 0)
	require.NoError(t, err)
	require.EqualValues(t, "GEOMETRYCOLLECTION (POINT EMPTY)", wkt)
}

This yields a test failure:

Not equal: 
expected: string("GEOMETRYCOLLECTION (POINT EMPTY)")
actual  : geopb.WKT("GEOMETRYCOLLECTION EMPTY")

PostGIS can represent this just fine:

postgis=# select st_astext(st_forcecollection('POINT EMPTY'));
            st_astext            
---------------------------------
 GEOMETRYCOLLECTION(POINT EMPTY)
(1 row)

Environment:

  • CockroachDB version: master at 8b91062f93
  • Server OS: macOS
  • Client app: cockroach demo

CC @otan

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions