2

I serve WMS and WFS data using QGIS server and have a problem with projections. My project uses CRS EPSG:3857, the layers use CRS EPSG:4326.

Showing a WMS layer using Openlayers works fine. Tiles are called like that:

http://localhost/cgi-bin/project/qgis_mapserv.fcgi?map=/home/gerald/project.qgs&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=riversWithName&WIDTH=256&HEIGHT=256&CRS=EPSG:3857&STYLES=&BBOX=-469629.10178412125,4696291.017841229,-313086.06785608025,4852834.051769271

When I try to get the same layer as WFS data (based on this example from Openlayers) it doesn't work:

http://localhost/cgi-bin/project/qgis_mapserv.fcgi?map=/home/gerald/project.qgs&service=WFS&version=1.1.0&request=GetFeature&typename=riversWithName&outputFormat=GeoJSON&srsname=EPSG:3857&bbox=-469629.10178412125,4696291.017841229,-313086.06785608025,4852834.051769271,EPSG:3857

It expects the bounding box as EPSG:4326, the same call defining "projection: 4326 in the Openlayers view works fine and returns the features:

http://localhost/cgi-bin/project/qgis_mapserv.fcgi?map=/home/gerald/project.qgs&service=WFS&version=1.1.0&request=GetFeature&typename=riversWithName&outputFormat=GeoJSON&srsname=EPSG:3857&bbox=-2.94186767578125,38.78664566796875,6.51186767578125,44.06557633203125,EPSG:3857

What do I have to do to make it work with standard Openlayers projections 3857?

5
  • What projections are reported as being supported in the GetCapabilities response of the WFS and WMS services? The QGIS docs tell me that only WFS 1.0.0 is supported, are you really getting a WFS 1.1.0 response?
    – nmtoken
    Commented Sep 18, 2017 at 18:49
  • You say the same call defining "projection: 4326 in the Openlayers view works fine and returns the features: but the example you give cites srsname=EPSG:3857 though the bounding box does look like they are degrees. Are you sure that it is working as expected?
    – nmtoken
    Commented Sep 18, 2017 at 18:56
  • You are right, WFS data is version 1.0.0. GetCapabilities shows that WFS reports only CRS 4326, but WMS supports also 3857. But I don't see any option to add projections to the WFS capabilities. About your second comment: Despite citing wrong projection, the features get returned fine. So in conclusion it seems that I do have to fix the CRS of the layer in QGIS right?
    – geraldo
    Commented Sep 18, 2017 at 20:27
  • A client (OpenLayers) should only request a CRS listed as supported by the service, and a (standards compliant) service should only return data/maps in a supported CRS, so if you want to request EPSG:3857 from the WFS then you need to add that support to your service.
    – nmtoken
    Commented Sep 19, 2017 at 9:41
  • Thanks for your hint. I changed layer CRS to 3857 and WFS GetCapabilities shows it as supported. Now the second GetFeature Request works fine for the defined layer bounds. If you want to convert your comment in an answer, I'll accept it.
    – geraldo
    Commented Sep 19, 2017 at 9:51

1 Answer 1

1

A client (OpenLayers) should only request a CRS listed as supported by the service, and a (standards compliant) service should only return data/maps in a supported CRS, so if you want to request EPSG:3857 from the WFS then you need to add that support to your service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.