public DataTable ToDataTable()//和第一句一样? //DataTable表示内存中数据的一个表 { DataTable table = InitTable(); try { foreach (var d in Data) { DataRow row = table.NewRow(); //Class.system.data.datarow:表示行中的数据Datatable row["Name"] = d.Name; row["X"] = $"{d.X:f3}"; row["Y"] = $"{d.Y:f3}"; row["Z"] = $"{d.Z:f3}"; row["B"] = GeoPro.Rad2Str(d.B); row["L"] = GeoPro.Rad2Str(d.L); row["H"] = $"{d.H:f3}"; row["x"] = $"{d.x:f3}"; row["y"] = $"{d.y:f3}"; table.Rows.Add(row); } } catch (Exception) { } return(table); }
string BL2xy() { string res = string.Format("\r\n高斯正算(BL-->xy)\r\n"); res += "--------------------------------------\r\n"; res += string.Format("{0,-5} {1,12} {2,12}", "点名", "B", "L"); res += string.Format(" {0,10:f4} {1,10:f4} \r\n", "x", "y"); Gauss pos = new Gauss(Obs.Datum, Obs.L0); double x, y; for (int i = 0; i < Obs.Data.Count; i++) { double B = Obs.Data[i].B; double L = Obs.Data[i].L; pos.BL2xy(B, L, out x, out y); Obs.Data[i].x = x; Obs.Data[i].y = y; res += string.Format("{0,-5} {1,12} {2,12}", Obs.Data[i].Name, GeoPro.Rad2Str(B), GeoPro.Rad2Str(L)); res += string.Format(" {0,10:f4} {1,10:f4}\r\n", x, y); } return(res); }
string XYZ2BLH() { string res = string.Format("\r\n空间坐标(XYZ)转换为大地坐标(BLH)\r\n"); res += "--------------------------------------\r\n"; res += string.Format("{0,-5}{1,15:f4}{2,15:f4}{3,15:f4}", "点名", "X", "Y", "Z"); res += string.Format("{0,15}{1,15}{2,8:f4}\r\n", "B", "L", " H"); Position pos = new Position(Obs.Datum); double B, L, H; for (int i = 0; i < Obs.Data.Count; i++) { double X = Obs.Data[i].X + 1000.0; //+1000 double Y = Obs.Data[i].Y + 1000.0; //+1000 double Z = Obs.Data[i].Z + 1000.0; //+1000 pos.CartesianToGeodetic(X, Y, Z, out B, out L, out H); res += string.Format("{0,-5}{1,15:f4}{2,15:f4}{3,15:f4}", Obs.Data[i].Name, X, Y, Z); res += string.Format("{0,15}{1,15}{2,10:f4}\r\n", GeoPro.Rad2Str(B), GeoPro.Rad2Str(L), H); } return(res); }
string BLH2XYZ() { string res = string.Format("\r\n大地坐标(BLH)转换为空间坐标(XYZ)\r\n"); res += "--------------------------------------\n"; res += string.Format("{0,-5}{1,10}{2,15}{3,8:f4}", "点名", "B", "L", " H"); res += string.Format("{0,15:f4} {1,15:f4}{2,15:f4}\r\n", "X", "Y", "Z"); Position pos = new Position(Obs.Datum); double X, Y, Z; for (int i = 0; i < Obs.Data.Count; i++) { double B = Obs.Data[i].B; double L = Obs.Data[i].L; double H = Obs.Data[i].H; pos.GeodeticToCartesian(B, L, H, out X, out Y, out Z); Obs.Data[i].X = X; Obs.Data[i].Y = Y; Obs.Data[i].Z = Z; res += string.Format("{0,-5}{1,15}{2,15}{3,10:f4}", Obs.Data[i].Name, GeoPro.Rad2Str(B), GeoPro.Rad2Str(L), H); res += string.Format("{0,15:f4}{1,15:f4}{2,15:f4}\r\n", X, Y, Z); } return(res); }
public DataTable ToDataTable() { DataTable table = InitTable(); try { foreach (var d in Data) { DataRow row = table.NewRow(); row["Name"] = d.Name; row["X"] = $"{d.X:f3}"; row["Y"] = $"{d.Y:f3}"; row["Z"] = $"{d.Z:f3}"; row["B"] = GeoPro.Rad2Str(d.B); row["L"] = GeoPro.Rad2Str(d.L); row["H"] = $"{d.H:f3}"; row["x(平面)"] = $"{d.x:f3}"; row["y(平面)"] = $"{d.y:f3}"; table.Rows.Add(row); } } catch (Exception) { } return(table); }
public int Zone; //带号 public override string ToString() { string line = string.Format("{0,-5}{1,15:f3}{2,15:f3}{3,15:f3}", Name, X, Y, Z); line += string.Format("{0,15}{1,15} {2,8:f4}", GeoPro.Rad2Str(B), GeoPro.Rad2Str(L), H); line += string.Format("{0,15:f3} {1,15:f3}", x, y); return(line); }
public static ObsData ReadFile(string filepath) { ObsData data = new ObsData(); try { string line; string[] strs; StreamReader sr = new StreamReader(filepath); //读椭球参数 line = sr.ReadLine(); strs = line.Split(','); double a = double.Parse(strs[1]); //因为str[0]等于a line = sr.ReadLine(); strs = line.Split(','); double invF = double.Parse(strs[1]); //同理[0]为1/f var ell = new Ellipsoid(a, invF); data.Datum = ell; line = sr.ReadLine(); strs = line.Split(','); data.L0 = GeoPro.Dms2Rad(double.Parse(strs[1])); line = sr.ReadLine(); PointInfo p; //方法调用?数据类型声明?定义?创建实例? while ((line = sr.ReadLine()) != null) { p = new PointInfo();//创建实例的一种方式? strs = line.Split(','); p.Name = strs[0]; p.B = GeoPro.Dms2Rad(double.Parse(strs[1])); p.L = GeoPro.Dms2Rad(double.Parse(strs[2])); p.H = double.Parse(strs[3]); data.Data.Add(p); } } catch (Exception ex) { throw ex; } return(data); }
string xy2BL() { string res = string.Format("\r\n高斯反算(xy-->BL)\r\n"); res += "--------------------------------------\r\n"; res += string.Format("{0,-5} {1,10:f4} {2,10:f4}", "点名", "x", "y"); res += string.Format(" {0,12} {1,12}\r\n", "B", "L"); Gauss pos = new Gauss(Obs.Datum, Obs.L0); double B, L; for (int i = 0; i < Obs.Data.Count; i++) { Obs.Data[i].B = 0; Obs.Data[i].L = 0; double x = Obs.Data[i].x + 500.0; //+500 double y = Obs.Data[i].y + 500.0; //+500 pos.xy2BL(x, y, out B, out L); res += string.Format("{0,-5} {1,10:f4} {2,10:f4}", Obs.Data[i].Name, x, y); res += string.Format(" {0,15} {1,15}\r\n ", GeoPro.Rad2Str(B), GeoPro.Rad2Str(L)); } return(res); }