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:
Raster layer: 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:
WMS provider: Cannot calculate extent
Raster layer: Provider is not valid (provider: wms, URI:
I'm already busy for hours and tried so many options, I'm really out of ideas...
Answer
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.
No comments:
Post a Comment