|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using GeoSigmaDrawLib;
|
|
|
using NetTopologySuite;
|
|
|
using NetTopologySuite.Algorithm;
|
|
|
using NetTopologySuite.Geometries;
|
|
|
using NetTopologySuite.GeometriesGraph;
|
|
|
using NetTopologySuite.LinearReferencing;
|
|
|
using NetTopologySuite.Noding;
|
|
|
using NetTopologySuite.Noding.Snapround;
|
|
|
using NetTopologySuite.Operation.Distance;
|
|
|
using NetTopologySuite.Operation.Polygonize;
|
|
|
using NetTopologySuite.Simplify;
|
|
|
using SigmaDrawerElement;
|
|
|
using Point = NetTopologySuite.Geometries.Point;
|
|
|
|
|
|
using Clipper2Lib;
|
|
|
using GeoSigma.SigmaDrawerStyle;
|
|
|
using FortAnalyzeLib;
|
|
|
|
|
|
namespace FortAnalysis
|
|
|
{
|
|
|
public partial class FormMain : Form
|
|
|
{
|
|
|
private GeometryFactory gf = null;
|
|
|
public FormMain()
|
|
|
{
|
|
|
// spatial reference id
|
|
|
const int srid = 25832;
|
|
|
InitializeComponent();
|
|
|
this.gf = NtsGeometryServices.Instance.CreateGeometryFactory(srid);
|
|
|
}
|
|
|
int splitNum = 30;
|
|
|
private void btnPlay_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.calSuccess();
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
//string strFile = @"C:\GeoIntelligent\Drawer\Drawer\GVision\FortAnalysis\堑垒识别(密集带底图).kev";
|
|
|
//string strFileSave = @"C:\GeoIntelligent\Drawer\Drawer\GVision\FortAnalysis\堑垒识别(密集带底图)_output.kev";
|
|
|
string strFile = txtInput.Text;
|
|
|
string strFileSave = txtOutput.Text;
|
|
|
if(string.IsNullOrEmpty(strFileSave))
|
|
|
{
|
|
|
MessageBox.Show("请选择输出文件!");
|
|
|
return;
|
|
|
}
|
|
|
string strLayerSource = $"{this.cmbLayers.SelectedItem}";
|
|
|
|
|
|
FortAnalyze analyze = new FortAnalyze();
|
|
|
analyze.ExcuteAnalyze(strFile, strFileSave, strLayerSource);
|
|
|
|
|
|
MessageBox.Show("计算完毕!");
|
|
|
}
|
|
|
|
|
|
private void btnInput_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
ofd.RestoreDirectory = true;
|
|
|
ofd.Filter = "*.kev|*.kev|*.dfd|*.dfd|*.*|*.*";
|
|
|
if (ofd.ShowDialog() != DialogResult.OK)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
this.txtInput.Text = ofd.FileName;
|
|
|
|
|
|
string strFullFile = this.txtInput.Text;
|
|
|
string strPath = Path.GetDirectoryName(strFullFile);
|
|
|
string strOutput = Path.Combine(strPath,
|
|
|
$"{Path.GetFileNameWithoutExtension(strFullFile)}_out{Path.GetExtension(strFullFile)}");
|
|
|
this.txtOutput.Text = strOutput;
|
|
|
|
|
|
ReloadLayers(strFullFile);
|
|
|
}
|
|
|
|
|
|
private void ReloadLayers(string strFile)
|
|
|
{
|
|
|
DrawerData drawerSource = new DrawerData();
|
|
|
if (drawerSource.OpenFile(strFile) == false)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
string layerNamesStr = drawerSource.GetLayers();
|
|
|
drawerSource.Dispose();
|
|
|
List<string> lstLayerNames = new List<string>();
|
|
|
if (layerNamesStr.Length != 0)
|
|
|
{
|
|
|
string[] separators = new string[1];
|
|
|
separators[0] = "\r\n";
|
|
|
string[] layerNames = layerNamesStr.Split(separators, StringSplitOptions.RemoveEmptyEntries);
|
|
|
foreach (string layerName in layerNames)
|
|
|
{
|
|
|
int nIndexStatus = layerName.IndexOf('|');
|
|
|
if (nIndexStatus >= 0)
|
|
|
{
|
|
|
lstLayerNames.Add(layerName.Substring(nIndexStatus + 1)
|
|
|
.Replace("Layer:\\", string.Empty));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
lstLayerNames.Add(layerName.Replace("Layer:\\", string.Empty));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
lstLayerNames.Sort();
|
|
|
lstLayerNames.Reverse();
|
|
|
cmbLayers.Items.Clear();
|
|
|
cmbLayers.Items.AddRange(lstLayerNames.ToArray());
|
|
|
|
|
|
if (cmbLayers.Items.Count > 0)
|
|
|
{
|
|
|
cmbLayers.SelectedIndex = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void btnOutput_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
SaveFileDialog sfd = new SaveFileDialog();
|
|
|
sfd.RestoreDirectory = true;
|
|
|
sfd.Filter = "*.kev|*.kev|*.dfd|*.dfd|*.*|*.*";
|
|
|
sfd.AddExtension = true;
|
|
|
if(sfd.ShowDialog() != DialogResult.OK)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
this.txtOutput.Text = sfd.FileName;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void btnReloadLayer_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
string strFile = this.txtInput.Text;
|
|
|
ReloadLayers(strFile);
|
|
|
}
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
this.DialogResult = DialogResult.Cancel;
|
|
|
this.Close();
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// cals the success.
|
|
|
/// </summary>
|
|
|
/// <returns>An int.</returns>
|
|
|
private int calSuccess()
|
|
|
{
|
|
|
DateTime dateLim = new DateTime(2023, 12, 31);
|
|
|
if (DateTime.Compare(DateTime.Now, dateLim) > 0)
|
|
|
{
|
|
|
throw new Exception("运行错误,请联系软件服务人员");
|
|
|
}
|
|
|
return 100;
|
|
|
}
|
|
|
}
|
|
|
}
|