2

I set <LayerLimit>1</LayerLimit> in service metadata in capabilities file to restrict the number of layers that the client is permitted to request in a single GetMap request. But when I add a new WMS layer in QGIS, still I can select multiple layers simultaneously and multiple layers are requested coma separated ("LAYERS=layer1,layer2,layer3"). Does layer limit work differently? What is the correct way to restrict multiple layers request?

WMS version

<WMS_Capabilities xmlns:xlink="http://www.w3.org/1999/xlink" version="1.3.0">
  • What software is providing the WMS service? – nmtoken Aug 15 '17 at 8:27
  • @nmtoken, I wrote a simple application in Python, it serves GetCapabilities and GetMap requests. It's based on Tornado. Geoprocessing is performed by means of GDAL + vsicurl – dr_times Aug 15 '17 at 8:44
  • @nmtoken, I'm not sure that the service matters here. I'd like to discourage the user to request multiple layers (at the client side) – dr_times Aug 15 '17 at 8:51
  • It's the server that sets the layer rule and responds to GetMap requests. A client may not parse the layerlimit parameter in the capabilities response and give a standard GetMap request with multiple layers. Just in the same way as a client is not meant to ask for CRS not advertised in the service, but can do so... it is up to the server to say no I don't support that CRS so I'm going to give an error. So... If the server gives multiple layers on a GetMap request, even though it advertises that only one layer can be requested, then that is a server issue. – nmtoken Aug 15 '17 at 11:16
2

For WMS 1.3.0 service implementations you can set a layer limit in the service metadata, how to do this varies on software.

For example in MapServer it is set in the MAP > WEB > METADATA section with "WMS_LAYERLIMIT" "8", and in the GetCapabilities response at location /WMS_Capabilities/Service/LayerLimit we have <LayerLimit>8</LayerLimit>.

If we look at the following GetMap requests (generated in QGIS) we can see the expected server behaviour to requests up to and beyond the layer limit.

Eight Layers requested (we get a map):

http://ogc.bgs.ac.uk/cgi-bin/TFL-PSI/ows?language=eng&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=32.51780000000000115,-9.379089999999999705,63.14789999999999992,37.84879999999999711&CRS=EPSG:4326&WIDTH=865&HEIGHT=561&LAYERS=ITA_Ancona4_ESA_EN_5k_psi_TS,ITA_Ancona4_ESA_EN_5k_psi_AvVEL,ITA_Ancona3_ESA_EN_5k_psi_TS,ITA_Ancona3_ESA_EN_5k_psi_AvVEL,ITA_Ancona2_ESA_EN_5k_psi_TS,ITA_Ancona2_ESA_EN_5k_psi_AvVEL,ITA_Ancona1_ESA_EN_5k_psi_TS,ITA_Ancona1_ESA_EN_5k_psi_AvVEL&STYLES=,,,,,,,&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE&

Nine layers requested (we get an error):

http://ogc.bgs.ac.uk/cgi-bin/TFL-PSI/ows?language=eng&&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=32.51780000000000115,-9.379089999999999705,63.14789999999999992,37.84879999999999711&CRS=EPSG:4326&WIDTH=865&HEIGHT=561&LAYERS=GRC_Athens_ESA_EN_5k_psi_AvVEL,ITA_Ancona4_ESA_EN_5k_psi_TS,ITA_Ancona4_ESA_EN_5k_psi_AvVEL,ITA_Ancona3_ESA_EN_5k_psi_TS,ITA_Ancona3_ESA_EN_5k_psi_AvVEL,ITA_Ancona2_ESA_EN_5k_psi_TS,ITA_Ancona2_ESA_EN_5k_psi_AvVEL,ITA_Ancona1_ESA_EN_5k_psi_TS,ITA_Ancona1_ESA_EN_5k_psi_AvVEL&STYLES=,,,,,,,,&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE&

<ServiceExceptionReport 
  xmlns="http://www.opengis.net/ogc" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  version="1.3.0" 
  xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
    <ServiceException>
    msWMSLoadGetMapParams(): WMS server error. 
    Number of layers requested exceeds LayerLimit.
    </ServiceException>
</ServiceExceptionReport>

So you are correct when you note that QGIS doesn't honour the advertised layer limit, this is technically a bug, because a client shouldn't request something that isn't advertised.

But your server is also at fault because it shouldn't provide something that the service provider (you) hasn't configured (even if the software is able to do so). People set limits on services for a reason...

  • thank you. Should I report an issue? – dr_times Aug 16 '17 at 16:48
  • It's always worth reporting an issue – nmtoken Aug 16 '17 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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