Ejemplo n.º 1
0
        private void btnCal_Click(object sender, EventArgs e)
        {
            Angle  angle = new Angle();
            double b     = angle.GetArc(txtB.Text);
            double X     = Ellipsoid.c[0] * b + Ellipsoid.c[1] * Math.Sin(2 * b) + Ellipsoid.c[2] * Math.Sin(4 * b)
                           + Ellipsoid.c[3] * Math.Sin(6 * b) + Ellipsoid.c[4] * Math.Sin(8 * b) + Ellipsoid.c[5] * Math.Sin(10 * b);

            txtMeridianLength.Text = X.ToString();
        }
Ejemplo n.º 2
0
        private void GetPointData()
        {
            if (pointInfo != null || pointInfo.Count >= 0)
            {
                pointInfo.Clear();
            }

            if (fourDt != null)
            {
                fourDt.Clear();
                fourDt = null;
            }

            if (svnDt != null)
            {
                svnDt.Clear();
                svnDt = null;
            }


            Angle angle = new Angle();

            double[] XY = new double[2];

            OpenFileDialog ofg = new OpenFileDialog();//打开文件获取所有的原始坐标数据

            ofg.Filter = "文本文件|*.txt|所有文件|*.*";
            if (DialogResult.OK == ofg.ShowDialog()) //用户点击打开按钮
            {
                string filePath = ofg.FileName;      //获取用户选择的文件全路径。

                using (StreamReader sr = new StreamReader(filePath))
                {
                    //sr.ReadLine();//读取并舍去数据表头
                    while (!sr.EndOfStream)                                      //开始读取数据
                    {
                        string    strLines = sr.ReadLine();                      //用strLine去接收读取的数据
                        string[]  strLine  = strLines.Split(new char[] { ',' }); //用“,”将读取的数据分割开来
                        BLHAndXYZ Point    = new BLHAndXYZ();                    //创建一个点类对象
                        Point.PointName = strLine[0];
                        Point.BData     = Convert.ToDouble(strLine[1]);
                        Point.LData     = Convert.ToDouble(strLine[2]);
                        Point.HData     = Convert.ToDouble(strLine[3]);
                        Point.Bstr      = BLHOperate.NumToAngle(Point.BData);
                        Point.Lstr      = BLHOperate.NumToAngle(Point.LData);
                        Point.XData     = BLHOperate.GetXData(angle.GetArc(Point.BData.ToString()), angle.GetArc(Point.LData.ToString()), Point.HData);
                        Point.YData     = BLHOperate.GetYData(angle.GetArc(Point.BData.ToString()), angle.GetArc(Point.LData.ToString()), Point.HData);
                        Point.ZData     = BLHOperate.GetZData(angle.GetArc(Point.BData.ToString()), Point.HData);
                        pointInfo.Add(Point);

                        BLAndXY flatPoint = new BLAndXY();
                        flatPoint.PointName = strLine[0];
                        flatPoint.BData     = Convert.ToDouble(strLine[1]);
                        flatPoint.LData     = Convert.ToDouble(strLine[2]);
                        flatPoint.Bstr      = BLHOperate.NumToAngle(flatPoint.BData);
                        flatPoint.Lstr      = BLHOperate.NumToAngle(flatPoint.LData);
                        XY = BLHOperate.GetFlatXYData(angle.GetArc(flatPoint.BData.ToString()), flatPoint.LData, dhCBX.Text);
                        flatPoint.XData = XY[0];
                        flatPoint.YData = XY[1];

                        flatPoInfo.Add(flatPoint);
                    }
                }

                //初始化表格(列)。
                dt = new DataTable();                 //初始化表格
                dt.Columns.Add("点名", typeof(string)); //表头“点名”
                dt.Columns.Add("B", typeof(string));  //表头“B坐标”
                dt.Columns.Add("L", typeof(string));  //表头“L坐标”
                dt.Columns.Add("H", typeof(double));  //表头“H坐标”
                dt.Columns.Add("X", typeof(double));  //表头“X坐标”
                dt.Columns.Add("Y", typeof(double));  //表头“Y坐标”
                dt.Columns.Add("Z", typeof(double));  //表头“Z坐标”

                fourDt = new DataTable();
                fourDt.Columns.Add("点名", typeof(string));
                fourDt.Columns.Add("X", typeof(double));  //表头“Y坐标”
                fourDt.Columns.Add("Y", typeof(double));  //表头“Z坐标”
                fourDt.Columns.Add("X’", typeof(double)); //表头“Y坐标”
                fourDt.Columns.Add("Y’", typeof(double)); //表头“Z坐标”

                svnDt = new DataTable();
                svnDt.Columns.Add("点名", typeof(string));
                svnDt.Columns.Add("X", typeof(double));  //表头“Y坐标”
                svnDt.Columns.Add("Y", typeof(double));  //表头“Z坐标”
                svnDt.Columns.Add("Z", typeof(double));  //表头“Z坐标”
                svnDt.Columns.Add("X’", typeof(double)); //表头“Y坐标”
                svnDt.Columns.Add("Y’", typeof(double)); //表头“Z坐标”
                svnDt.Columns.Add("Z’", typeof(double)); //表头“Z坐标”

                //给表格添加行数据
                for (int i = 0; i < pointInfo.Count; i++)//遍历导入的点数据
                {
                    DataRow row  = dt.NewRow();
                    DataRow frow = fourDt.NewRow();
                    DataRow srow = svnDt.NewRow();

                    row["点名"] = pointInfo[i].PointName;
                    row["B"]  = pointInfo[i].Bstr;
                    row["L"]  = pointInfo[i].Lstr;
                    row["H"]  = pointInfo[i].HData;
                    row["X"]  = pointInfo[i].XData;
                    row["Y"]  = pointInfo[i].YData;
                    row["Z"]  = pointInfo[i].ZData;
                    dt.Rows.Add(row);

                    frow["点名"] = pointInfo[i].PointName;
                    frow["X"]  = pointInfo[i].XData;
                    frow["Y"]  = pointInfo[i].YData;
                    frow["X’"] = 0;
                    frow["Y’"] = 0;
                    fourDt.Rows.Add(frow);

                    srow["点名"] = pointInfo[i].PointName;
                    srow["X"]  = pointInfo[i].XData;
                    srow["Y"]  = pointInfo[i].YData;
                    srow["Z"]  = pointInfo[i].ZData;
                    srow["X’"] = 0;
                    srow["Y’"] = 0;
                    srow["Z’"] = 0;
                    svnDt.Rows.Add(srow);
                }

                dataGridView1.DataSource = null;
                dataGridView1.Columns.Clear();
                dataGridView1.Rows.Clear();
                dataGridView1.DataSource = dt;
                AutoSizeColumn(dataGridView1);
            }
            else
            {
                return;
            }
        }