Ejemplo n.º 1
0
        /// <summary>
        /// 打开并读取数据文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenDataFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MyOpenFileDialog.InitialDirectory = Application.StartupPath;
            MyOpenFileDialog.Filter           = "txt file(*.txt)|*.txt"; // 文件类型过滤器设置为txt文件
            bool estiThroErrData = false;

            if (MyOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                string[] allText = File.ReadAllLines(MyOpenFileDialog.FileName, Encoding.UTF8); // 读取txt文件中全部的数据
                for (int i = 0; i < allText.Length - 1; i++)
                {
                    string[] rowText = allText[i].Replace(" ", "").Replace(",,", ",").Split(',');   // 每一行的数据
                    if (rowText[0] == "")
                    {
                        estiThroErrData = true;
                        i       = i + 1;
                        rowText = allText[i].Replace(" ", "").Replace(",,", ",").Split(',');        // 每一行的数据
                        ml      = Convert.ToDouble(rowText[0]);
                        mb      = AngleTransUtil.DegreeToRand(Convert.ToDouble(rowText[1]) / 3600); //将mb转成弧度
                        //ma = DegreeToRand(DMSToDegree(Convert.ToDouble(rowText[2])));
                        continue;
                    }
                    if (estiThroErrData)
                    {   // 贯通数据
                        bool          isDirEdge  = Convert.ToInt16(rowText[3]) == 1;
                        int           surveyNum  = Convert.ToInt16(rowText[4]);
                        TraversePoint startPoint = new TraversePoint(rowText);
                        startPoint.Pointindex = PointNum;
                        rowText = allText[i + 1].Replace(" ", "").Replace(",,", ",").Split(',');   // 每一行的数据
                        TraversePoint endPoint = new TraversePoint(rowText);
                        endPoint.Pointindex = PointNum + 1;
                        TraverseEdge traverEdge = new TraverseEdge(startPoint, endPoint, isDirEdge, surveyNum);
                        traverseEdge.Add(traverEdge);
                        PointNum++;
                    }
                    else
                    {
                        // 陀螺经纬仪观测数据
                        ObserveData obData = new ObserveData(rowText); // 观测数据
                        if (rowText[0] == "DM")
                        {                                              //地面
                            groundData.Add(obData);
                        }
                        if (rowText[0] == "JX")
                        {
                            //井下
                            downholeData.Add(obData);
                        }
                    }
                }
            }
            isReadData = true;
            InitState();
            // 更新表格数据
            InsertObDataIntoTable();
        }
Ejemplo n.º 2
0
        private void InitState()
        {
            //isCalGtroAzi = false;
            isCalma       = false;
            isEstiThroErr = false;
            DataTableGridView.Rows.Clear();
            ReportTextBox.Clear();

            /**
             * 初始化数据
             */
            //初始化陀螺边
            int gyroEdgeNum = 0;

            for (int i = 0; i < traverseEdge.Count; i++)
            {
                if (traverseEdge[i].IsGyroDirEdge)
                {
                    gyroEdge.Add(traverseEdge[i]);
                    gyroEdgeNum += 1;
                }
            }

            //初始化符合导线和支导线
            TraverseEdge tempTraverse = new TraverseEdge(); //符合导线
            bool         isstartEdge  = false;              //第一个边是否是陀螺边
            bool         isendEdge    = false;

            if (traverseEdge[0].IsGyroDirEdge)
            {
                isstartEdge             = true;
                tempTraverse.StartPoint = traverseEdge[0].EndPoint;
                tempTraverse.SurveyNum  = 1;
            }
            else
            {
                isstartEdge             = false;
                tempTraverse.StartPoint = traverseEdge[0].StartPoint;
            }
            for (int i = 0; i < traverseEdge.Count - 1; i++)
            {
                tempTraverse.SurveyNum += 1;
                //判断结束边是否是陀螺边
                if (traverseEdge[i].IsGyroDirEdge)
                {
                    isendEdge = true;
                    if (isstartEdge && isendEdge)
                    {
                        tempTraverse.EndPoint   = traverseEdge[i].StartPoint;
                        tempTraverse.SurveyNum -= 1;
                        connectTraverse.Add(tempTraverse);
                        isstartEdge             = true;
                        tempTraverse            = new TraverseEdge();
                        tempTraverse.StartPoint = traverseEdge[i].EndPoint;
                    }
                    else
                    {
                        tempTraverse.EndPoint   = traverseEdge[i].StartPoint;
                        tempTraverse.SurveyNum -= 1;
                        openTraverse.Add(tempTraverse);
                        isstartEdge             = true;
                        tempTraverse            = new TraverseEdge();
                        tempTraverse.StartPoint = traverseEdge[i].EndPoint;
                    }
                }
            }

            if (traverseEdge[traverseEdge.Count - 1].IsGyroDirEdge)
            {
                isendEdge = true;
                if (isstartEdge && isendEdge)
                {
                    tempTraverse.EndPoint = traverseEdge[traverseEdge.Count - 1].StartPoint;
                    connectTraverse.Add(tempTraverse);
                }
                else
                {
                    tempTraverse.EndPoint = traverseEdge[traverseEdge.Count - 1].EndPoint;
                    openTraverse.Add(tempTraverse);
                }
            }
            else
            {
                tempTraverse.SurveyNum += 1;
                tempTraverse.EndPoint   = traverseEdge[traverseEdge.Count - 1].EndPoint;
                openTraverse.Add(tempTraverse);
            }
        }