Bug report #11885

Add WMS layer throw python console -> QGIS Crash

Added by Evgeniy Nikulin about 5 years ago. Updated over 4 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Web Services clients/WMS
Affected QGIS version:2.6.0 Regression?:No
Operating System:Linux Easy fix?:No
Pull Request or Patch supplied:No Resolution:worksforme
Crashes QGIS or corrupts data:Yes Copied to github as #:20099

Description

I try to add wms layer to the map:

http://maps.rosreestr.ru/arcgis/services/Cadastre/CadastreWMS/MapServer/WMSServer?

If I use the GUI, then everything is fine.
But when I try to add throw Python console, the qgis crashes.

My code :

wms_url = 'http://maps.rosreestr.ru/arcgis/services/Cadastre/CadastreWMS/MapServer/WMSServer?format=image/png&layers=1&styles=&crs=EPSG:3857'
layer = QgsRasterLayer('url=%s' % wms_url, 'Test WMS', 'wms')
if not layer.isValid():
    QgsMessageLog.logMessage('ops', level=QgsMessageLog.CRITICAL)
else:
    QgsMapLayerRegistry.instance().addMapLayer(layer)

If the URL contains only one sublayer - it's work.
Change url to:

http://maps.rosreestr.ru/arcgis/services/Cadastre/CadastreWMS/MapServer/WMSServer?format=image/png&layers=1,2&styles=&crs=EPSG:3857

and oops...

History

#1 Updated by Sandro Santilli about 5 years ago

  • Tag set to wms

#2 Updated by Nyall Dawson almost 5 years ago

The issue is that your layer URI isn't complete. Try using:

wms_uri = 'crs=EPSG:3857&format=image/jpeg&layers=1&layers=2&styles=default&styles=default&url=http://maps.rosreestr.ru/arcgis/services/Cadastre/CadastreWMS/MapServer/WMSServer?format%3Dimage/png%26layers%3D1,2%26styles%3D%26crs%3DEPSG:3857'
layer = QgsRasterLayer(wms_uri, 'Test WMS', 'wms')

#3 Updated by Nyall Dawson almost 5 years ago

  • Status changed from Open to Feedback

#4 Updated by Giovanni Manghi over 4 years ago

  • Priority changed from Normal to High

#5 Updated by Jürgen Fischer over 4 years ago

  • Resolution set to worksforme
  • Status changed from Feedback to Closed

closing for the lack of feedback

Also available in: Atom PDF