From 3aa2a3beb2003c265a7912a9a1a8f0ce3732bb4b Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 09 十月 2023 09:55:54 +0800 Subject: [PATCH] 添加动态wms图层 --- ExportMap/Sources/MoonExp.py | 14 ++++++++++---- ExportMap/Sources/Moon.qpt | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ExportMap/Sources/Moon.qpt b/ExportMap/Sources/Moon.qpt index 35fcc33..d9c4790 100644 --- a/ExportMap/Sources/Moon.qpt +++ b/ExportMap/Sources/Moon.qpt @@ -469,6 +469,7 @@ <property value="true" key="singleFile"/> <property key="layers" value="geo_albedo_feature_point,geo_alkaline_rock_suite,geo_cliff_annotation,geo_construction_unit_boundary,copernican_craters_180,geo_age_not_determined,moon"/> <property key="imgPath" value="E:\terrait\TianJin\ExportMap\MoonExp\Sources\Test.png"/> + <property key="wmsUrl" value="http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d"/> </customproperties> <Atlas filenamePattern="'output_'||@atlas_featurenumber" filterFeatures="0" enabled="0" coverageLayer="" sortFeatures="0" hideCoverage="0" pageNameExpression=""/> </Layout> diff --git a/ExportMap/Sources/MoonExp.py b/ExportMap/Sources/MoonExp.py index 469be76..f898115 100644 --- a/ExportMap/Sources/MoonExp.py +++ b/ExportMap/Sources/MoonExp.py @@ -57,11 +57,17 @@ # 娣诲姞搴曞浘锛歭ayer.isValid()锛宭ayer.metadataUri()锛宭ayer.providerType() -def add_map_layer(prj, args): - url = "crs=ESRI:104903&dpiMode=7&format=image/png&layers=Default&styles=default&tileMatrixSet=GoogleCRS84Quad01&url=http://219.153.49.10:7511/sj_raster/v6/wmts/service/system/10000201/1?ak=mf72ff9295c740ec0f37e61433e8a3ad8d" +def add_map_layer(prj, layout, args): + wms_url = layout.customProperty("wmsUrl") + if wms_url is None: + print("WmsUrl is None.") + return + + url = "crs=ESRI:104903&dpiMode=7&format=image/png&layers=Default&styles=default&tileMatrixSet=GoogleCRS84Quad01&url=" + wms_url + print("WMS鍦板潃锛�" + url) + layer = QgsRasterLayer(url, "WmsLayer", "wms") prj.addMapLayer(layer) - print(url) # 鍒濆鍖� @@ -114,7 +120,7 @@ # set_layers_valid(prj, showLayers) set_item_visibility(root, showLayers) -add_map_layer(prj, args) +add_map_layer(prj, layout, args) # sm = layout.itemById(r'璇存槑') '''table = layout.multiFrames()[0] -- Gitblit v1.9.3