管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-07-26 a10e925cdda6f92a7bbf86188e317f5c5ee839b5
水面数据在计算时添加建筑物避让功能
已添加1个文件
已修改4个文件
278 ■■■■ 文件已修改
SimuTools/Domain/Args.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SimuTools/FrmMain.Designer.cs 66 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SimuTools/FrmMain.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SimuTools/SimuTools.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SimuTools/Tools/Handle.cs 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SimuTools/Domain/Args.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
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.Domain
{
    public class Args
    {
        public string serviceName { set; get; }
        public string terrainFile { set; get; }
        public string buildingFile { set; get; }
        public string waterPath { set; get; }
        public string flowPath { set; get; }
        public string outPath { set; get; }
        public string temp { set; get; }
        public Dictionary<string, float[]> buildings { set; get; }
        public Args()
        {
            buildings = new Dictionary<string, float[]>();
        }
        public Args(string serviceName, string terrainFile, string buildingFile, string waterPath, string flowPath, string outPath) : this()
        {
            this.serviceName = serviceName;
            this.terrainFile = terrainFile;
            this.buildingFile = buildingFile;
            this.waterPath = waterPath;
            this.flowPath = flowPath;
            this.outPath = outPath;
            this.outPath = Path.Combine(this.outPath, serviceName);
            if (!Directory.Exists(this.outPath)) Directory.CreateDirectory(this.outPath);
            this.temp = Path.Combine(this.outPath, "temp");
            if (!Directory.Exists(this.temp)) Directory.CreateDirectory(this.temp);
        }
    }
}
SimuTools/FrmMain.Designer.cs
@@ -43,6 +43,9 @@
            this.btnOutPath = new System.Windows.Forms.Button();
            this.txtServiceName = new System.Windows.Forms.TextBox();
            this.lblService = new System.Windows.Forms.Label();
            this.txtBuildingPath = new System.Windows.Forms.TextBox();
            this.lblBuilding = new System.Windows.Forms.Label();
            this.btnBuildingPath = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // btnTerrainPath
@@ -79,7 +82,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(118, 94);
            this.txtWaterPath.Location = new System.Drawing.Point(118, 143);
            this.txtWaterPath.MaxLength = 2000;
            this.txtWaterPath.Name = "txtWaterPath";
            this.txtWaterPath.Size = new System.Drawing.Size(482, 26);
@@ -90,7 +93,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(33, 99);
            this.lblWater.Location = new System.Drawing.Point(33, 148);
            this.lblWater.Name = "lblWater";
            this.lblWater.Size = new System.Drawing.Size(79, 16);
            this.lblWater.TabIndex = 51;
@@ -99,7 +102,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(616, 94);
            this.btnWaterPath.Location = new System.Drawing.Point(616, 143);
            this.btnWaterPath.Name = "btnWaterPath";
            this.btnWaterPath.Size = new System.Drawing.Size(130, 26);
            this.btnWaterPath.TabIndex = 50;
@@ -110,7 +113,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(118, 144);
            this.txtFlowPath.Location = new System.Drawing.Point(118, 193);
            this.txtFlowPath.MaxLength = 2000;
            this.txtFlowPath.Name = "txtFlowPath";
            this.txtFlowPath.Size = new System.Drawing.Size(482, 26);
@@ -121,7 +124,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(33, 149);
            this.lblFlow.Location = new System.Drawing.Point(33, 198);
            this.lblFlow.Name = "lblFlow";
            this.lblFlow.Size = new System.Drawing.Size(79, 16);
            this.lblFlow.TabIndex = 54;
@@ -130,7 +133,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(616, 144);
            this.btnFlowPath.Location = new System.Drawing.Point(616, 193);
            this.btnFlowPath.Name = "btnFlowPath";
            this.btnFlowPath.Size = new System.Drawing.Size(130, 26);
            this.btnFlowPath.TabIndex = 53;
@@ -142,7 +145,7 @@
            // 
            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(616, 248);
            this.btnRun.Location = new System.Drawing.Point(616, 297);
            this.btnRun.Name = "btnRun";
            this.btnRun.Size = new System.Drawing.Size(130, 26);
            this.btnRun.TabIndex = 57;
