From e3d5fefaf7e3ca1efa749f972162f15ee320774c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 09 三月 2023 18:59:31 +0800 Subject: [PATCH] 1 --- ExportMap/Sources/xyz.py | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ExportMap/Sources/xyz.py b/ExportMap/Sources/xyz.py index 5e8c210..fee5161 100644 --- a/ExportMap/Sources/xyz.py +++ b/ExportMap/Sources/xyz.py @@ -13,7 +13,6 @@ from qgis.PyQt.QtCore import * from qgis.PyQt.QtWidgets import * from processing.core.Processing import Processing -import processing # 鑾峰彇瀹屾暣璺緞 @@ -26,7 +25,7 @@ print("argv = ", sys.argv[1:]) parser = argparse.ArgumentParser(description='ArgUtils') parser.add_argument("-src", type=str, default=get_full_path(), required=False) - parser.add_argument("-qgz", type=str, default="xyz.qgz", required=False) + parser.add_argument("-qgz", type=str, default="xyz2.qgz", required=False) parser.add_argument("-file", type=str, default=r"D:\xyz\tiles.txt", required=False) parser.add_argument("-out", type=str, default=r"D:\xyz\tiles\zy", required=False) @@ -47,6 +46,9 @@ # 鍔犺浇鍥惧眰 def loadLayers(prj, args): + for layer in prj.mapLayers().values(): + prj.removeMapLayer(layer) + lines = readTxt(args.file) for i in range(0, len(lines)): line = lines[i] @@ -57,12 +59,17 @@ layer = QgsRasterLayer(line, "layer_" + str(i)) if not layer.isValid(): print("layer_" + str(i) + ": failed to load!") + continue + prj.addMapLayer(layer) + + for layer in prj.mapLayers().values(): + print(layer.name()) # 鍒濆鍖� def init(): # QgsApplication.setPrefixPath("C:\Program Files\QGIS 3.16", True) - qgs = QgsApplication([], True) + qgs = QgsApplication([], False) Processing.initialize() qgs.initQgis() @@ -73,6 +80,7 @@ loadLayers(project, args) + import processing ops = { 'BACKGROUND_COLOR': QColor(0, 0, 0, 0), 'DPI': 96, @@ -85,8 +93,8 @@ 'TILE_HEIGHT': 256, 'TILE_WIDTH': 256, 'TMS_CONVENTION': True, - 'ZOOM_MAX': 8, - 'ZOOM_MIN': 8 + 'ZOOM_MAX': 12, + 'ZOOM_MIN': 12 } processing.run("qgis:tilesxyzdirectory", ops) -- Gitblit v1.9.3