开发工具:
文件大小: 920byte
下载次数: 0
上传时间: 2013-04-19
详细说明: 基于c#CP3平面网严密平差数据处理 using System; using System.Collections.Generic; using System.Collections;//使用动态数组需要添加的语句 using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using ParaSet; using CSAccelerateMatrix; using Trans; using CSUsualFun; namespace FreeStaAdj { public partial class Form1 : Form { static string Path = "C:\\Documents and Settings\\HB\\桌面\\春儿数据-120907"; string[] KPName;//存储已知点点号 double[,] KPXYZ;//存储已知点三维坐标 string[] StaKName;//存储测站点点号 double[,] StaKXYZ;//存储测站点已知三维坐标 public class StaData { public string StaName;//测站名 public int Num;//观测的CPIII点数 public string[] CP3Name = new string[12];//CPIII自由测站学习点数一般不会超过12个,此处也可用动态数组存储 public double[,] LVS = new double[12, 3]; }; ArrayList StaList = new ArrayList(); public struct DLVS//用于存储方差分量估计各次的方差估值 { public double DL,DV,DS; }; //以下为默认先验平差参数 double PriLm=0.5,PriSa=1.0,PriSb=1.0;//水平方向中误差,测距固定误差和比例误差 int DMaxNum = 10;//最大方差分量估计次数 double DLimitValue = 0.01;//方差分量估计默认收敛阀值 bool IsD=true;//true表示进行方差分量估计 bool SP = true;//true表示A+B*S bool Ma = true;//true表示验后单位权中误差 double LVRatio = 2.0;//水平方向 和 天顶距 权的比值 string AdjMethord = "普通";//三维平差方法 const double Pe = 0.0174532925199433;//Math.PI/180.0,便于后面简化运算 public Form1() { InitializeComponent(); } public double Cal_DRatio(double a,double b,double c) { double x, y; if (a>=b) { x=a; y =b; } else { x = b; y=a; } if (xc) { y=c; } return x / y;//三个数中的最大值:最小值 } public double atan(double y, double x)//Math.Atan2的返回值区间(-PI,PI] { double p = Math.Atan2(y, x); if (p<0) { return p+2*Math.PI; } else { return p; } } public double SubRad(double y, double x)//返回两个弧度(角度)的差值 { double p =y-x; if (p < 0) { return p + 6.28318530717959; } else { return p; } } public void GetXYZ(string PName,ref double x,ref double y,ref double z,string[] KPName, double[,] KPXYZ) { for (int i=0;i3.14)//出现359 59 59的情况 { ljk -= 2 * Math.PI; } return ljk * 206264.8062471; } public void Cal_LVk(double[] LV, double[,] BL, double[] lL, double[] X, int n) { for (int i = 0; i < n; i++) { LV[i] = -1.0 + BL[i, 0] * X[2] + BL[i, 1] * X[3] - lL[i]; } } public void Cal_LV(double[] LV,double[,] BL, double[] lL,double[] X,int n) { for(int i=0;i0) { linecount++; } } A0.Close(); KPName = new string[linecount]; KPXYZ = new double[linecount, 3]; int k = 0, j = 0;//j记录逗号下标+1 StreamReader A1 = new StreamReader(fname); while ((line = A1.ReadLine()) != null) { if (line.Trim().Length>0) { KPName[k] = GetData(line, ref j); KPXYZ[k, 1] =double.Parse(GetData(line, ref j));//原文件格式是YXZ KPXYZ[k, 0] =double.Parse(GetData(line, ref j));//原文件格式是YXZ KPXYZ[k, 2] = double.Parse(GetData(line, ref j)); k++; j = 0; } } A1.Close(); } } private void 导入观测数据ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Multiselect = false; openFileDialog1.Title = "导入观测文件"; openFileDialog1.Filter = "文本文档(*.txt;*.csv)|*.txt;*.csv" + "|所有文件(*.*)|*.*"; openFileDialog1.InitialDirectory = @Path; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { richTextBox1.Clear(); string fname = openFileDialog1.FileName; StreamReader sr = new StreamReader(fname, Encoding.UTF8); richTextBox1.Text = sr.ReadToEnd().ToString(); sr.Close(); String line; int linecount = 0; StreamReader A0 = new StreamReader(fname); while ((line = A0.ReadLine()) != null) { if (line.Trim().Length > 0) { linecount++; } } A0.Close(); int k = 0; StaList.Clear();//清空原来的数据 StreamReader A1 = new StreamReader(fname); line = A1.ReadLine(); while (line!=null) { if (line.Trim().Length > 0) { if (line[3]=='-') { StaData D=new StaData(); D.StaName=GetStaName(line); line = A1.ReadLine();//跳过"序号 水平方向观测值 天顶距 斜距" while ((line = A1.ReadLine()) != null) { line = line.Trim(); if (line.Length > 0) { if (line[3]!='-') { GetLVS(line, ref D.CP3Name[k], ref D.LVS[k, 0], ref D.LVS[k, 1], ref D.LVS[k, 2]); D.LVS[k, 0] *= 0.9; //gon -> ″ D.LVS[k, 1] *= 0.9; //gon -> ″ D.LVS[k,2]-=0.0344;//减去棱镜常数 k++; } else { D.Num=k; StaList.Add(D); k = 0; break; } } } if (k>0)//最后一个测站的数据 { D.Num = k; StaList.Add(D); } } } else { line = A1.ReadLine(); } } A1.Close(); } } private void 导入测站ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Multiselect = false; openFileDialog1.Title = "导入既有测站坐标"; openFileDialog1.Filter = "文本文档(*.txt;*.dat)|*.txt;*.dat" + "|所有文件(*.*)|*.*"; openFileDialog1.InitialDirectory = @Path; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { richTextBox1.Clear(); string fname = openFileDialog1.FileName; StreamReader sr = new StreamReader(fname, Encoding.UTF8); richTextBox1.Text = sr.ReadToEnd().ToString(); sr.Close(); String line; int linecount = 0; StreamReader A0 = new StreamReader(fname); while ((line = A0.ReadLine()) != null) { if (line.Trim().Length > 0) { linecount++; } } A0.Close(); StaKName = new string[linecount]; StaKXYZ = new double[linecount, 3]; int k = 0; StreamReader A1 = new StreamReader(fname); while ((line = A1.ReadLine())!= null) { //原文件格式是YXZ GetLVS(line, ref StaKName[k], ref StaKXYZ[k, 1], ref StaKXYZ[k, 0], ref StaKXYZ[k, 2]); k++; } A1.Close(); } } private void 参数设置ToolStripMenuItem_Click(object sender, EventArgs e) { SetPa f1=new SetPa(); f1.ShowDialog(this); this.PriLm = double.Parse(f1.textBox1.Text); this.PriSa = double.Parse(f1.textBox2.Text); this.PriSb = double.Parse(f1.textBox3.Text); this.DMaxNum = int.Parse(f1.textBox4.Text); this.DLimitValue = double.Parse(f1.textBox5.Text); this.IsD =f1.checkBox1.Checked; this.SP = f1.radioButton1.Checked; this.Ma = f1.radioButton4.Checked; this.AdjMethord = f1.comboBox1.Text; this.LVRatio = double.Parse(f1.comboBox2.Text); } private void 三维平差ToolStripMenuItem_Click(object sender, EventArgs e) { //以下进行测站三维平差-只针对CPIII自由测站的三维解算 double[,] StaAppXYZ=new double[StaList.Count,3];//测站概略坐标数组 double[,] StaAdjXYZ = new double[StaList.Count, 3];//测站概略坐标数组 double[] StaZ = new double[StaList.Count];//测站定向角未知数数组 double[] StaAppZ = new double[StaList.Count];//测站定向角未知数数组 double[] K = new double[StaList.Count];//大气折光系数k数组 double[,] AB = new double[StaList.Count, 2];//固定误差 和 比例误差数组 CalStaAppXY(StaAppXYZ,StaList,KPName,KPXYZ);//计算测站点近似坐标 CopyStaAppXY(StaAppXYZ, StaAdjXYZ);//将近似坐标拷贝一个副本 double z0=0;//z0为某测站定向角未知数近似值,单位为弧度 ArrayList D0List = new ArrayList();//存储各次方差分量估值的数组 //平差方法包括:普通 球气差 距离误差 球气差&距离误差 四种 switch (AdjMethord) { case "普通": { //未知参数改正数顺序为 定向角z,X,Y,Z int i; for (i = 0; i < StaList.Count; i++) { double[] NL = new double[10];//水平方向 法方程系数矩阵 double[] NV = new double[10];//天顶距 法方程系数矩阵 double[] NS = new double[10];//边长 法方程系数矩阵 double[] N = new double[10];//法方程系数矩阵 double[] WL = new double[4];//水平方向 法方程常数项 double[] WV = new double[4];//天顶距 法方程常数项 double[] WS = new double[4];//天顶距 法方程常数项 double[] W = new double[4];//法方程常数项 double[] X = new double[4];//未知参数改正数顺序为z,X,Y,Z StaData D = (StaData)StaList[i];//获取各测站的数据,需要强制类型转换获取StaList中的数据 //以下对边长定权 double[] PS = new double[D.Num]; Cal_SWeight(PS, PriLm, PriSa, PriSb, D, SP); double[,] BL=new double[D.Num,2];//用于v=Bx-l计算v double[,] BV=new double[D.Num,3]; double[,] BS=new double[D.Num,3]; double[] lL=new double[D.Num];//用于v=Bx-l计算l double[] lV=new double[D.Num]; double[] lS=new double[D.Num]; double[] LV=new double[D.Num];//用于存储残差 double[] VV=new double[D.Num]; double[] SV=new double[D.Num]; int IterNum = 0;//记录迭代次数 double DL, DV, DS,RLS; ArrayList TempD0 = new ArrayList();//存储各测站方差分量估计各次各分量的方差值 do { IterNum++; if (IterNum > DMaxNum) { break;//超过自定义迭代次数则跳出循环 } //以下填充N和W,此处的三个函数实际上合并成一个函数可以简化运算!但时间限制,有待继续完善 FillNS(NS,WS,i,D,PS,KPName,KPXYZ,StaAdjXYZ,BS,lS); FillNL(NL, WL, i, D, ref z0, KPName, KPXYZ, StaAdjXYZ, BL, lL); FillNV(NV, WV, i, D, LVRatio, KPName, KPXYZ, StaAdjXYZ, BV, lV); AccelerateMatrix A = new AccelerateMatrix(); A.AddN(N, NL, NS, 10); A.AddN(N, NV, 10); A.AddN(W, WL, WS, 4); A.AddN(W, WV, 4); A.SPDMatrixInverse(ref N, 4); A.Cal_InvNW(N, W, 4, ref X); Cal_LV(LV,BL,lL,X,D.Num); Cal_SV(SV,BS,lS,X,D.Num); Cal_VV(VV,BV,lV,X,D.Num); UsualFun UF = new UsualFun(); StaAppZ[i] = UF.ChangeRadToDMS(z0);//存储定向角未知数近似值 StaZ[i] = UF.ChangeRadToDMS(z0 + X[0] / 206264.8062471);//将定向角从rad转换为dms StaAdjXYZ[i, 0] += X[1] / 1000; StaAdjXYZ[i, 1] += X[2] / 1000; StaAdjXYZ[i, 2] += X[3] / 1000; if(!IsD) { break;//不进行Helmert方差分量估计就跳出循环 } DL=Cal_LD0(LV,D.Num,N,NL,4); DV=Cal_VD0(VV,LVRatio,D.Num,N,NV,4); DS=Cal_SD0(SV,PS,D.Num,N,NS,4); DLVS Di=new DLVS(); Di.DL = DL; Di.DV = DV; Di.DS = DS; TempD0.Add(Di); RLS=DL/ DS; for (int j = 0; j < D.Num;j++) { PS[j] *=RLS; } LVRatio*=DV/DL;//此处不理解可以推导 } while ((Math.Abs(Cal_DRatio(DL, DV, DS)- 1)) > DLimitValue); D0List.Add(TempD0); } PrintResult(StaAppXYZ, StaAdjXYZ, StaZ,StaAppZ,StaList, D0List, IsD, StaKName, StaKXYZ); break; } case "球气差": { //未知参数改正数顺序为 定向角z,k,X,Y,Z int i; for (i = 0; i < StaList.Count; i++) { double[] NL = new double[15];//水平方向 法方程系数矩阵 double[] NV = new double[15];//天顶距 法方程系数矩阵 double[] NS = new double[15];//边长 法方程系数矩阵 double[] N = new double[15];//法方程系数矩阵 double[] WL = new double[5];//水平方向 法方程常数项 double[] WV = new double[5];//天顶距 法方程常数项 double[] WS = new double[5];//天顶距 法方程常数项 double[] W = new double[5];//法方程常数项 double[] X = new double[5];//未知参数改正数顺序为z,X,Y,Z StaData D = (StaData)StaList[i];//获取各测站的数据,需要强制类型转换获取StaList中的数据 //以下对边长定权 double[] PS = new double[D.Num]; Cal_SWeight(PS, PriLm, PriSa, PriSb, D, SP); double[,] BL = new double[D.Num, 2];//用于v=Bx-l计算v double[,] BV = new double[D.Num, 4];//k,X,Y,Z double[,] BS = new double[D.Num, 3]; double[] lL = new double[D.Num];//用于v=Bx-l计算l double[] lV = new double[D.Num]; double[] lS = new double[D.Num]; double[] LV = new double[D.Num];//用于存储残差 double[] VV = new double[D.Num]; double[] SV = new double[D.Num]; int IterNum = 0;//记录迭代次数 double DL, DV, DS, RLS; ArrayList TempD0 = new ArrayList();//存储各测站方差分量估计各次各分量的方差值 do { IterNum++; if (IterNum > DMaxNum) { ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.