[PostGIS] #5597: ST_AsGeoJSONRow: Invalid output for null geometry

PostGIS trac at osgeo.org
Mon Oct 30 12:37:04 PDT 2023


#5597: ST_AsGeoJSONRow: Invalid output for null geometry
---------------------+---------------------------
 Reporter:  jtojnar  |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 3.4.1
Component:  postgis  |    Version:  3.4.x
 Keywords:  json     |
---------------------+---------------------------
 According to the GeoJSON RFC, [https://www.rfc-
 editor.org/rfc/rfc7946#section-3.1 the `type` member of Geometry must be
 one of seven geometry type names]. This is not the case when a row
 containing a NULL geometry column is converted to GeoJSON Feature:

 {{{
 postgres=# select ST_AsGeoJSON(r.*) from (values (null::geometry)) as
 r(geom);
                            st_asgeojson
 -------------------------------------------------------------------
  {"type": "Feature", "geometry": {"type": null}, "properties": {}}
 (1 row)
 }}}

 The proper representation is `"geometry": null`, see [https://www.rfc-
 editor.org/rfc/rfc7946#section-3.2 section 3.2].

 This can be
 [https://github.com/postgis/postgis/blob/a5e9fc1124d0de4d6994e5572fd66b1c78fc7af9/postgis/lwgeom_out_geojson.c#L194
 trivially fixed] but I am not sure whether it would be an acceptable BC
 break.
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5597>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list