管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2023-05-22 bc425adbda376e5ad30f269c0a9ebae2d12de44f
1
已修改2个文件
46 ■■■■■ 文件已修改
ExportMap/Sources/merge.py 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/cs/TerraUtils.cs 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ExportMap/Sources/merge.py
@@ -98,6 +98,22 @@
    processing.run("gdal:merge", ops)
# 获取中心点坐标
def get_coord(prj, args):
    layer = QgsRasterLayer(args.out, "layer_tif")
    rect = layer.extent()
    x = (rect.xMinimum() + rect.xMaximum()) / 2
    y = (rect.yMinimum() + rect.yMaximum()) / 2
    sid = layer.crs().authid()
    coord = str(x) + ", " + str(y) + ", " + str(sid)
    print(coord)
    f = open(args.out.replace(".tif", "_cs.txt"), 'w')
    f.write(coord)
    f.close()
# 初始化
def init():
    # QgsApplication.setPrefixPath("C:\Program Files\QGIS 3.16", True)
@@ -113,6 +129,7 @@
    load_layers(prj, args)
    merge(prj, args)
    get_coord(prj, args)
    qgs.exitQgis()
ExportMap/cs/TerraUtils.cs
@@ -258,6 +258,7 @@
            meta.name = args.name;
            SysPublish sys = Tools.NewPublish(meta, args, GetReleaseUrl(args.dircode), "3d\\terrain\\" + args.dircode);
            sys.geom = GetPointZ(args);
            int pubid = PubDBHelper.InsertPublish(sys);
            if (pubid > 0)
@@ -277,5 +278,33 @@
            return pubid;
        }
        /// <summary>
        /// 获取中心点
        /// </summary>
        private static string GetPointZ(XYZArgs args)
        {
            string dirPath = GetTerrainPath(args.dircode);
            string txtFile = Path.Combine(dirPath, args.dircode + "_cs.txt");
            if (!File.Exists(txtFile)) return null;
            string[] strs = File.ReadAllLines(txtFile, Encoding.UTF8);
            File.Delete(txtFile);
            if (null == strs || strs.Length == 0) return null;
            string[] str = strs[0].Split(new string[] { ", " }, StringSplitOptions.None);
            int i = 18;
            for (; i > -1; i--)
            {
                string path = Path.Combine(dirPath, i.ToString());
                if (Directory.Exists(path))
                {
                    break;
                }
            }
            return string.Format("ST_GeomFromText('POINT Z ({0} {1} {2})')", str[1], str[0], i);
        }
    }
}