From 6e9376fc933c8721cdf90e68ccf4457090af968d Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 09 十一月 2022 10:35:21 +0800
Subject: [PATCH] 1

---
 ExportMap/cs/ExportUtil.cs     |   21 ++++++++++
 ExportMap/Sources/Test.qpt     |    2 
 ExportMap/ExportMap.csproj     |    4 +
 ExportMap/Models/ExportArgs.cs |   38 ++++++++++++++++++
 4 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/ExportMap/ExportMap.csproj b/ExportMap/ExportMap.csproj
index 1f75eb9..4ce7fcd 100644
--- a/ExportMap/ExportMap.csproj
+++ b/ExportMap/ExportMap.csproj
@@ -141,7 +141,9 @@
     <Folder Include="App_Data\" />
   </ItemGroup>
   <ItemGroup>
-    <Content Include="Sources\Test.qpt" />
+    <Content Include="Sources\Test.qpt">
+      <SubType>Designer</SubType>
+    </Content>
     <Content Include="Sources\Test.qgz" />
   </ItemGroup>
   <ItemGroup>
diff --git a/ExportMap/Models/ExportArgs.cs b/ExportMap/Models/ExportArgs.cs
index 09532eb..fc67e59 100644
--- a/ExportMap/Models/ExportArgs.cs
+++ b/ExportMap/Models/ExportArgs.cs
@@ -18,6 +18,11 @@
         public String title { set; get; }
 
         /// <summary>
+        /// 绾稿紶澶у皬
+        /// </summary>
+        public string pageSize { set; get; }
+
+        /// <summary>
         /// 鐪佷唤
         /// </summary>
         public String province { set; get; }
@@ -28,7 +33,7 @@
         public String scale { set; get; }
 
         /// <summary>
-        /// 鍒嗚鲸鐜�
+        /// 鍒嗚鲸鐜囷紙鍙充笅瑙掓枃鏈級
         /// </summary>
         public String resolution { set; get; }
 
@@ -72,6 +77,11 @@
         /// </summary>
         public double xmax { set; get; }
 
+        /// <summary>
+        /// 鍑哄浘鍒嗚鲸鐜�
+        /// </summary>
+        public int dpi { set; get; }
+
         public void SetDefault()
         {
             if (string.IsNullOrWhiteSpace(title)) title = "绠¢亾鍩虹澶ф暟鎹钩鍙�";
@@ -80,7 +90,33 @@
             if (string.IsNullOrWhiteSpace(resolution)) resolution = string.Empty;
             if (string.IsNullOrWhiteSpace(date)) date = DateTime.Now.ToString("yyyy.MM.dd");
 
+            this.dpi = GetDpi(this.pageSize);
             imgPath = "";
         }
+
+        public int GetDpi(string page)
+        {
+            if (string.IsNullOrWhiteSpace(page)) return 300;
+
+            switch (page.ToUpper())
+            {
+                case "A0":
+                    return 1200;
+                case "A1":
+                    return 850;
+                case "A2":
+                    return 600;
+                case "A3":
+                    return 424;
+                case "A4":
+                    return 300;
+                case "A5":
+                    return 212;
+                case "A6":
+                    return 150;
+                default:
+                    return 300;
+            }
+        }
     }
 }
diff --git a/ExportMap/Sources/Test.qpt b/ExportMap/Sources/Test.qpt
index 6a4e359..28598c1 100644
--- a/ExportMap/Sources/Test.qpt
+++ b/ExportMap/Sources/Test.qpt
@@ -1,4 +1,4 @@
-<Layout units="mm" name="Template" printResolution="300" worldFileMap="{4e649c5d-cabe-431f-a385-d69809d87ebf}">
+<Layout units="mm" name="Template" printResolution="{dpi}" worldFileMap="{4e649c5d-cabe-431f-a385-d69809d87ebf}">
  <Snapper snapToItems="1" tolerance="5" snapToGrid="0" snapToGuides="1"/>
  <Grid resolution="10" offsetY="0" offsetUnits="mm" resUnits="mm" offsetX="0"/>
  <PageCollection>
diff --git a/ExportMap/cs/ExportUtil.cs b/ExportMap/cs/ExportUtil.cs
index 4a7c0f5..416575a 100644
--- a/ExportMap/cs/ExportUtil.cs
+++ b/ExportMap/cs/ExportUtil.cs
@@ -24,6 +24,27 @@
             }
         }
 
+        private static string sourcesPath;
+
+        public string GetSourcesPath
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(sourcesPath))
+                {
+                    sourcesPath = Path.Combine(BaseDir, "Sources");
+                }
+
+                return sourcesPath;
+            }
+        }
+
+        /// <summary>
+        /// 鎵цPython
+        /// </summary>
+        /// <param name="py">Python鏂囦欢</param>
+        /// <param name="qgz">QGIS宸ョ▼</param>
+        /// <param name="qpt">QGIS妯℃澘</param>
         public static void ExecPython(string py, string qgz, string qpt)
         {
             try

--
Gitblit v1.9.3