@@ -153,7 +156,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(118, 196);
            this.txtOutPath.Location = new System.Drawing.Point(118, 245);
            this.txtOutPath.MaxLength = 2000;
            this.txtOutPath.Name = "txtOutPath";
            this.txtOutPath.Size = new System.Drawing.Size(482, 26);
@@ -164,7 +167,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(33, 201);
            this.lblOut.Location = new System.Drawing.Point(33, 250);
            this.lblOut.Name = "lblOut";
            this.lblOut.Size = new System.Drawing.Size(79, 16);
            this.lblOut.TabIndex = 59;
@@ -173,7 +176,7 @@
            // 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(616, 196);
            this.btnOutPath.Location = new System.Drawing.Point(616, 245);
            this.btnOutPath.Name = "btnOutPath";
            this.btnOutPath.Size = new System.Drawing.Size(130, 26);
            this.btnOutPath.TabIndex = 58;
@@ -183,7 +186,7 @@
            // 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.Location = new System.Drawing.Point(118, 297);
            this.txtServiceName.MaxLength = 2000;
            this.txtServiceName.Name = "txtServiceName";
            this.txtServiceName.Size = new System.Drawing.Size(482, 26);
@@ -194,17 +197,51 @@
            // 
            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.Location = new System.Drawing.Point(33, 302);
            this.lblService.Name = "lblService";
            this.lblService.Size = new System.Drawing.Size(79, 16);
            this.lblService.TabIndex = 61;
            this.lblService.Text = "服务名称:";
            // 
            // txtBuildingPath
            //
            this.txtBuildingPath.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.txtBuildingPath.Location = new System.Drawing.Point(118, 94);
            this.txtBuildingPath.MaxLength = 2000;
            this.txtBuildingPath.Name = "txtBuildingPath";
            this.txtBuildingPath.Size = new System.Drawing.Size(482, 26);
            this.txtBuildingPath.TabIndex = 65;
            this.txtBuildingPath.Text = "D:\\simu\\input\\tongzhou-local-mesh2-buildings.tif";
            //
            // lblBuilding
            //
            this.lblBuilding.AutoSize = true;
            this.lblBuilding.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.lblBuilding.Location = new System.Drawing.Point(33, 99);
            this.lblBuilding.Name = "lblBuilding";
            this.lblBuilding.Size = new System.Drawing.Size(79, 16);
            this.lblBuilding.TabIndex = 64;
            this.lblBuilding.Text = "建筑数据:";
            //
            // btnBuildingPath
            //
            this.btnBuildingPath.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnBuildingPath.Location = new System.Drawing.Point(616, 94);
            this.btnBuildingPath.Name = "btnBuildingPath";
            this.btnBuildingPath.Size = new System.Drawing.Size(130, 26);
            this.btnBuildingPath.TabIndex = 63;
            this.btnBuildingPath.Text = "选择地形文件";
            this.btnBuildingPath.UseVisualStyleBackColor = true;
            this.btnBuildingPath.Click += new System.EventHandler(this.btnBuildingPath_Click);
            //
            // FrmMain
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(804, 324);
            this.ClientSize = new System.Drawing.Size(804, 364);
            this.Controls.Add(this.txtBuildingPath);
            this.Controls.Add(this.lblBuilding);
            this.Controls.Add(this.btnBuildingPath);
            this.Controls.Add(this.txtServiceName);
            this.Controls.Add(this.lblService);
            this.Controls.Add(this.txtOutPath);
@@ -247,6 +284,9 @@
        private System.Windows.Forms.Button btnOutPath;
        private System.Windows.Forms.TextBox txtServiceName;
        private System.Windows.Forms.Label lblService;
        private System.Windows.Forms.TextBox txtBuildingPath;
        private System.Windows.Forms.Label lblBuilding;
        private System.Windows.Forms.Button btnBuildingPath;
    }
}
SimuTools/FrmMain.cs
@@ -1,4 +1,5 @@
using SimuTools.Tools;
using SimuTools.Domain;
using SimuTools.Tools;
using System;
using System.IO;
using System.Windows.Forms;
@@ -34,11 +35,21 @@
        private void btnTerrainPath_Click(object sender, EventArgs e)
        {
            selectFile(this.txtTerrainPath);
        }
        private void btnBuildingPath_Click(object sender, EventArgs e)
        {
            selectFile(this.txtBuildingPath);
        }
        private void selectFile(TextBox tb)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Tif files(*.tif)|*.tif|Tiff files (*.tiff)|*.tiff";
            dialog.RestoreDirectory = true;
            string path = this.txtTerrainPath.Text.Trim();
            string path = tb.Text.Trim();
            if (File.Exists(path))
            {
                dialog.InitialDirectory = Path.GetDirectoryName(path);
@@ -46,7 +57,7 @@
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.txtTerrainPath.Text = dialog.FileName;
                tb.Text = dialog.FileName;
            }
        }
