使用基本身份验证在QGIS中调用WMS GetCapabilities请求时是否有问题?

2024-04-28 06:57:50 发布

您现在位置:Python中文网/ 问答频道 /正文

这是代码。我正试图这么做,但这与getURL不一样

uri = QgsDataSourceUri()
uri.setParam('url' , 'http://localhost:8443/geoserver/test/ows?service=WMS&layers=test:2-0&crs=EPSG:3857&styles=')
uri.setUsername('testing')
uri.setPassword('sd6idfs')
rlayer = QgsRasterLayer(uri.uri(False), '2-0', 'WMS')
QgsProject.instance().addMapLayer(rlayer)

警告:功能下载失败:协议“”未知

请告诉我哪里错了。或者如何使用用户名或密码在qgis中传递getcapabilities url。 不像这种形式

http://username:password@localhost:8080/geoserver/test/wms?

因为当我尝试这样做的时候,它对我来说是有效的,但是只处理一个请求,比如GetMap请求,而不是列表。并且用户名和密码不会隐藏在图层工具提示上


Tags: 代码testlocalhosthttpurl密码geoserveruri