[MapServer-users] WFS, OpenLayers and OUTPUTFORMAT explanations

mathias cunault mathias.cunault at inrap.fr
Tue Mar 19 03:26:11 PDT 2024


Hello,
Something that was never clear to me.
Here is a mapfile for a WFS definition:
MAP
NAME "Mapserver-Inrap"
FONTSET "C:\ms4w\Apache\site\fonts\fonts.txt"
OUTPUTFORMAT
NAME "geojson"
DRIVER "OGR/GEOJSON"
MIMETYPE "application/json;subtype=geojson" #option
# FORMATOPTION "STORAGE=stream" #requis
# FORMATOPTION "FORM=SIMPLE"
FORMATOPTION "STORAGE=memory" #requis
FORMATOPTION "FORM=SIMPLE"
END #fin format

EXTENT 103362.94 6049964.789658545 1242388.010000001 7108973.60237487 #xmin
ymin xmax ymax
51.075383199990654 #xmin ymin xmax ymax
UNITS METERS
DEBUG 5
CONFIG "CPL_DEBUG" "ON"
CONFIG "PROJ_DEBUG" "ON"
CONFIG MS_ERRORFILE
"C:/ms4w/Apache/error/errorMapFile_vue_ol_prescription.txt"

SYMBOLSET "C:\ms4w\Apache\site\symbols\symbols.sym"

PROJECTION # proj de sortie
"init=epsg:2154"
END

WEB
METADATA
"wfs_title" "WFS Caviar"
"wfs_onlineresource" "
http://xxxx/mapserv.exe?MAP=C:/ms4w/Apache/site/mapfile/vue_ol_prescription.map
"
"wms_encoding" "UTF-8"
"wfs_srs" "EPSG:2154 EPSG:32620 EPSG:3857 EPSG:900913 EPSG:4326"
"wfs_enable_request" "*"
"wfs_abstract" "blabla"
"wfs_getfeature_formatlist" "application/json, GeoJSON, json"
END #fin metadata
END #end web

#-----debut prescription
LAYER
NAME "prescription"
TYPE POLYGON
CONNECTIONTYPE POSTGIS
CONNECTION "host=xxx dbname=activite user=wxxx password=xxx port=5432"
DATA "geom from activite.vue_ol_prescription using unique gid using
SRID=2154"
EXTENT 103362.94 6049964.789658545 1242388.010000001 7108973.60237487 #aide
pour performance
PROCESSING "CLOSE_CONNECTION=DEFER"
CLASS
...
END #-----fin classe unique
METADATA
"gml_include_items" "all" #obligé pour afficher attributs getfeatureinfo
"wfs_title" "prescription_2154"
#d'après la doc pas besoin si défini dans les metadata de la map cf.10.1
#"wfs_srs" "EPSG:2154"
"gml_featureid" "gid"
"wfs_enable_request" "*"
"wfs_use_default_extent_for_getfeature" "false"
# si geojson en premier alors geoson dans l'url pour OpenLayers:
"wfs_getfeature_formatlist" "GeoJSON, json, application/json"
END #fin metadata prescription
TEMPLATE "bidon.html"
END #fin layer prescription

END #-----fin mapfile

It works fine in QGIS.
In a javascript file with the OpenLayers library, I can define a source
with an url function like this:
 url: function (extent) {
    return (
      "http://xxxx/cgi-bin/mapserv.exe?MAP=C:/.../vue_ol_prescription.map&"
+
      "service=WFS&version=1.1.0&request=GetFeature&typename=prescription&"
+
      "outputformat=geojson&SRSNAME=EPSG:2154&bbox=" +
      extent.join(",") +
      ",EPSG:3857"
    )

Why can't I use outputformat = application/json though it is permitted by
the outpuformat in mapfile layer definition ? I have an error :
"application.json  not permitted".
Leehan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20240319/b1d958b7/attachment.htm>


More information about the MapServer-users mailing list