From 0f522b742699f0d81f23adc4cf517205cdf3d45c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期四, 18 七月 2024 16:30:27 +0800 Subject: [PATCH] 开始执行运行方法 --- SimuTools/Domain/Layer.cs | 10 +- SimuTools/FrmMain.cs | 15 ++++ SimuTools/dlls/Newtonsoft.Json.dll | 0 SimuTools/Domain/Duration.cs | 4 SimuTools/FrmMain.Designer.cs | 57 +++++++++++++----- SimuTools/SimuTools.csproj | 5 + SimuTools/Domain/Water.cs | 7 + SimuTools/Domain/Terrain.cs | 2 SimuTools/Domain/Extension.cs | 12 ++-- SimuTools/Tools/Handle.cs | 27 ++++++++- 10 files changed, 103 insertions(+), 36 deletions(-) diff --git a/SimuTools/Domain/Duration.cs b/SimuTools/Domain/Duration.cs index 9bb0b6e..d802ddf 100644 --- a/SimuTools/Domain/Duration.cs +++ b/SimuTools/Domain/Duration.cs @@ -8,9 +8,9 @@ { public class Duration { - private long start { set; get; } + public long start { set; get; } - private long end { set; get; } + public long end { set; get; } public Duration() { } diff --git a/SimuTools/Domain/Extension.cs b/SimuTools/Domain/Extension.cs index ad2daed..a1d8f80 100644 --- a/SimuTools/Domain/Extension.cs +++ b/SimuTools/Domain/Extension.cs @@ -8,17 +8,17 @@ { public class Extension { - private double minx { set; get; } + public double minx { set; get; } - private double miny { set; get; } + public double miny { set; get; } - private double maxx { set; get; } + public double maxx { set; get; } - private double maxy { set; get; } + public double maxy { set; get; } - private double minHeight { set; get; } + public double minHeight { set; get; } - private double maxHeight { set; get; } + public double maxHeight { set; get; } public Extension() { } diff --git a/SimuTools/Domain/Layer.cs b/SimuTools/Domain/Layer.cs index 15d8c2f..8a66cf6 100644 --- a/SimuTools/Domain/Layer.cs +++ b/SimuTools/Domain/Layer.cs @@ -10,15 +10,15 @@ { public class Layer { - private String version { set; get; } + public String version { set; get; } - private Duration duration { set; get; } + public Duration duration { set; get; } - private Extension extension { set; get; } + public Extension extension { set; get; } - private Terrain terrain { set; get; } + public Terrain terrain { set; get; } - private Water waters { set; get; } + public Water waters { set; get; } public Layer() { diff --git a/SimuTools/Domain/Terrain.cs b/SimuTools/Domain/Terrain.cs index 92fdd53..e212558 100644 --- a/SimuTools/Domain/Terrain.cs +++ b/SimuTools/Domain/Terrain.cs @@ -9,7 +9,7 @@ { public class Terrain { - private List<int[]> size { set; get; } + public List<int[]> size { set; get; } public Terrain() { diff --git a/SimuTools/Domain/Water.cs b/SimuTools/Domain/Water.cs index 577bac2..29ac95e 100644 --- a/SimuTools/Domain/Water.cs +++ b/SimuTools/Domain/Water.cs @@ -8,9 +8,12 @@ { public class Water { - private List<long> data { set; get; } + public List<long> data { set; get; } - public Water() { } + public Water() + { + data = new List<long>(); + } public Water(List<long> data) { diff --git a/SimuTools/FrmMain.Designer.cs b/SimuTools/FrmMain.Designer.cs index c342cf3..ae523de 100644 --- a/SimuTools/FrmMain.Designer.cs +++ b/SimuTools/FrmMain.Designer.cs @@ -41,12 +41,14 @@ this.txtOutPath = new System.Windows.Forms.TextBox(); this.lblOut = new System.Windows.Forms.Label(); this.btnOutPath = new System.Windows.Forms.Button(); + this.txtServiceName = new System.Windows.Forms.TextBox(); + this.lblService = new System.Windows.Forms.Label(); this.SuspendLayout(); // // btnTerrainPath // this.btnTerrainPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnTerrainPath.Location = new System.Drawing.Point(607, 27); + this.btnTerrainPath.Location = new System.Drawing.Point(616, 45); this.btnTerrainPath.Name = "btnTerrainPath"; this.btnTerrainPath.Size = new System.Drawing.Size(130, 26); this.btnTerrainPath.TabIndex = 47; @@ -58,7 +60,7 @@ // this.lblTerrain.AutoSize = true; this.lblTerrain.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.lblTerrain.Location = new System.Drawing.Point(24, 32); + this.lblTerrain.Location = new System.Drawing.Point(33, 50); this.lblTerrain.Name = "lblTerrain"; this.lblTerrain.Size = new System.Drawing.Size(79, 16); this.lblTerrain.TabIndex = 48; @@ -67,7 +69,7 @@ // txtTerrainPath // this.txtTerrainPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.txtTerrainPath.Location = new System.Drawing.Point(109, 27); + this.txtTerrainPath.Location = new System.Drawing.Point(118, 45); this.txtTerrainPath.MaxLength = 2000; this.txtTerrainPath.Name = "txtTerrainPath"; this.txtTerrainPath.Size = new System.Drawing.Size(482, 26); @@ -77,7 +79,7 @@ // txtWaterPath // this.txtWaterPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.txtWaterPath.Location = new System.Drawing.Point(109, 76); + this.txtWaterPath.Location = new System.Drawing.Point(118, 94); this.txtWaterPath.MaxLength = 2000; this.txtWaterPath.Name = "txtWaterPath"; this.txtWaterPath.Size = new System.Drawing.Size(482, 26); @@ -88,7 +90,7 @@ // this.lblWater.AutoSize = true; this.lblWater.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.lblWater.Location = new System.Drawing.Point(24, 81); + this.lblWater.Location = new System.Drawing.Point(33, 99); this.lblWater.Name = "lblWater"; this.lblWater.Size = new System.Drawing.Size(79, 16); this.lblWater.TabIndex = 51; @@ -97,7 +99,7 @@ // btnWaterPath // this.btnWaterPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnWaterPath.Location = new System.Drawing.Point(607, 76); + this.btnWaterPath.Location = new System.Drawing.Point(616, 94); this.btnWaterPath.Name = "btnWaterPath"; this.btnWaterPath.Size = new System.Drawing.Size(130, 26); this.btnWaterPath.TabIndex = 50; @@ -108,7 +110,7 @@ // txtFlowPath // this.txtFlowPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.txtFlowPath.Location = new System.Drawing.Point(109, 126); + this.txtFlowPath.Location = new System.Drawing.Point(118, 144); this.txtFlowPath.MaxLength = 2000; this.txtFlowPath.Name = "txtFlowPath"; this.txtFlowPath.Size = new System.Drawing.Size(482, 26); @@ -119,7 +121,7 @@ // this.lblFlow.AutoSize = true; this.lblFlow.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.lblFlow.Location = new System.Drawing.Point(24, 131); + this.lblFlow.Location = new System.Drawing.Point(33, 149); this.lblFlow.Name = "lblFlow"; this.lblFlow.Size = new System.Drawing.Size(79, 16); this.lblFlow.TabIndex = 54; @@ -128,7 +130,7 @@ // btnFlowPath // this.btnFlowPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnFlowPath.Location = new System.Drawing.Point(607, 126); + this.btnFlowPath.Location = new System.Drawing.Point(616, 144); this.btnFlowPath.Name = "btnFlowPath"; this.btnFlowPath.Size = new System.Drawing.Size(130, 26); this.btnFlowPath.TabIndex = 53; @@ -140,9 +142,9 @@ // this.btnRun.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnRun.ForeColor = System.Drawing.SystemColors.Highlight; - this.btnRun.Location = new System.Drawing.Point(27, 229); + this.btnRun.Location = new System.Drawing.Point(616, 248); this.btnRun.Name = "btnRun"; - this.btnRun.Size = new System.Drawing.Size(710, 26); + this.btnRun.Size = new System.Drawing.Size(130, 26); this.btnRun.TabIndex = 57; this.btnRun.Text = "杩� 琛�"; this.btnRun.UseVisualStyleBackColor = true; @@ -151,7 +153,7 @@ // txtOutPath // this.txtOutPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.txtOutPath.Location = new System.Drawing.Point(109, 178); + this.txtOutPath.Location = new System.Drawing.Point(118, 196); this.txtOutPath.MaxLength = 2000; this.txtOutPath.Name = "txtOutPath"; this.txtOutPath.Size = new System.Drawing.Size(482, 26); @@ -162,7 +164,7 @@ // this.lblOut.AutoSize = true; this.lblOut.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.lblOut.Location = new System.Drawing.Point(24, 183); + this.lblOut.Location = new System.Drawing.Point(33, 201); this.lblOut.Name = "lblOut"; this.lblOut.Size = new System.Drawing.Size(79, 16); this.lblOut.TabIndex = 59; @@ -171,19 +173,40 @@ // btnOutPath // this.btnOutPath.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnOutPath.Location = new System.Drawing.Point(607, 178); + this.btnOutPath.Location = new System.Drawing.Point(616, 196); this.btnOutPath.Name = "btnOutPath"; this.btnOutPath.Size = new System.Drawing.Size(130, 26); this.btnOutPath.TabIndex = 58; this.btnOutPath.Text = "閫夋嫨杈撳嚭鐩綍"; this.btnOutPath.UseVisualStyleBackColor = true; - this.btnOutPath.Click += new System.EventHandler(this.btnOutPath_Click); + // + // txtServiceName + // + this.txtServiceName.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtServiceName.Location = new System.Drawing.Point(118, 248); + this.txtServiceName.MaxLength = 2000; + this.txtServiceName.Name = "txtServiceName"; + this.txtServiceName.Size = new System.Drawing.Size(482, 26); + this.txtServiceName.TabIndex = 62; + this.txtServiceName.Text = "202407"; + // + // lblService + // + this.lblService.AutoSize = true; + this.lblService.Font = new System.Drawing.Font("瀹嬩綋", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lblService.Location = new System.Drawing.Point(33, 253); + this.lblService.Name = "lblService"; + this.lblService.Size = new System.Drawing.Size(79, 16); + this.lblService.TabIndex = 61; + this.lblService.Text = "鏈嶅姟鍚嶇О:"; // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(751, 280); + this.ClientSize = new System.Drawing.Size(804, 324); + this.Controls.Add(this.txtServiceName); + this.Controls.Add(this.lblService); this.Controls.Add(this.txtOutPath); this.Controls.Add(this.lblOut); this.Controls.Add(this.btnOutPath); @@ -222,6 +245,8 @@ private System.Windows.Forms.TextBox txtOutPath; private System.Windows.Forms.Label lblOut; private System.Windows.Forms.Button btnOutPath; + private System.Windows.Forms.TextBox txtServiceName; + private System.Windows.Forms.Label lblService; } } diff --git a/SimuTools/FrmMain.cs b/SimuTools/FrmMain.cs index c888011..41faf90 100644 --- a/SimuTools/FrmMain.cs +++ b/SimuTools/FrmMain.cs @@ -87,11 +87,17 @@ private void btnRun_Click(object sender, EventArgs e) { + string serviceName = this.txtServiceName.Text.Trim(); string terrainFile = this.txtTerrainPath.Text.Trim(); string waterPath = this.txtWaterPath.Text.Trim(); string flowPath = this.txtFlowPath.Text.Trim(); string outPath = this.txtOutPath.Text.Trim(); + if (string.IsNullOrEmpty(serviceName)) + { + ShowErr("鏈嶅姟鍚嶇О锛岃姹傚繀濉紒"); + return; + } if (!File.Exists(terrainFile)) { ShowErr("鍦板舰鏂囦欢锛岃姹傚繀椤诲瓨鍦紒"); @@ -109,10 +115,17 @@ flag = true; LogOut.Info(">> 寮�濮嬭繍琛� >>"); + outPath = Path.Combine(outPath, serviceName); + if (!Directory.Exists(outPath)) + { + Directory.CreateDirectory(outPath); + } + Tools.Handle.Run(terrainFile, waterPath, flowPath, outPath); - LogOut.Info("<< 杩愯缁撴潫 <<"); flag = false; + LogOut.Info("<< 杩愯缁撴潫 <<"); + MessageBox.Show("杩愯缁撴潫锛�", "鎻愮ず", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { diff --git a/SimuTools/SimuTools.csproj b/SimuTools/SimuTools.csproj index 05eea49..b5464f0 100644 --- a/SimuTools/SimuTools.csproj +++ b/SimuTools/SimuTools.csproj @@ -48,6 +48,10 @@ <SpecificVersion>False</SpecificVersion> <HintPath>dlls\log4net4.dll</HintPath> </Reference> + <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>dlls\Newtonsoft.Json.dll</HintPath> + </Reference> <Reference Include="ogr_csharp, Version=3.5.2.0, Culture=neutral, PublicKeyToken=db5a52b08dc5b321, processorArchitecture=MSIL" /> <Reference Include="osr_csharp, Version=3.5.2.0, Culture=neutral, PublicKeyToken=db5a52b08dc5b321, processorArchitecture=MSIL" /> <Reference Include="System" /> @@ -562,6 +566,7 @@ <Content Include="dlls\gdal_csharp.dll" /> <Content Include="dlls\gdal_wrap.dll" /> <Content Include="dlls\log4net4.dll" /> + <Content Include="dlls\Newtonsoft.Json.dll" /> <Content Include="dlls\ogr_csharp.dll" /> <Content Include="dlls\ogr_wrap.dll" /> <Content Include="dlls\osr_csharp.dll" /> diff --git a/SimuTools/Tools/Handle.cs b/SimuTools/Tools/Handle.cs index c733210..1ee6f00 100644 --- a/SimuTools/Tools/Handle.cs +++ b/SimuTools/Tools/Handle.cs @@ -1,9 +1,11 @@ -锘縰sing System; +锘縰sing Newtonsoft.Json; +using SimuTools.Domain; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Windows.Forms; namespace SimuTools.Tools { @@ -13,7 +15,26 @@ public static void Run(string terrainFile, string waterPath, string flowPath, string outPath) { - // + Layer layer = new Layer(); + layer.terrain = new Terrain(); + layer.duration = new Duration(1719812810225L, 1719812810225L); + layer.extension = new Extension(); + layer.waters = new Water(); + + CreateLayerJson(outPath, layer); + } + + private static void CreateLayerJson(string outPath, Layer layer) + { + if (null == layer) return; + + String json = JsonConvert.SerializeObject(layer); + + string filePath = Path.Combine(outPath, "layer.json"); + using (StreamWriter sw = new StreamWriter(filePath)) + { + sw.Write(json); + } } } } diff --git a/SimuTools/dlls/Newtonsoft.Json.dll b/SimuTools/dlls/Newtonsoft.Json.dll new file mode 100644 index 0000000..0a91cd7 --- /dev/null +++ b/SimuTools/dlls/Newtonsoft.Json.dll Binary files differ -- Gitblit v1.9.3