//高斯批量正算 private void btnZConvert_Click(object sender, EventArgs e) { //从ListView中获取经纬度 List <string> listStrB = new List <string>(); List <string> listStrL = new List <string>(); Data.FromListView(this.listZSource, listStrB, listStrL); if (txtn.Text == "") { MessageBox.Show("请输入带号!", "Error"); return; } int n = Convert.ToInt32(txtn.Text); double l0 = Gauss.l0rad(n); int ykm = Convert.ToInt32(txtYKM.Text) / 1000; //获取所选椭球参数值 double a = Convert.ToDouble(txtA.Text); //由于double精度有限,所以选择通过扁率的倒数β来计算e的平方 double e2 = (2 * Convert.ToDouble(txtB.Text) - 1) / Convert.ToDouble(txtB.Text) / Convert.ToDouble(txtB.Text); Gauss gauss = new Gauss(a, e2); MyList <string> xyStr = new MyList <string>(); for (int i = 0; i < listStrB.Count; i++) { double lrad = DmsRad.dms2rad(listStrL[i]) - l0; double x = gauss.Get_x(DmsRad.dms2rad(listStrB[i]), lrad); double y = gauss.Get_y(DmsRad.dms2rad(listStrB[i]), lrad, n, ykm); xyStr.Add(x.ToString(), y.ToString()); } listZDes.BeginUpdate(); Data.AddDataList(listZDes, xyStr.ListX, xyStr.ListY); listZDes.EndUpdate(); }
//计算子午线弧长 private void btnLZCal_Click(object sender, EventArgs e) { //获取所选椭球参数值 double a = Convert.ToDouble(txtA.Text); //由于double精度有限,所以选择通过扁率的倒数β来计算e的平方 double e2 = (2 * Convert.ToDouble(txtB.Text) - 1) / Convert.ToDouble(txtB.Text) / Convert.ToDouble(txtB.Text); //获取步长或者精度 double n = 0; if (txtZE.Enabled) { n = Convert.ToDouble(txtZE.Text); } //存储从ListView中获取到的“纬度B” List <string> list = new List <string>(); Data.FromListView(this.listLZ, list); List <string> listStr = new List <string>(); foreach (var item in list) { listStr.Add((Convert.ToDouble(item)).ToString("0.0000")); } //将list中的“纬度”转换为弧度制 //根据所选算法计算弧长,将结果存放在listRes集合中。 List <string> listRes = new List <string>(); ArcLength arc = new ArcLength(a, e2); //经典算法结果 List <string> list_c = new List <string>(); foreach (var item in list) { list_c.Add(arc.X_standard(DmsRad.dms2rad(item)).ToString("0.000")); } //根据数值积分计算弧长 switch (this.cboxZMethod.SelectedIndex) { case 1: //复化梯形算法 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_ft((int)(B_rad / (n / DmsRad.p)), B_rad).ToString("0.000")); } break; case 2: //复化辛普森算法 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_fs((int)(B_rad / (n / DmsRad.p)), B_rad).ToString("0.000")); } break; case 3: //复化科特斯算法 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_fc((int)(B_rad / (n / DmsRad.p)), B_rad).ToString("0.000")); } break; case 4: //龙贝格算法 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_r(n, B_rad).ToString("0.000")); } break; //case 5: case 6: //欧拉迭代公式 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_Ee(Convert.ToInt32(n), B_rad).ToString("0.000")); } break; case 7: //欧拉矫正公式 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_Epre(Convert.ToInt32(n), B_rad).ToString("0.000")); } break; case 8: //二阶龙格-库塔算法 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_RK2(Convert.ToInt32(n), B_rad).ToString("0.000")); } break; case 9: //龙贝格算法 listRes.Clear(); foreach (var item in list) { double B_rad = DmsRad.dms2rad(item.ToString()); listRes.Add(arc.X_RK4(Convert.ToInt32(n), B_rad).ToString("0.000")); } break; default: break; } //在ListView中显示与结果 if (cboxZMethod.SelectedIndex == 0) { Data.AddDataList(this.listLZ, listStr, list_c); } else { List <string> listDif = XZ_dif(listRes, list_c); Data.AddDataList(this.listLZ, listStr, listRes, listDif); } }