[mapserver-users] WFS GeoJSON Output Missing numberMatched

Seth G sethg at geographika.co.uk
Wed Jun 5 14:43:22 PDT 2019


Hi all,

I'm currently working on a front-end grid that requests features via WFS 2.0 and loads them using OpenLayers. 
OpenLayers 4 doesn't support parsing of GML3 used by WFS 2.0, but I can return features as GeoJSON by setting the output format as follows:

    OUTPUTFORMAT
        NAME "geojson"
        DRIVER "OGR/GEOJSON"
        MIMETYPE "application/json; subtype=geojson"
        FORMATOPTION "FORM=SIMPLE"
        FORMATOPTION "STORAGE=memory"
    END

Then setting WEB > METADATA > "wfs_getfeature_formatlist" "gml,geojson,application/json"

WFS requests  are then made with URL parameters such as &service=WFS&version=2.0.0&request=GetFeature&typeName=MyLayer&outputFormat=application%2Fjson&startIndex=0&count=20

Everything works fine including paging, but in order to calculate how many "pages" of data I need to get the numberMatched property. 
This can be turned on for GML3 using WEB > METADATA > "wfs_compute_number_matched" "true" (as noted at https://mapserver.org/fr/ogc/wfs_server.html#web-object-metadata). 

If I then request GML with outputFormat=gml3 the GML response includes numberMatched="6607" (the number of features in the layer). 

As GML3 features can't be rendered in OpenLayers I'd like to get this property added to the GeoJSON output. This appears to be implemented in GeoServer. 
I was wondering if this is something that can be configured somewhere in the Mapfile perhaps as an option for the OGR/GEOJSON driver (https://gdal.org/drivers/vector/geojson.html). 
The timeStamp, numberReturned are also missing from the GeoJSON output. 

Any ideas or hints appreciated,

Seth


--
web:http://geographika.co.uk
twitter: @geographika


More information about the mapserver-users mailing list