@@ -87,6 +98,7 @@
        {
            string serviceName = this.txtServiceName.Text.Trim();
            string terrainFile = this.txtTerrainPath.Text.Trim();
            string buildingFile = this.txtBuildingPath.Text.Trim();
            string waterPath = this.txtWaterPath.Text.Trim();
            string flowPath = this.txtFlowPath.Text.Trim();
            string outPath = this.txtOutPath.Text.Trim();
@@ -96,9 +108,9 @@
                ShowErr("服务名称,要求必填!");
                return;
            }
            if (!File.Exists(terrainFile))
            if (!File.Exists(terrainFile) || !File.Exists(buildingFile))
            {
                ShowErr("地形文件,要求必须存在!");
                ShowErr("地形和建筑文件,要求必须存在!");
                return;
            }
            if (!Directory.Exists(waterPath) || !Directory.Exists(flowPath) || !Directory.Exists(outPath))
@@ -112,13 +124,7 @@
                this.btnRun.Enabled = false;
                LogOut.Info("开始运行 >>");
                outPath = Path.Combine(outPath, serviceName);
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }
                Tools.Handle.Run(terrainFile, waterPath, flowPath, outPath);
                Tools.Handle.Run(new Args(serviceName, terrainFile, buildingFile, waterPath, flowPath, outPath));
                this.btnRun.Enabled = true;
                LogOut.Info("运行结束 <<");
SimuTools/SimuTools.csproj
@@ -67,6 +67,7 @@
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Domain\Args.cs" />
    <Compile Include="Domain\Duration.cs" />
    <Compile Include="Domain\Extension.cs" />
    <Compile Include="Domain\Layer.cs" />
