qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.39k stars 2.98k forks source link

Add WMS layer throw python console -> QGIS Crash #20099

Closed qgib closed 5 years ago

qgib commented 9 years ago

Author Name: Evgeniy Nikulin (Evgeniy Nikulin) Original Redmine Issue: 11885 Affected QGIS version: 2.6.0 Redmine category:web_services_clients/wms


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":https://gist.github.com/yellow-sky/e2b4ff752c49aef887e0 :

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)
</code>

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...

qgib commented 9 years ago

Author Name: Sandro Santilli (@strk)


qgib commented 9 years ago

Author Name: Nyall Dawson (@nyalldawson)


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')
qgib commented 9 years ago

Author Name: Nyall Dawson (@nyalldawson)


qgib commented 9 years ago

Author Name: Giovanni Manghi (@gioman)


qgib commented 8 years ago

Author Name: Jürgen Fischer (@jef-n)


closing for the lack of feedback