[postgis-tickets] [PostGIS] #4799: ST_AsGeoJSON doesn't export the CRS of multiple geometry columns

PostGIS trac at osgeo.org
Fri Nov 20 18:18:03 PST 2020


#4799: ST_AsGeoJSON doesn't export the CRS of multiple geometry columns
----------------------------------+---------------------------
 Reporter:  tobwen                |      Owner:  pramsey
     Type:  enhancement           |     Status:  new
 Priority:  medium                |  Milestone:  PostGIS 3.1.0
Component:  postgis               |    Version:  master
 Keywords:  geojson, json, jsonb  |
----------------------------------+---------------------------
 == summary
 ST_AsGeoJSON only uses the first geometry column to create the feature's
 geometry. The other geometry columns get stored in properties. But here,
 the CRS is missing. It's not in GeoJSON specs, but it might be useful to
 reconstruct the geometry.

 == example
 {{{
 SELECT
     ST_AsGeoJSON(data.*)
 FROM
     (SELECT
         1 AS id,
         ST_Transform(geom, 3035) geom,
         ST_Transform(geom, 25832) geom
     FROM
         ST_SetSRID(ST_MakePoint(7, 51), 4326) geom
     ) data;
 }}}

 == result
 {{{
 {
   "type":"Feature",
   "geometry":{
     "type":"Point",
     "crs":{
       "type":"name",
       "properties":{
         "name":"EPSG:3035"
       }
     },
     "coordinates":[
       4110471.051819585,
       3103060.820290524
     ]
   },
   "properties":{
     "id":1,
     "geom":{
       "type":"Point",
       "coordinates":[
         359666.70366028673,
         5651728.682548149
       ]
     }
   }
 }
 }}}

 == nice to have
 {{{
 {
   "type":"Feature",
   "geometry":{
     "type":"Point",
     "crs":{
       "type":"name",
       "properties":{
         "name":"EPSG:3035"
       }
     },
     "coordinates":[
       4110471.051819585,
       3103060.820290524
     ]
   },
   "properties":{
     "id":1,
     "geom":{
       "crs":{
         "type":"name",
         "properties":{
           "name":"EPSG:25832"
         }
       },
       "type":"Point",
       "coordinates":[
         359666.70366028673,
         5651728.682548149
       ]
     }
   }
 }
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4799>
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