SimuTools/Tools/Handle.cs
@@ -32,39 +32,37 @@
        /// <summary>
        /// è¿è¡Œ
        /// </summary>
        public static void Run(string terrainFile, string waterPath, string flowPath, string outPath)
        public static void Run(Args args)
        {
            Domain.Layer layer = new Domain.Layer();
            layer.duration = new Duration();
            layer.terrain = new Terrain();
            layer.waters = new Water();
            string temp = Path.Combine(outPath, "temp");
            if (!Directory.Exists(temp)) Directory.CreateDirectory(temp);
            CopeTerrain(args, layer);
            CopeBuilding(args, layer);
            CopeWater(args, layer);
            CopeFlow(args, layer);
            CopeLayerJson(args, layer);
            CopeTerrain(terrainFile, waterPath, outPath, layer);
            CopeWater(waterPath, outPath, layer);
            CopeFlow(flowPath, outPath, layer);
            CopeLayerJson(outPath, layer);
            if (Directory.Exists(temp)) Directory.Delete(temp, true);
            if (Directory.Exists(args.temp)) Directory.Delete(args.temp, true);
        }
        #region åœ°å½¢
        /// <summary>
        /// å¤„理地形
        /// </summary>
        private static void CopeTerrain(string terrainFile, string waterPath, string outPath, Domain.Layer layer)
        private static void CopeTerrain(Args args, Domain.Layer layer)
        {
            Dataset ds = null;
            try
            {
                ds = Gdal.Open(terrainFile, Access.GA_ReadOnly);
                ds = Gdal.Open(args.terrainFile, Access.GA_ReadOnly);
                if (null == ds || 0 == ds.RasterCount || null == ds.GetSpatialRef()) return;
                SetTerrainInfo(ds, layer);
                SetWaterInfo(waterPath, layer);
                CreateTerrainPng(ds, layer, outPath);
                SetWaterInfo(args, layer);
                CreateTerrainPng(args, ds, layer);
            }
            finally
            {
@@ -113,16 +111,14 @@
        /// <summary>
        /// åˆ›å»ºåœ°å½¢PNG
        /// </summary>
        private static void CreateTerrainPng(Dataset ds, Domain.Layer layer, string outPath)
        private static void CreateTerrainPng(Args args, Dataset ds, Domain.Layer layer)
        {
            string tempPath = Path.Combine(outPath, "temp");
            if (!Directory.Exists(tempPath)) Directory.CreateDirectory(tempPath);
            string terrainPath = Path.Combine(outPath, "terrain");
            string terrainPath = Path.Combine(args.outPath, "terrain");
            if (!Directory.Exists(terrainPath)) Directory.CreateDirectory(terrainPath);
            foreach (int[] sizes in layer.terrain.size)
            {
                string tif = Path.Combine(tempPath, DateTime.Now.Ticks.ToString() + ".tif");
                string tif = Path.Combine(args.temp, "terrain_" + sizes[0] + "_" + sizes[1] + ".tif");
                //Resample(ds.GetDescription(), tif, sizes[0], sizes[1]);
                Resample(ds, tif, sizes[0], sizes[1], layer);
                if (!File.Exists(tif)) continue;
@@ -166,7 +162,7 @@
                ds = Gdal.Open(tif, Access.GA_ReadOnly);
                if (null == ds || 0 == ds.RasterCount) return;
                OSGeo.GDAL.Band band = ds.GetRasterBand(1);
                Band band = ds.GetRasterBand(1);
                float[] buffer = new float[width * height];
                band.ReadRaster(0, 0, width, height, buffer, width, height, 0, 0);
@@ -175,7 +171,6 @@
                graphic.Clear(Color.Transparent); // å¡«å……透明色
                //double perHeight = (layer.terrain.maxHeight - layer.terrain.minHeight) * 100 / 65536;
                //double differ = layer.terrain.maxHeight - layer.terrain.minHeight;
                double differ = layer.extension.maxHeight - layer.extension.minHeight, minHeight = layer.extension.minHeight;
                for (int x = 0; x < width; x++)
                {
@@ -186,7 +181,6 @@
                        //int val = Convert.ToInt32((buffer[offset] - layer.terrain.minHeight) * 100 / perHeight);
                        //int val = Convert.ToInt32((buffer[offset] - layer.terrain.minHeight) / differ * 255); // 65535
                        int r = 0, g, b;
                        if (buffer[offset] - layer.extension.maxHeight > 0)
                        {
@@ -213,13 +207,48 @@
        }
        #endregion
        #region å»ºç­‘
        /// <summary>
        /// å¤„理建筑
        /// </summary>
        private static void CopeBuilding(Args args, Domain.Layer layer)
        {
            Dataset ds = null;
            try
            {
                ds = Gdal.Open(args.buildingFile, Access.GA_ReadOnly);
                if (null == ds || 0 == ds.RasterCount || null == ds.GetSpatialRef()) return;
                foreach (int[] sizes in layer.terrain.size)
                {
                    string tif = Path.Combine(args.temp, "building_" + sizes[0] + "_" + sizes[1] + ".tif");
                    Resample(ds, tif, sizes[0], sizes[1], layer);
                    if (!File.Exists(tif)) continue;
                    Dataset dataset = Gdal.Open(tif, Access.GA_ReadOnly);
                    if (null == dataset || 0 == dataset.RasterCount) return;
                    float[] buffer = new float[sizes[0] * sizes[1]];
                    dataset.GetRasterBand(1).ReadRaster(0, 0, sizes[0], sizes[1], buffer, sizes[0], sizes[1], 0, 0);
                    args.buildings[sizes[0] + "_" + sizes[1]] = buffer;
                    dataset.Dispose();
                }
            }
            finally
            {
                if (null != ds) ds.Dispose();
            }
        }
        #endregion
        #region æ°´é¢
        /// <summary>
        /// è®¾ç½®æ°´é¢ä¿¡æ¯
        /// </summary>
        private static void SetWaterInfo(string waterPath, Domain.Layer layer)
        private static void SetWaterInfo(Args args, Domain.Layer layer)
        {
            List<string> files = layer.waters.files = GetFiles(waterPath);
            List<string> files = layer.waters.files = GetFiles(args.waterPath);
            if (null == files || files.Count == 0) return;
            SetWaterData(layer, files);
@@ -229,12 +258,12 @@
        /// <summary>
        /// å¤„理水面
        /// </summary>
        private static void CopeWater(string waterPath, string outPath, Domain.Layer layer)
        private static void CopeWater(Args args, Domain.Layer layer)
        {
            List<String> files = layer.waters.files;
            if (files.Count == 0 || files.Count != layer.waters.data.Count) return;
            ProcessWaters(files, outPath, layer);
            ProcessWaters(args, files, layer);
        }
        /// <summary>
@@ -302,7 +331,7 @@
        /// <summary>
        /// å¤„理水面数据
        /// </summary>
        private static void ProcessWaters(List<string> files, string outPath, Domain.Layer layer)
        private static void ProcessWaters(Args args, List<string> files, Domain.Layer layer)
        {
            Parallel.For(0, files.Count, i =>
            //for (int i = 0; i < files.Count; i++)
@@ -313,7 +342,7 @@
                    ds = Gdal.Open(files[i], Access.GA_ReadOnly);
                    if (null == ds || 0 == ds.RasterCount || null == ds.GetSpatialRef()) return;
                    CreateWaterPng(ds, layer, outPath, layer.waters.data[i]);
                    CreateWaterPng(args, ds, layer, layer.waters.data[i]);
                }
                finally
                {
@@ -325,29 +354,27 @@
        /// <summary>
        /// åˆ›å»ºæ°´é¢PNG
        /// </summary>
        private static void CreateWaterPng(Dataset ds, Domain.Layer layer, string outPath, long ticks)
        private static void CreateWaterPng(Args args, Dataset ds, Domain.Layer layer, long ticks)
        {
            string tempPath = Path.Combine(outPath, "temp");
            if (!Directory.Exists(tempPath)) Directory.CreateDirectory(tempPath);
            string waterPath = Path.Combine(outPath, "waters", ticks.ToString());
            string waterPath = Path.Combine(args.outPath, "waters", ticks.ToString());
            if (!Directory.Exists(waterPath)) Directory.CreateDirectory(waterPath);
            foreach (int[] sizes in layer.terrain.size)
            {
                string fileName = Path.GetFileNameWithoutExtension(ds.GetDescription()) + "_" + sizes[0] + "_" + sizes[1];
                string tif = Path.Combine(tempPath, fileName + ".tif");
                string tif = Path.Combine(args.temp, fileName + ".tif");
                Resample(ds, tif, sizes[0], sizes[1], layer);
                if (!File.Exists(tif)) continue;
                string png = Path.Combine(waterPath, sizes[0] + "_" + sizes[1] + ".png");
                Water2Png(layer, tif, png, sizes[0], sizes[1]);
                Water2Png(args, layer, tif, png, sizes[0], sizes[1]);
            }
        }
        /// <summary>
        /// æ°´é¢è½¬PNG
        /// </summary>
        private static void Water2Png(Domain.Layer layer, string tif, string png, int width, int height)
        private static void Water2Png(Args args, Domain.Layer layer, string tif, string png, int width, int height)
        {
            Dataset ds = null;
            try
@@ -358,6 +385,7 @@
                Band band = ds.GetRasterBand(1);
                float[] buffer = new float[width * height];
                band.ReadRaster(0, 0, width, height, buffer, width, height, 0, 0);
                float[] building = args.buildings[width + "_" + height];
                Bitmap image = new Bitmap(width, height);
                Graphics graphic = Graphics.FromImage(image);
@@ -371,13 +399,9 @@
                    {
                        int offset = x + y * width;
                        if (float.IsNaN(buffer[offset]) || buffer[offset] < -999 || buffer[offset] < minHeight) continue;
                        if (!float.IsNaN(building[offset]) && building[offset] > -999) continue;
                        //int val = Convert.ToInt32(buffer[offset] * 100);
                        //int val = Convert.ToInt32((buffer[offset] - layer.extension.minHeight + WaterHeightOffset) * 100 / perHeight);
                        //int r = val / 65536;
                        //int g = (val - r * 65536) / 256;
                        //int b = val % 256;
                        int r = 0, g, b;
                        if (buffer[offset] - layer.extension.maxHeight > 0)
                        {
@@ -408,10 +432,10 @@
        /// <summary>
        /// å¤„理流速流向
        /// </summary>
        private static void CopeFlow(string flowPath, string outPath, Domain.Layer layer)
        private static void CopeFlow(Args args, Domain.Layer layer)
        {
            List<string> vxFiles = GetFiles(flowPath, "vx");
            List<string> vyFiles = GetFiles(flowPath, "vy");
            List<string> vxFiles = GetFiles(args.flowPath, "vx");
            List<string> vyFiles = GetFiles(args.flowPath, "vy");
            if (null == vxFiles || null == vyFiles || vxFiles.Count != vyFiles.Count || vxFiles.Count != layer.waters.data.Count) return;
            Parallel.For(0, vxFiles.Count, i =>
@@ -425,7 +449,7 @@
                    if (null == vxDs || 0 == vxDs.RasterCount || null == vxDs.GetSpatialRef() ||
                        null == vyDs || 0 == vyDs.RasterCount || null == vyDs.GetSpatialRef()) return;
                    CreateFlowPng(vxDs, vyDs, layer, outPath, layer.waters.data[i]);
                    CreateFlowPng(args, vxDs, vyDs, layer, layer.waters.data[i]);
                }
                finally
                {
@@ -438,21 +462,19 @@
        /// <summary>
        /// åˆ›å»ºæµé€Ÿæµå‘PNG
        /// </summary>
        private static void CreateFlowPng(Dataset vxDs, Dataset vyDs, Domain.Layer layer, string outPath, long ticks)
        private static void CreateFlowPng(Args args, Dataset vxDs, Dataset vyDs, Domain.Layer layer, long ticks)
        {
            string tempPath = Path.Combine(outPath, "temp");
            if (!Directory.Exists(tempPath)) Directory.CreateDirectory(tempPath);
            string flowPath = Path.Combine(outPath, "flows", ticks.ToString());
            string flowPath = Path.Combine(args.outPath, "flows", ticks.ToString());
            if (!Directory.Exists(flowPath)) Directory.CreateDirectory(flowPath);
            foreach (int[] sizes in layer.terrain.size)
            {
                string vxName = Path.GetFileNameWithoutExtension(vxDs.GetDescription()) + "_" + sizes[0] + "_" + sizes[1];
                string vxTif = Path.Combine(tempPath, vxName + ".tif");
                string vxTif = Path.Combine(args.temp, vxName + ".tif");
                Resample(vxDs, vxTif, sizes[0], sizes[1], layer);
                string vyName = Path.GetFileNameWithoutExtension(vyDs.GetDescription()) + "_" + sizes[0] + "_" + sizes[1];
                string vyTif = Path.Combine(tempPath, vyName + ".tif");
                string vyTif = Path.Combine(args.temp, vyName + ".tif");
                Resample(vyDs, vyTif, sizes[0], sizes[1], layer);
                if (!File.Exists(vxTif) || !File.Exists(vyTif)) continue;
@@ -547,13 +569,13 @@
        /// <summary>
        /// å¤„理元数据
        /// </summary>
        private static void CopeLayerJson(string outPath, Domain.Layer layer)
        private static void CopeLayerJson(Args args, Domain.Layer layer)
        {
            if (null == layer) return;
            String json = JsonConvert.SerializeObject(layer);
            string filePath = Path.Combine(outPath, "layer.json");
            string filePath = Path.Combine(args.outPath, "layer.json");
            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write(json);
@@ -565,12 +587,9 @@
        /// <summary>
        /// è®¾ç½®åœ°å½¢ä¿¡æ¯
        /// </summary>
        private static void SetTerrainInfo(Dataset ds, string outPath, Domain.Layer layer)
        private static void SetTerrainInfo(Args args, Dataset ds, Domain.Layer layer)
        {
            string tempPath = Path.Combine(outPath, "temp");
            if (!Directory.Exists(tempPath)) Directory.CreateDirectory(tempPath);
            string tif = Path.Combine(tempPath, Path.GetFileNameWithoutExtension(ds.GetDescription()) + ".tif");
            string tif = Path.Combine(args.temp, Path.GetFileNameWithoutExtension(ds.GetDescription()) + ".tif");
            Resample(ds, tif);
            if (!File.Exists(tif)) throw new Exception("高程文件重投影失败!");