兼容新排位软件。
This commit is contained in:
parent
7ce4357fbe
commit
edb3ad63c3
|
|
@ -81,6 +81,7 @@
|
||||||
this.Controls.Add(this.LB_SFilePath);
|
this.Controls.Add(this.LB_SFilePath);
|
||||||
this.Name = "Gui";
|
this.Name = "Gui";
|
||||||
this.Text = "Gui";
|
this.Text = "Gui";
|
||||||
|
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Gui_FormClosed);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PutTowerPosition
|
||||||
private void BT_SelectSFile_Click(object sender, EventArgs e)
|
private void BT_SelectSFile_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
openFileDialog.Filter = "S files (*.dat)|*.dat";
|
openFileDialog.Filter = "S or cadd files (*.dat;*.cadd)|*.dat;*.cadd";
|
||||||
openFileDialog.Multiselect = false;
|
openFileDialog.Multiselect = false;
|
||||||
openFileDialog.RestoreDirectory = true;
|
openFileDialog.RestoreDirectory = true;
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
|
@ -36,5 +36,11 @@ namespace PutTowerPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Gui_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
|
{
|
||||||
|
PutTowerPosition.Cmd.releaseLatestTowerList();
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// 此代码由工具生成。
|
||||||
// Runtime Version:2.0.50727.8689
|
// 运行时版本:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||||
// the code is regenerated.
|
// 重新生成代码,这些更改将会丢失。
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace PutTowerPosition.Properties {
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
|
@ -10,8 +10,29 @@
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>PutTowerPosition</RootNamespace>
|
<RootNamespace>PutTowerPosition</RootNamespace>
|
||||||
<AssemblyName>PutTowerPostion</AssemblyName>
|
<AssemblyName>PutTowerPostion</AssemblyName>
|
||||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<UpgradeBackupLocation>
|
||||||
|
</UpgradeBackupLocation>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
@ -23,6 +44,9 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<StartAction>Program</StartAction>
|
<StartAction>Program</StartAction>
|
||||||
<StartProgram>C:\Program Files\AutoCAD 2010\acad.exe</StartProgram>
|
<StartProgram>C:\Program Files\AutoCAD 2010\acad.exe</StartProgram>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
|
|
@ -32,26 +56,29 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="acdbmgd, Version=18.0.0.0, Culture=neutral, processorArchitecture=x86">
|
<Reference Include="accoremgd">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\..\..\Program Files\Cad2022\AutoCAD 2022\accoremgd.dll</HintPath>
|
||||||
<HintPath>C:\Program Files\AutoCAD 2010\acdbmgd.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="acmgd, Version=18.0.0.0, Culture=neutral, processorArchitecture=x86">
|
<Reference Include="acdbmgd">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\..\..\Program Files\Cad2022\AutoCAD 2022\acdbmgd.dll</HintPath>
|
||||||
<HintPath>C:\Program Files\AutoCAD 2010\acmgd.dll</HintPath>
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="acmgd">
|
||||||
|
<HintPath>..\..\..\Program Files\Cad2022\AutoCAD 2022\acmgd.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>C:\Program Files (x86)\Microsoft Office\root\Office16\ADDINS\Microsoft Power Query for Excel Integrated\bin\Microsoft.Office.Interop.Excel.dll</HintPath>
|
<HintPath>C:\Program Files (x86)\Microsoft Office\root\Office16\ADDINS\Microsoft Power Query for Excel Integrated\bin\Microsoft.Office.Interop.Excel.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath>Newtonsoft.Json.11.0.2\lib\net35\Newtonsoft.Json.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
|
|
@ -85,6 +112,7 @@
|
||||||
<Compile Include="Utils.cs" />
|
<Compile Include="Utils.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
|
@ -95,6 +123,26 @@
|
||||||
<DependentUpon>Gui.cs</DependentUpon>
|
<DependentUpon>Gui.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<WCFMetadata Include="Connected Services\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
|
<StartProgram>D:\Program Files\Cad2022\AutoCAD 2022\acad.exe</StartProgram>
|
||||||
|
<StartAction>Program</StartAction>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectView>ProjectFiles</ProjectView>
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -13,6 +13,12 @@ using System.Security.Cryptography;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
using System.Runtime.Remoting.Lifetime;
|
||||||
|
|
||||||
|
|
||||||
[assembly: CommandClass(typeof(PutTowerPosition.Cmd))]
|
[assembly: CommandClass(typeof(PutTowerPosition.Cmd))]
|
||||||
namespace PutTowerPosition
|
namespace PutTowerPosition
|
||||||
|
|
@ -21,7 +27,7 @@ namespace PutTowerPosition
|
||||||
|
|
||||||
public class Cmd
|
public class Cmd
|
||||||
{
|
{
|
||||||
struct spanStruct
|
public struct spanStruct
|
||||||
{
|
{
|
||||||
|
|
||||||
public string towerName;
|
public string towerName;
|
||||||
|
|
@ -60,12 +66,24 @@ namespace PutTowerPosition
|
||||||
gui.Show();
|
gui.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void releaseLatestTowerList()
|
||||||
|
{
|
||||||
|
latestTowerList = null;
|
||||||
|
}
|
||||||
public static void PutTowerPosition(string SFilePath)
|
public static void PutTowerPosition(string SFilePath)
|
||||||
{
|
{
|
||||||
string excelFile = findCordinationExcel(SFilePath);
|
string excelFile = findCordinationExcel(SFilePath);
|
||||||
Dictionary<string, double[]> cordDic = readCordExcel(excelFile);
|
Dictionary<string, double[]> cordDic = readCordExcel(excelFile);
|
||||||
List<spanStruct> spanList = readSSpan(SFilePath);
|
string rootDir = Path.GetDirectoryName(SFilePath);
|
||||||
|
List<spanStruct> spanList=null;
|
||||||
|
if (SFilePath.EndsWith(".dat"))
|
||||||
|
{
|
||||||
|
spanList = readSSpan(SFilePath);
|
||||||
|
}
|
||||||
|
if (SFilePath.EndsWith(".cadd"))
|
||||||
|
{
|
||||||
|
spanList = readCaddSpan(SFilePath);
|
||||||
|
}
|
||||||
Document acDoc;
|
Document acDoc;
|
||||||
Database acCurDb;
|
Database acCurDb;
|
||||||
//acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filePath, true);
|
//acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(filePath, true);
|
||||||
|
|
@ -107,27 +125,38 @@ namespace PutTowerPosition
|
||||||
|
|
||||||
}
|
}
|
||||||
Position[] cordinationList = calTowerXYPostion(cordDic, spanList);
|
Position[] cordinationList = calTowerXYPostion(cordDic, spanList);
|
||||||
foreach (Position point in cordinationList)
|
if (cordinationList != null)
|
||||||
{
|
{
|
||||||
DBPoint dbPoint = new DBPoint(new Point3d(point.Y, point.X, 0));
|
foreach (Position point in cordinationList)
|
||||||
dbPoint.Layer = "TW";
|
{
|
||||||
acBlkTblRec.AppendEntity(dbPoint);
|
DBPoint dbPoint = new DBPoint(new Point3d(point.Y, point.X, 0));
|
||||||
acTrans.AddNewlyCreatedDBObject(dbPoint, true);
|
dbPoint.Layer = "TW";
|
||||||
acCurDb.Pdmode = 35;
|
acBlkTblRec.AppendEntity(dbPoint);
|
||||||
acCurDb.Pdsize = 15;
|
acTrans.AddNewlyCreatedDBObject(dbPoint, true);
|
||||||
DBText dbTowerName=new DBText();
|
acCurDb.Pdmode = 35;
|
||||||
dbTowerName.TextString = point.towerName;
|
acCurDb.Pdsize = 15;
|
||||||
Point3d towerNamePoint = new Point3d(point.Y + 20, point.X + 20,0);
|
DBText dbTowerName = new DBText();
|
||||||
dbTowerName.Position = towerNamePoint;
|
dbTowerName.TextString = point.towerName;
|
||||||
dbTowerName.Layer = "TW";
|
Point3d towerNamePoint = new Point3d(point.Y + 20, point.X + 20, 0);
|
||||||
dbTowerName.Height = 40;
|
dbTowerName.Position = towerNamePoint;
|
||||||
acBlkTblRec.AppendEntity(dbTowerName);
|
dbTowerName.Layer = "TW";
|
||||||
acTrans.AddNewlyCreatedDBObject(dbTowerName,true);
|
dbTowerName.Height = 40;
|
||||||
Tower latestTower;
|
acBlkTblRec.AppendEntity(dbTowerName);
|
||||||
latestTower.name = dbTowerName.ObjectId;
|
acTrans.AddNewlyCreatedDBObject(dbTowerName, true);
|
||||||
latestTower.point = dbPoint.ObjectId;
|
Tower latestTower;
|
||||||
latestTowerList.Add(latestTower);
|
latestTower.name = dbTowerName.ObjectId;
|
||||||
|
latestTower.point = dbPoint.ObjectId;
|
||||||
|
latestTowerList.Add(latestTower);
|
||||||
|
}
|
||||||
|
//写坐标
|
||||||
|
StreamWriter cordTextWriter = new StreamWriter(rootDir + "/cord.txt");
|
||||||
|
foreach (Position point in cordinationList)
|
||||||
|
{
|
||||||
|
cordTextWriter.WriteLine(point.towerName + "," + point.Y + "," + point.X);//地理Y和X坐标,与数学坐标相比是反的。
|
||||||
|
}
|
||||||
|
cordTextWriter.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
acTrans.Commit();
|
acTrans.Commit();
|
||||||
}
|
}
|
||||||
//acBlkTblRec.Database.SaveAs(outputFilePath, false, DwgVersion.Current, acDoc.Database.SecurityParameters);
|
//acBlkTblRec.Database.SaveAs(outputFilePath, false, DwgVersion.Current, acDoc.Database.SecurityParameters);
|
||||||
|
|
@ -288,14 +317,79 @@ namespace PutTowerPosition
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double[] cordination = new double[2];
|
double[] cordination = new double[2];
|
||||||
cordination[0] = (double)(get_value(w_sheet, "B" + i.ToString()));
|
cordination[1] = (double)(get_value(w_sheet, "B" + i.ToString()));
|
||||||
cordination[1] = (double)(get_value(w_sheet, "C" + i.ToString()));
|
cordination[0] = (double)(get_value(w_sheet, "C" + i.ToString()));
|
||||||
towerCordination.Add(towerName, cordination);
|
towerCordination.Add(towerName.Trim(), cordination);
|
||||||
}
|
}
|
||||||
return towerCordination;
|
return towerCordination;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<spanStruct> readCaddSpan(string CaddFilePath)
|
||||||
|
{
|
||||||
|
//StreamReader reader = new StreamReader(SFilePath, Encoding.GetEncoding("gb2312"));
|
||||||
|
string json = File.ReadAllText(CaddFilePath, Encoding.GetEncoding("gb2312"));
|
||||||
|
JObject objs = JObject.Parse(json);
|
||||||
|
JArray dingweiData = objs["08定位数据"]["01定位数据"] as JArray;
|
||||||
|
double basicMileage = 0;
|
||||||
|
List<spanStruct> spanList = new List<spanStruct>();
|
||||||
|
foreach (JObject towerInfo in dingweiData)
|
||||||
|
{
|
||||||
|
|
||||||
|
double mileage = (double)towerInfo["03累距"];
|
||||||
|
double span = mileage - basicMileage;
|
||||||
|
string towerName;
|
||||||
|
towerName= (string)towerInfo["00塔号"];
|
||||||
|
spanStruct _span;
|
||||||
|
_span.towerName = towerName;
|
||||||
|
_span.span = span;
|
||||||
|
spanList.Add(_span);
|
||||||
|
basicMileage = mileage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Dictionary<string, char> has_tower = new Dictionary<string, char>();
|
||||||
|
//while ((line = reader.ReadLine()) != null)
|
||||||
|
//{
|
||||||
|
// if (line.Trim().StartsWith("首端") | line.Trim().StartsWith("塔号"))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// if (line.Trim() == "")
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// string norm_line;
|
||||||
|
// norm_line = Regex.Replace(line, @"\s+", ",");
|
||||||
|
// if (norm_line.StartsWith(","))
|
||||||
|
// {
|
||||||
|
// norm_line = norm_line.Substring(1);
|
||||||
|
// }
|
||||||
|
// string[] sep = norm_line.Split(',');
|
||||||
|
// string towerName = sep[0];
|
||||||
|
// if (has_tower.ContainsKey(towerName))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// has_tower.Add(towerName, ' ');
|
||||||
|
// double mileage = Double.Parse(sep[1]);
|
||||||
|
// double span;
|
||||||
|
// if (basicMileage == -1)
|
||||||
|
// {
|
||||||
|
// basicMileage = mileage;
|
||||||
|
// }
|
||||||
|
// span = mileage - basicMileage;
|
||||||
|
// spanStruct _span;
|
||||||
|
// _span.towerName = towerName;
|
||||||
|
// _span.span = span;
|
||||||
|
// spanList.Add(_span);
|
||||||
|
// basicMileage = mileage;
|
||||||
|
|
||||||
|
//}
|
||||||
|
//reader.Close();
|
||||||
|
return spanList;
|
||||||
|
}
|
||||||
|
|
||||||
static List<spanStruct> readSSpan(string SFilePath)
|
static List<spanStruct> readSSpan(string SFilePath)
|
||||||
{
|
{
|
||||||
StreamReader reader = new StreamReader(SFilePath, Encoding.GetEncoding("gb2312"));
|
StreamReader reader = new StreamReader(SFilePath, Encoding.GetEncoding("gb2312"));
|
||||||
|
|
@ -352,9 +446,16 @@ namespace PutTowerPosition
|
||||||
tensionStart = 0;
|
tensionStart = 0;
|
||||||
//find next end point
|
//find next end point
|
||||||
Point2D endPoint;
|
Point2D endPoint;
|
||||||
|
int inCaseOfInfinite=0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
inCaseOfInfinite++;
|
||||||
Position startPosition;
|
Position startPosition;
|
||||||
|
if (!cordDic.ContainsKey(SSpan[tensionStart].towerName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("字典中无关键字" + SSpan[tensionStart].towerName);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
startPoint.X = cordDic[SSpan[tensionStart].towerName][0];
|
startPoint.X = cordDic[SSpan[tensionStart].towerName][0];
|
||||||
startPoint.Y = cordDic[SSpan[tensionStart].towerName][1];
|
startPoint.Y = cordDic[SSpan[tensionStart].towerName][1];
|
||||||
startPosition.towerName = SSpan[tensionStart].towerName;
|
startPosition.towerName = SSpan[tensionStart].towerName;
|
||||||
|
|
@ -394,6 +495,11 @@ namespace PutTowerPosition
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (inCaseOfInfinite > 10000)
|
||||||
|
{
|
||||||
|
MessageBox.Show("进入无限循环了。");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cordinationList;
|
return cordinationList;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using PutTowerPosition;
|
||||||
|
|
||||||
|
namespace PutTowerPosition
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
PutTowerPosition.Cmd.readCaddSpan("d:\\工程\\750kV白银3回\\排位\\750白银3\\750白银3.cadd");
|
||||||
|
System.Console.WriteLine("Finished.");
|
||||||
|
System.Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{31613C09-BD2B-41D1-A375-0FC306504569}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>Test</RootNamespace>
|
||||||
|
<AssemblyName>Test</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\PutTowerPosition\PutTowerPosition.csproj">
|
||||||
|
<Project>{ca8fb7a3-ceb6-471c-bb97-76cbfa17293c}</Project>
|
||||||
|
<Name>PutTowerPosition</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
Loading…
Reference in New Issue