I have installed QGIS server on Ubuntu 14.04 which serves WMS. Connection uses https and basic auth. URL is https://my.awesome.url:8090/cgi-bin/project1/qgis_mapserv.fcgi I can connect with QGIS and view my data. So far so good.
I installed OSGeo4W64 on Windows and are trying to build my own application using QGIS. I managed to build a window, load a simple shape, even load another WMS service but when trying to load my own WMS I get nothing except an error.
uri_separator = '&'
uri_url = 'url=https://my.awesome.url:8090/cgi-bin/project1/qgis_mapserv.fcgi'
uri_username = 'username=user'
uri_password = 'password=pass'
uri_format = 'format=image/png'
uri_layers = 'layers=mylayer'
uri_crs = 'crs=EPSG:25831'
url_with_params = uri_separator.join((uri_url,
uri_username,
uri_password,
uri_format,
uri_layers,
uri_crs))
rlayer = QgsRasterLayer(url_with_params, 'norther', 'wms')
print rlayer.error().message()
Result is:
<p><b>Raster layer:</b> Provider is not valid (provider: wms, URI: url=https://my.awesome.url:8090/cgi-bin/project1/qgis_mapserv.fcgi&username=user&password=pass&format=image/png&layers=mylayer&crs=EPSG:25831
The logs on the server don't give anything useful
I tried adding the following but that doesn't help.
uri_service = 'SERVICE=WMS'
uri_version = 'VERSION=1.3.0'
uri_request = 'REQUEST=GetMap'
I also tried remove format, layers and crs but then the error is:
<p><b>WMS provider:</b> Cannot calculate extent<p><b>Raster layer:</b> Provider is not valid (provider: wms, URI:
I'm already busy for hours and tried so many options, I'm really out of ideas...
1 Answer 1
Apparently it needs a styles&
in the URL, even when there is no style defined.
As the document OpenGIS Web Map Service (WMS) Implementation Specification states on www.opengeospatial.org in paragraph 7.3.2 GetMap request overview, table 8 the Styles parameter is mandatory.
The mandatory STYLES parameter lists the style in which each layer is to be rendered. The value of the STYLES parameter is a comma-separated list of one or more valid style names.
...
If all layers are to be shown using the default style, either the form "STYLES=" or "STYLES=,,," is valid.
-
Yes a
styles
parameter is required by the WMS specification, unless the WMS supports SLD, in which case it is optional when an SLD or SLD_BODY parameter is supplied as part of the GetMap requestnmtoken– nmtoken2017年01月15日 17:03:59 +00:00Commented Jan 15, 2017 at 17:03
Explore related questions
See similar questions with these tags.