[TinyOWS-dev] GeoJSON output should include srs at FeatureCollection level

Even Rouault even.rouault at mines-paris.org
Sat May 14 08:32:04 EST 2011


Hi,

GetFeature request with outputformat=application/json currently returns an 
output like (indented for better readability):

{
  "type": "FeatureCollection",
  "features": [
  {
    "type":"Feature",
    "properties":{ ... },
    "geometry":{
        "type":"Polygon",
        "crs":{
            "type":"name",
            "properties":{"name":"urn:ogc:def:crs:EPSG::xxxx"}
        },
        "bbox":[...],
        "coordinates":[[[...]]]
     }
  },
  {
    "type":"Feature",
    "properties":{ ... },
    "geometry":{
        "type":"Polygon",
        "crs":{
            "type":"name",
            "properties":{"name":"urn:ogc:def:crs:EPSG::xxxx"}
        },
        "bbox":[...],
        "coordinates":[[[...]]]
     }
  }
  ]
}

Note the crs member added for each Feature.

The GeoJSON specs instead recommands in http://geojson.org/geojson-
spec.html#coordinate-reference-system-objects :

"The crs member should be on the top-level GeoJSON object in a hierarchy (in 
feature collection, feature, geometry order) and should not be repeated or 
overridden on children or grandchildren of the object."

So it should be like :

{
  "type": "FeatureCollection",
  "crs":{
    "type":"name",
    "properties":{"name":"urn:ogc:def:crs:EPSG::xxxx"}
  },
  "features": [
  {
    "type":"Feature",
    "properties":{ ... },
    "geometry":{
        "type":"Polygon",
        "bbox":[...],
        "coordinates":[[[...]]]
     }
  },
  {
    "type":"Feature",
    "properties":{ ... },
    "geometry":{
        "type":"Polygon",
        "bbox":[...],
        "coordinates":[[[...]]]
     }
  }
  ]
}

For instance, the OGR GeoJSON driver will not be able to fetch the SRS if it 
is only defined at the Feature level, and not at the FeatureCollection level. 
(I think that the repetition in children doesn't really harm - at least it 
won't harm the OGR GeoJSON driver - except it increases bandwidth)

Best regards,

Even




More information about the TinyOWS-dev mailing list