您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 四等水准c#开源代码
四等水准测量开源代码namespace测量程序设计{publicpartialclassForm3:Form{publicForm3(){InitializeComponent();}privatevoidbutton3_Click(objectsender,EventArgse){}privatevoidradioButton1_CheckedChanged(objectsender,EventArgse){//选择路线类型附合有终点高程闭合和支水准都不存在终点高程//选中附合txtz可用而闭合和和支水准不可用choiceStyle();}//定义全局变量方便其他控件调用intistation;double[]dis;double[]detH;doublestartpoint;doubleendpoint;//声明泛型集合来存储文件全路径Listdoublelistdis=newListdouble();ListdoublelistdetH=newListdouble();privatevoidbutton1_Click(objectsender,EventArgse){AddDate();}double[]BMPoint;//转点高程数组doublecloseDetH;//闭合差doubletotalDetH=0;//累计高差privatevoidbutton2_Click(objectsender,EventArgse){double[]diss=listdis.ToArray();double[]detHh=listdetH.ToArray();CalcDate(diss,detHh);}privatevoidtxtc_TextChanged(objectsender,EventArgse){}//选择类型publicvoidchoiceStyle(){if(rb1.Checked==true){txtz.Enabled=true;}elseif(rb2.Checked==true){txtz.Enabled=false;}elseif(rb3.Checked==true){txtz.Enabled=false;}}//读入数据publicvoidAddDate(){if(txtq.Text==){MessageBox.Show(还没有输入起始高程);txtq.Focus();}elseif(rb1.Checked==true&&txtz.Text==){MessageBox.Show(还没有输入终点高程);txtz.Focus();}elseif(txtc.Text==){MessageBox.Show(还没有输入测站数);txtc.Focus();}else{//点击弹出对话框OpenFileDialogofd=newOpenFileDialog();//设置对话框可以多选ofd.Multiselect=true;//设置对话框的初始目录ofd.InitialDirectory=@C:\DocumentsandSettings\Administrator\桌面;//设置对话框的文件类型ofd.Filter=文本文件|*.txt|所有文件|*.*;//展示对话框ofd.ShowDialog();//获得在打开对话框中选中文件的路径stringpath=ofd.FileName;if(path==){return;}istation=int.Parse(txtc.Text);startpoint=double.Parse(txtq.Text);endpoint=double.Parse(txtz.Text);string[]line=File.ReadAllLines(path);for(inti=0;iistation;i++){dis=newdouble[istation];detH=newdouble[istation];char[]chs={','};string[]str=line[i].Split(chs,StringSplitOptions.RemoveEmptyEntries);dis[i]=double.Parse(str[0]);//高差中数detH[i]=double.Parse(str[1]);//距离intstation=i+1;//数组转化为集合方便后面数据的使用listdis.Add(dis[i]);listdetH.Add(detH[i]);txtre.Text=txtre.Text+\r\n+第+station+站:+\r\n+距离:+dis[i].ToString()++高差中数:+detH[i].ToString();}}}//平差计算publicvoidCalcDate(double[]diss,double[]detHh){txtre.Text=txtre.Text+\r\n+计算结果为:+\r\n;doubletDist=0;for(inti=0;iistation;i++){tDist=tDist+diss[i];//计算距离之和}for(inti=0;iistation;i++){totalDetH=totalDetH+detHh[i];//计算累计高差}if(rb1.Checked==true)//附合水准{closeDetH=totalDetH-(endpoint-startpoint);}else{closeDetH=-(totalDetH);//闭合水准和支水准闭合差取负}if(Math.Abs(closeDetH)40*Math.Sqrt(tDist/1000)){MessageBox.Show(闭合差超限,测量成果不合格!);txtre.Text=txtre.Text+闭合差超限,成果不合格;return;}else{MessageBox.Show(闭合差合格,继续计算转点高程!);}BMPoint=newdouble[istation];BMPoint[0]=startpoint;txtre.Text=txtre.Text+平差后的高程为:+\r\n+(+0+)+startpoint.ToString()+\r\n;for(inti=1;iistation;i++){BMPoint[i]=BMPoint[i-1]+detHh[i-1]+closeDetH*diss[i-1]/tDist;txtre.Text=txtre.Text+\r\n+(+i.ToString()+)+BMPoint[i].ToString(#0.0000)+\r\n;}txtre.Text=txtre.Text+\r\n+(+istation.ToString()+)+endpoint.ToString();;}}
本文标题:四等水准c#开源代码
链接地址:https://www.777doc.com/doc-4674117 .html