From 1d9aa9ea9f2a8b36573a5669664e32e25787cd23 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 07 八月 2023 17:32:50 +0800 Subject: [PATCH] 1 --- ExportMap/Sources/xyz2.py | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ExportMap/Sources/xyz2.py b/ExportMap/Sources/xyz2.py index 6bae100..fbbc24f 100644 --- a/ExportMap/Sources/xyz2.py +++ b/ExportMap/Sources/xyz2.py @@ -33,14 +33,13 @@ parser.add_argument("-min", type=int, default=12, required=False) parser.add_argument("-max", type=int, default=15, required=False) parser.add_argument("-noData", type=int, default=0, required=False) - parser.add_argument("-authid", type=int, default=4490, required=False) return parser.parse_args() # 璇诲彇鏂囨湰鏂囦欢 -def readTxt(filePath): - f = open(filePath, encoding="utf-8") +def read_txt(path): + f = open(path, encoding="utf-8") lines = f.readlines() f.close() @@ -51,11 +50,11 @@ # 鍔犺浇鍥惧眰 -def loadLayers(prj, args): +def load_layers(prj, args): for layer in prj.mapLayers().values(): prj.removeMapLayer(layer) - lines = readTxt(args.file) + lines = read_txt(args.file) for i in range(0, len(lines)): if len(lines[i]) == 0: continue @@ -85,7 +84,7 @@ # 鑾峰彇XYZ鍙傛暟 -def getXYZOps(args): +def get_xyz_ops(args): ops = { 'BACKGROUND_COLOR': QColor(0, 0, 0, 0), 'DPI': 96, @@ -108,7 +107,7 @@ # 鍒涘缓XYZ鐡︾墖 -def createXYZ(prj, args): +def create_xyz(prj, args): import processing for layer in prj.mapLayers().values(): @@ -116,7 +115,7 @@ prj.setCrs(layer.crs()) epsg = '' if layer.crs() is None else ' [' + layer.crs().authid() + ']' args.ext = str(e.xMinimum()) + "," + str(e.xMaximum()) + "," + str(e.yMinimum()) + "," + str(e.yMaximum()) + epsg - ops = getXYZOps(args) + ops = get_xyz_ops(args) processing.run("qgis:tilesxyzdirectory", ops) @@ -133,11 +132,11 @@ # prj.read(args.qgz) print("FileName: " + prj.fileName()) - loadLayers(prj, args) + load_layers(prj, args) # prj.write(args.file.replace(".txt", ".qgz")) # args.ext = getExtent(prj, args) - createXYZ(prj, args) + create_xyz(prj, args) qgs.exitQgis() -- Gitblit v1.9.3