#1996 closed defect (fixed)
ST_AsGeoJSON('POINT EMPTY') produces invalid JSON
Reported by: | cdestigter | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.1.0 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
This one's valid:
# select st_asgeojson('GEOMETRYCOLLECTION EMPTY'::geometry); st_asgeojson ----------------------------------------------- {"type":"GeometryCollection","geometries":[]} (1 row)
This one's not:
# select st_asgeojson('POINT EMPTY'::geometry); st_asgeojson --------------------------------- {"type":"Point","coordinates":} (1 row)
I understand that POINT EMPTY isn't valid as WKB, but that shouldn't affect its ability to produce valid JSON. Even it means it comes out as MULTIPOINT EMPTY instead.
The other empty geometry types seem to be fine, only POINT is affected.
POSTGIS="2.1.0SVN r10262" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.6"
PostgreSQL 9.0.6 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3, 64-bit
Change History (3)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 12 years ago
Regardless of the odd dimensionality of the structure, using an empty array at least allows code to blindly test for length==0 as an isEmpty test. Went with that fix as suggested by original filer.
Hm, this is an interesting question… given that a non-empty point returns this
and a non-empty linestring returns this
I would expect the empty linestring to return an array with zero elements, but the coordinates type for the point is not an array, it's just a coordinate. So we'd be returning an empty array (dimensionality 1) in the empty case, but a singleton coordinate (dimensionality 0) in the non-empty case. If that's OK, we can do it. Unfortunately, looks like there is not any official guidance on what to do for empty.