Opened 3 years ago

Closed 3 years ago

#4895 closed defect (fixed)

Problem of GeoJSON support with empty geometries

Reported by: ezimanyi Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.4
Component: postgis Version: 2.5.x -- EOL
Keywords: Cc:

Description

I haven't tested all geometry types but I have found already the problems below.

test=# select ST_AsGeoJSON(geometry 'Linestring empty'), ST_asText(ST_GeomFromGeoJSON(ST_AsGeoJSON(geometry 'Linestring empty')));

st_asgeojson | st_astext


{"type":"LineString","coordinates":[]} | LINESTRING Z EMPTY

(1 row)

test=# select ST_AsGeoJSON(geometry 'Point empty'), ST_asText(ST_GeomFromGeoJSON(ST_AsGeoJSON(geometry 'Point empty'))); ERROR: Too few ordinates in GeoJSON

test=# select postgis_full_version(); POSTGIS="2.5.5" [EXTENSION] PGSQL="130" GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 6.3.1, February 10th, 2020" GDAL="GDAL 3.0 .4, released 2020/01/28" LIBXML="2.9.10" LIBJSON="0.13.1" RASTER

Esteban

Change History (5)

comment:1 by pramsey, 3 years ago

Milestone: PostGIS 3.1.23.1.3

comment:2 by pramsey, 3 years ago

Milestone: 3.1.3PostGIS 3.1.3

Milestone renamed

comment:3 by robe, 3 years ago

Milestone: PostGIS 3.1.3PostGIS 3.1.4

In prep for 3.1.3 release

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

In b4e803d/git:

Allow empty geometry to round-trip JSON format, references #4895

comment:5 by pramsey, 3 years ago

Resolution: fixed
Status: newclosed

OK, with a little more rigour on JSON emitted and a little more flexibility on JSON consumed, we can now round-trip EMPTY geometry. They are not round-tripping in full fidelity, in particular collections of empty are flattened to just a single empty.

MULTIPOINT(EMPTY, EMPTY) => MULTIPOINT EMPTY

But on the general principle that "empty is empty", which our other empty handling tries to largely follow, this will do.

Note: See TracTickets for help on using tickets.