管道基础大数据平台系统开发-【CS】-ExportMap
1
13693261870
2022-11-09 a2a1b640b35ff095807069e63571faa3fdd4f659
ExportMap/cs/ExportUtil.cs
@@ -1,4 +1,5 @@
using System;
using LFServer.Models;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
@@ -140,11 +141,55 @@
            }
        }
        public static void Generate()
        /// <summary>
        /// 生成
        /// </summary>
        /// <param name="args">出图参数</param>
        public static void Generate(ExportArgs args)
        {
            string date = DateStr;
            string sub = GetExportSubFolder();
            string qgz = "Test.qgz";
            args.imgPath = sub + "/" + date + ".png";
            args.qpt = date + ".qpt";
            CreateTemplate(args);
            ExecPython(PyFile, qgz, args.qpt);
        }
        /// <summary>
        /// 创建模板
        /// </summary>
        /// <param name="args">出图参数</param>
        public static void CreateTemplate(ExportArgs args)
        {
            string imgPath = Path.Combine(ExportFolder, args.imgPath);
            string templateFile = Path.Combine(SourcesPath, "Test.qpt");
            string qptFile = Path.Combine(SourcesPath, args.qpt);
            if (File.Exists(qptFile))
            {
                File.Delete(qptFile);
            }
            string xml = File.ReadAllText(templateFile);
            xml = xml
                .Replace("{dpi}", args.dpi.ToString())
                .Replace("{title}", args.title)
                .Replace("{rotation}", args.rotation.ToString())
                .Replace("{xmin}", args.xmin.ToString())
                .Replace("{ymin}", args.ymin.ToString())
                .Replace("{ymax}", args.ymax.ToString())
                .Replace("{xmax}", args.xmax.ToString())
                .Replace("{province}", args.province)
                .Replace("{scale}", args.scale)
                .Replace("{resolution}", args.resolution)
                .Replace("{date}", args.date)
                .Replace("{layers}", args.layers)
                .Replace("{imgPath}", imgPath);
            File.WriteAllText(qptFile, xml);
        }
    }
}