CPIII观测数据平差处理工具

匿名 (未验证) 提交于 2019-12-03 00:22:01

在高速铁路精密工程测量工作中,经常会涉及到CPIII控制测量的工作以及内业CPIII观测数据的处理,CPIII外业测量采用智能型全站仪进行测量,智能型全站仪可以自动照准目标,自动测量,自动保存观测数据。但内业工作中仍然要对外业得到的角度和距离的观测数据进行平差处理,由于CPIII观测数据的量往往非常大,所以开发出一个能够对CPIII外业观测数据进行批量处理的小工具就很有必要了。下面对该小工具进行介绍并附上核心代码,希望大家多多支持。

CPIII观测数据平差处理工具的界面如图所示


CPIII一个测站的观测数据文件格式如图所示,有几个测站就有多少个观测文件,该程序可以一次打开多个观测数据文件



CPIII观测数据处理软件平差得到的结果如图所示


最后附上程序的核心代码

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.IO; using System.Windows.Forms;  namespace CPIII {     public partial class Form1 : Form     {         private List<string> Names = new List<string>();         private List<string > LAngles = new List<string>();         private List<string> LAngles1= new List<string>();         private List<string> SAngles= new List<string>();         private List<string> SAngles1= new List<string>();         private List<double> Sds = new List<double>();         private List<double> Sds1= new List<double>();         private string  CPIII=null;         public Form1()         {             InitializeComponent();         }          private void button1_Click(object sender, EventArgs e)         {             OpenFileDialog dlg = new OpenFileDialog();             dlg.Multiselect = true;             dlg.DefaultExt = ".SUC";             dlg.Filter = "CPIII观测文件(.SUC)|*.SUC";             if (dlg.ShowDialog()==DialogResult.OK)             {                  foreach (string file in dlg.FileNames)                 {                     Names.Clear();                     LAngles.Clear();                     SAngles.Clear();                     Sds.Clear();                     LAngles1.Clear();                     SAngles1.Clear();                     Sds1.Clear();                     int row = 0;                     int count = 0;                     StreamReader sr = new StreamReader(file);                     string line;                     while ((line = sr.ReadLine()) != null)                     {                         if (row == 0)                         {                             string[] array = line.Split(',');                             CPIII =CPIII+array[0] + "\r\n";                             count = int.Parse(array[2]);                         }                         else                         {                             string[] array = line.Split(',');                             if (array.Length == 6 && row < 3 + count)                             {                                 Names.Add(array[0]);                                 LAngles.Add(array[1]);                                 SAngles.Add(array[2]);                                 Sds.Add(double.Parse(array[3]));                             }                             else if (array.Length == 6 && row < 4 + (count + 1) * 2 + count && row >= 4 + (count + 1) * 2)                             {                                 LAngles1.Add(array[1]);                                 SAngles1.Add(array[2]);                                 Sds1.Add(double.Parse(array[3]));                             }                         }                         row++;                     }                     for (int i = 0; i < count; i++)                     {                         if (i == 0)                         {                             CPIII = CPIII + Names.ElementAt(0).Replace(" ", null) + " ,  L  , 0.000000\r\n";                             CPIII = CPIII + Names.ElementAt(0).Replace(" ", null) + " ,  S  , " + Math.Round((Sds.ElementAt(0) * Math.Sin(DmsToRad(SAngles.ElementAt(0))) + Sds1.ElementAt(0) * Math.Sin(DmsToRad(SAngles1.ElementAt(0)))) / 2, 6) + "\r\n";                         }                         else                         {                             double rad = (dms_jian(LAngles.ElementAt(i), LAngles.ElementAt(0)) + dms_jian(LAngles1.ElementAt(i), LAngles1.ElementAt(0))) / 2;                             CPIII = CPIII + Names.ElementAt(i).Replace(" ",null) + " ,  L  , " + RadToDms(rad) + "\r\n";                             CPIII = CPIII + Names.ElementAt(i).Replace(" ", null) + " ,  S  , " + Math.Round((Sds.ElementAt(i) * Math.Sin(DmsToRad(SAngles.ElementAt(i))) + Sds1.ElementAt(i) * Math.Sin(DmsToRad(SAngles1.ElementAt(i)))) / 2, 6) + "\r\n";                         }                     }                     sr.Close();                 }                              }             MessageBox.Show("         成功打开文件!请点\n击平差处理按钮进行格式转换!");         }         private double dms_jian(string DMS,string dms)         {             double rad = DmsToRad(DMS) - DmsToRad(dms);             if(rad<0)                 rad = 2 * Math.PI - DmsToRad(dms) + DmsToRad(DMS);             return rad;         }         private double DmsToRad(string dms)         {             string []array=dms.Split('.');             int dec =int.Parse(array[0]);             int min = int.Parse(array[1].Substring(0, 2));             string s=null;             if(array[1].Length>4)             s=array[1].Substring(2,2)+"."+array[1].Substring(4);             else               s=array[1].Substring(2,2);             double sec = double.Parse(s);             return (dec + min / 60.0 + sec / 3600) * Math.PI / 180;         }         private string RadToDms(double rad)         {             double dec = 180 / Math.PI * rad;             int D = (int)dec;             double min = (dec - D) * 60;             int M=(int)min;             double sec = (min - M) * 60;             sec = Math.Round(sec, 2);             string MM;             string ss;             if (Math.Abs(M)< 10)                 MM = 0 +Math.Abs(M).ToString();             else                 MM = Math.Abs(M).ToString();             if (Math.Abs(sec) < 10)                 ss = 0 + Math.Abs(sec).ToString();             else                 ss = Math.Abs(sec).ToString();                              return D.ToString() + "." + MM + ss.Replace(".",null);         }          private void button2_Click(object sender, EventArgs e)         {             SaveFileDialog dlg = new SaveFileDialog();             dlg.Filter = "观测文件(*.obser)|*.obser";             dlg.FileName = "result_obser";             dlg.AddExtension = true;             dlg.RestoreDirectory = true;             if (dlg.ShowDialog()==DialogResult.OK)             {                 StreamWriter sw = new StreamWriter(dlg.FileName);                 sw.Write(CPIII);                 sw.Close();             }         }     } } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!