[mapserver-users] OGR/GeoJSON WRITE_BBOX

Tom tom at nthsense.net
Mon Jun 30 14:02:50 PDT 2014


Interesting - I too am using GDAL 1.9. Can you suggest anything else I can try?  I'm kind of at a loss as to how to narrow this down further.  Thanks for trying it out.

-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Even Rouault
Sent: Monday, June 30, 2014 4:58 PM
To: mapserver-users at lists.osgeo.org
Cc: Tom
Subject: Re: [mapserver-users] OGR/GeoJSON WRITE_BBOX

Le lundi 30 juin 2014 22:23:58, Tom a écrit :
> Hi Jukka,
> 
> 
> 
> That service you are fetching from returns the gml:boundedBy element, 
> which would correspond directly to the bbox of the FeatureCollection.  
> If I use GML which already has the boundedBy element in it, ogr2ogr 
> does in fact return a bbox at the FeatureCollection level.  When I 
> request my layer as GML, it returns a boundedBy element.  When I 
> request it as GeoJSON, the bbox is not there.  I think this points to 
> a Mapserver issue.  Do you agree?

I don't think so. I've just tested adding your outputformat definition in a Mapfile and I get the bbox at FeatureCollection level :

$ mapserv
QUERY_STRING="map=test_geojson.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=popplace&OUTPUTFORMAT=geojson"
Content-Disposition: attachment; filename=result.dat
Content-Type: application/json; subtype=geojson

{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3978" 
} },
"bbox": [ 2279399.0, -55344.50390625, 2600377.0, 461586.8125 ],                 
"features": [
...snip...
]
}

I've only tested with mapserver master and GDAL trunk, but don't see why it wouldn't work with GDAL >= 1.9.

> 
> 
> 
> Tom
> 
> 
> 
> From: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Rahkonen 
> Jukka (Tike)
> Sent: Monday, June 30, 2014 2:48 PM
> To: Tom; mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] OGR/GeoJSON WRITE_BBOX
> 
> 
> 
> Hi,
> 
> Perhaps it is your GDAL version that does not write the BBOX for the 
> collection? This gets GML from Mapserver WFS and converts it into 
> geojson
> 
> ogr2ogr -f geojson test_ms.json -lco WRITE_BBOX=YES 
> "http://hip.latuviitta.org/cgi-bin/mapserver_wfs?service=wfs
> <http://hip.latuviitta.org/cgi-bin/mapserver_wfs?service=wfs&version=1
> .0.0& r equest=getfeature&typename=municipalities&maxfeatures=10>
> &version=1.0.0&request=getfeature&typename=municipalities&maxfeatures=10"
> 
> Result begins
> 
> {
> "type": "FeatureCollection",
> "crs": { "type": "name", "properties": { "name":
> "urn:ogc:def:crs:EPSG::3067" } },
> "bbox": [ 349631.3148, 7066945.4181, 673079.7106, 7776424.2258 ],
> "features": [
> 
> -Jukka-
> 
>   _____
> 
>  Tom wrote:
> 
> Thanks, Jukka.  I see that Geoserver is including the 
> FeatureCollection bbox, but my GeoJSON from Mapserver is not.  If I 
> take the json from my WFS call and run it through ogr2ogr as you 
> suggested, the output is an exact copy of the original.  I still get 
> bbox for the individual features, but not the feature collection.  I 
> tried GDAL 1.9 and 2.0-dev.  Perhaps there is something missing from 
> my layer configuration, or could it be that Geoserver has this capability but Mapserver does not?
> 
> 
> 
> From: mapserver-users-bounces at lists.osgeo.org
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Rahkonen 
> Jukka (Tike)
> Sent: Monday, June 30, 2014 12:47 PM
> To: Tom; mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] OGR/GeoJSON WRITE_BBOX
> 
> 
> 
> Hi,
> 
> About how to test if it is an OGR issue, make a test with OGR. Capture 
> some data for example from some Geoserver WFS and convert it into 
> geojson with ogr2ogr
> 
> ogr2ogr -f geojson test.json -lco WRITE_BBOX=YES 
> "http://demo.opengeo.org/geoserver/wfs?service=wfs
> <http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.0.0&reque
> st=ge t feature&typename=og:archsites&outputformat=application/json>
> &version=1.0.0&request=getfeature&typename=og:archsites&outputformat=a
> pplic
> a tion/json"
> 
> See the beginning of the result
> 
> {
> "type": "FeatureCollection",
> "crs": { "type": "name", "properties": { "name":
> "urn:ogc:def:crs:EPSG::26713" } },
> "bbox": [ 589860.0, 4914479.0, 608355.0, 4926490.0 ],
> "features": [
> 
> Conclusion: ogr2ogr can do it. My version is GDAL 2.0-dev.
> 
> -Jukka Rahkonen-
> 
>   _____
> 
> Tom wrote:
> 
> Hi folks,
> 
> 
> 
> I'm trying to use OGR to output GeoJSON from my WFS service.  I'd like 
> to include the BBOX (equivalent of gml:boundedBy) at the 
> FeatureCollection level.  From the documentation, it looks like I 
> should be able to set it up this way:
> 
> 
> 
> OUTPUTFORMAT
> 
>                   NAME "GEOJSON"
> 
>                   DRIVER "OGR/GeoJSON"
> 
>                   MIMETYPE "application/json; subtype=geojson"
> 
>                   FORMATOPTION "STORAGE=memory"
> 
>                   FORMATOPTION "FORM=SIMPLE"
> 
>                 FORMATOPTION "LCO:WRITE_BBOX=YES"
> 
> END
> 
> 
> 
> According to http://www.gdal.org/drv_geojson.html, WRITE_BBOX is 
> exactly what I need.  According to the docs, it should create a bbox 
> at the FeatureCollection and the Feature level.  For me, it generates 
> a bbox for every feature, but not one for the top-level 
> FeatureCollection, which OGR claims to support.
> 
> 
> 
> Does anyone have experience with this?  Any idea how I could determine 
> if this would be a Mapserver issue, or an OGR issue?
> 
> 
> 
> Thanks,
> 
> 
> 
> Tom

--
Geospatial professional services
http://even.rouault.free.fr/services.html
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the MapServer-users mailing list