Ejemplo n.º 1
0
        internal static string ParameterAdjustment(List <string> col0, List <string> col1, List <string> col2, ref List <string> col4, ref List <string> col5, double[] accuracy, DataType.Data approximateDataType, DataType.LeftOrRight lorR, ref TableLayoutPanel tableLayoutPanel)
        {
            List <double> azimuth = new List <double>();

            for (int i = 0; i < col0.Count - 1; i++)
            {
                double deltaX = Convert.ToDouble(col1[i + 1]) - Convert.ToDouble(col1[i]);
                double deltaY = Convert.ToDouble(col2[i + 1]) - Convert.ToDouble(col2[i]);
                col4.Add(Math.Sqrt(Math.Abs(deltaX) * Math.Abs(deltaX) + Math.Abs(deltaY) * Math.Abs(deltaY)).ToString("#.000000"));
                TextBox txtSide = new TextBox();
                txtSide.Text        = col4[i];
                txtSide.Margin      = new Padding(0);
                txtSide.Width       = 60;
                txtSide.Height      = 21;
                txtSide.TextAlign   = HorizontalAlignment.Center;
                txtSide.BorderStyle = BorderStyle.None;
                tableLayoutPanel.Controls.Add(txtSide, 3, i + 2);
            }
            for (int i = 0; i < col0.Count - 1; i++)
            {
                double xf     = Convert.ToDouble(col1[i]);
                double xa     = Convert.ToDouble(col1[i + 1]);
                double yf     = Convert.ToDouble(col2[i]);
                double ya     = Convert.ToDouble(col2[i + 1]);
                double deltaX = Math.Round(xa - xf, 3);
                double deltaY = Math.Round(ya - yf, 3);
                double rian   = Math.Atan2(deltaY, deltaX);
                if (rian >= 0)
                {
                    azimuth.Add(rian);
                    col5.Add(ConvertAngle.DegreeToString(rian * 180 / Math.PI));
                }
                else
                {
                    azimuth.Add(2 * Math.PI + rian);
                    col5.Add(ConvertAngle.DegreeToString(360 + rian * 180 / Math.PI));
                }
                TextBox txtAngle = new TextBox();
                txtAngle.Text        = col5[i];
                txtAngle.Margin      = new Padding(0);
                txtAngle.Width       = 60;
                txtAngle.Height      = 21;
                txtAngle.TextAlign   = HorizontalAlignment.Center;
                txtAngle.BorderStyle = BorderStyle.None;
                tableLayoutPanel.Controls.Add(txtAngle, 4, i + 2);
            }
            string tempFile = Path.GetTempFileName();

            using (StreamWriter sw = new StreamWriter(tempFile))
            {
                sw.WriteLine("{0} {1} {2} {3} {4} {5}", col0.Count, 4, col0.Count - 2, (col0.Count - 2) * 2, col0.Count - 3, 1);
                sw.WriteLine("{0} {1} {2} {3}", accuracy[0], accuracy[1], accuracy[2], accuracy[3]);
                sw.WriteLine("{0} {1} {2}", col0[0], col1[0], col2[0]);
                sw.WriteLine("{0} {1} {2}", col0[1], col1[1], col2[1]);
                sw.WriteLine("{0} {1} {2}", col0[col0.Count - 2], accuracy[4], accuracy[5]);
                sw.WriteLine("{0} {1} {2}", col0[col0.Count - 1], col1[col1.Count - 1], col2[col2.Count - 1]);
                for (int i = 1; i < col0.Count - 1; i++)
                {
                    sw.WriteLine("{0} {1}", col0[i], 2);
                    sw.WriteLine("{0} {1}", col0[i - 1], 0);
                    sw.WriteLine("{0} {1}", col0[i + 1], Math.PI - azimuth[i - 1] + azimuth[i]);
                }
                for (int i = 1; i < col0.Count - 2; i++)
                {
                    sw.WriteLine("{0} {1} {2}", col0[i], col0[i + 1], col4[i]);
                }
                sw.WriteLine("{0} {1} {2}", col0[2], col0[3], azimuth[2]);
            }
            return(Adjustment.ParameterAdjustment.Calculate(tempFile));
        }
