Opened 4 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 , 4 years ago
Milestone: | PostGIS 3.1.2 → 3.1.3 |
---|
comment:2 by , 4 years ago
Milestone: | 3.1.3 → PostGIS 3.1.3 |
---|
comment:5 by , 3 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.
Milestone renamed