Ejemplo n.º 2
0
 internal static void GetData(string filePath, TableLayoutPanel tableLayoutPanel, ref double unitError, List <string> col0, List <string> col1, List <string> col2, List <string> col4, List <string> col5, ref List <string> col6, ref List <string> col7, ref List <string> col8, ref List <string> col9, ref List <string> col10, ref List <string> col11, ref List <string> col12, ref List <string> col13, ref List <string> col14, ref List <string> col15, ref List <string> col16, ref List <string> col17, ref List <string> col18)
 {
     using (StreamReader sr = new StreamReader(filePath))
     {
         string[] strSplit    = { " " };
         string[] strArrCol6  = new string[2];
         string[] strArrCol7  = new string[2];
         string[] strArrCol8  = new string[2];
         string[] strArrCol15 = new string[2];
         string[] strArrCol16 = new string[2];
         unitError = Convert.ToDouble(sr.ReadLine().Trim());//平差结果的第一行是单位权中误差,暂时不需要
         //这部分读取的是坐标平差值及其精度
         for (int i = 0; i < 2; i++)
         {
             string   strAdjCoord    = sr.ReadLine();
             string[] strArrAdjCoord = strAdjCoord.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
             col14.Add(strArrAdjCoord[2]);
             col15.Add(strArrAdjCoord[3]);
             col6.Add(strArrAdjCoord[4]);
             col7.Add(strArrAdjCoord[5]);
             col8.Add(strArrAdjCoord[6]);
         }
         for (int i = 0; i < 2; i++)
         {
             string   strAdjCoord    = sr.ReadLine();
             string[] strArrAdjCoord = strAdjCoord.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
             strArrCol15[i] = strArrAdjCoord[2];
             strArrCol16[i] = strArrAdjCoord[3];
             strArrCol6[i]  = strArrAdjCoord[4];
             strArrCol7[i]  = strArrAdjCoord[5];
             strArrCol8[i]  = strArrAdjCoord[6];
         }
         for (int i = 4; i < col0.Count; i++)
         {
             string   strAdjCoord    = sr.ReadLine();
             string[] strArrAdjCoord = strAdjCoord.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
             col14.Add(strArrAdjCoord[2]);
             col15.Add(strArrAdjCoord[3]);
             col6.Add(strArrAdjCoord[4]);
             col7.Add(strArrAdjCoord[5]);
             col8.Add(strArrAdjCoord[6]);
         }
         for (int i = 0; i < 2; i++)
         {
             col14.Add(strArrCol15[i]);
             col15.Add(strArrCol16[i]);
             col6.Add(strArrCol6[i]);
             col7.Add(strArrCol7[i]);
             col8.Add(strArrCol8[i]);
         }
         for (int i = 0; i < col0.Count - 2; i++)
         {
             string   strFront    = sr.ReadLine();
             string[] strArrFront = strFront.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
             string   strAfter    = sr.ReadLine();
             string[] strArrAfter = strAfter.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
             double   douAngle;
             double   douFront = Convert.ToDouble(strArrFront[4]);
             double   douAfter = Convert.ToDouble(strArrAfter[3]);
             if (i == 0)
             {
                 if (douFront > Math.PI)
                 {
                     col16.Add(ConvertAngle.RealDegreeToString((douFront - Math.PI) / Math.PI * 180));
                 }
                 else
                 {
                     col16.Add(ConvertAngle.RealDegreeToString((douFront + Math.PI) / Math.PI * 180));
                 }
                 col17.Add(Math.Round(Convert.ToDouble(strArrFront[6]), 4).ToString());
                 col9.Add("0");
                 col10.Add("0");
             }
             col16.Add(ConvertAngle.RealDegreeToString(douAfter / Math.PI * 180));
             col17.Add(Math.Round(Convert.ToDouble(strArrAfter[5]), 4).ToString());
             if (douAfter > douFront)
             {
                 douAngle = douAfter - douFront;
             }
             else
             {
                 douAngle = douAfter - douFront + 2 * Math.PI;
             }
             col18.Add(ConvertAngle.RealDegreeToString(douAngle / Math.PI * 180));
             col9.Add(Math.Round(Convert.ToDouble(strArrAfter[6]), 4).ToString());
             col10.Add(Math.Round(Convert.ToDouble(strArrAfter[4]), 3).ToString());
         }
         for (int i = 0; i < col0.Count - 2; i++)
         {
             sr.ReadLine();
         }
         for (int i = 0; i < col0.Count - 4; i++)
         {
             string   strEllipses    = sr.ReadLine();
             string[] strArrEllipses = strEllipses.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
             col11.Add(strArrEllipses[1]);
             col12.Add(strArrEllipses[2]);
             col13.Add(ConvertAngle.DegreeToString(Convert.ToDouble(strArrEllipses[3]) / Math.PI * 180));
         }
     }
     for (int i = 0; i < col0.Count; i++)
     {
         TextBox txtErr = new TextBox();
         txtErr.Text        = col8[i];
         txtErr.Margin      = new Padding(0);
         txtErr.Width       = 70;
         txtErr.Height      = 21;
         txtErr.TextAlign   = HorizontalAlignment.Center;
         txtErr.BorderStyle = BorderStyle.None;
         tableLayoutPanel.Controls.Add(txtErr, 5, i + 2);
         TextBox txtX = new TextBox();
         txtX.Text        = col14[i];
         txtX.Margin      = new Padding(0);
         txtX.Width       = 95;
         txtX.Height      = 21;
         txtX.TextAlign   = HorizontalAlignment.Center;
         txtX.BorderStyle = BorderStyle.None;
         tableLayoutPanel.Controls.Add(txtX, 6, i + 2);
         TextBox txtY = new TextBox();
         txtY.Text        = col15[i];
         txtY.Margin      = new Padding(0);
         txtY.Width       = 95;
         txtY.Height      = 21;
         txtY.TextAlign   = HorizontalAlignment.Center;
         txtY.BorderStyle = BorderStyle.None;
         tableLayoutPanel.Controls.Add(txtY, 7, i + 2);
     }
 }