Beispiel #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox3.Text != null && textBox8.Text != null && (radioButton2.Checked || radioButton1.Checked))
     {
         try
         {
             double x        = double.Parse(textBox3.Text.Trim());
             double y1       = double.Parse(textBox8.Text.Trim());
             double y        = y1 - (Math.Floor(y1 / 1000000)) * 1000000 - 500000;
             double B        = 0;
             double L        = 0;
             double left_x   = 0;
             double left_y   = 0;
             double left_y1  = 0;
             double right_x  = 0;
             double right_y  = 0;
             double right_y1 = 0;
             double L0       = 0;
             int    n        = 0;
             if (radioButton1.Checked)
             {
                 L0 = (Math.Floor(y1 / 1000000.0) * 3) * Math.PI / 180.0;
                 Caculate.Gauss_To(Form1.el, ref B, ref L, x, y, L0);
                 n  = (int)((L * 180 / Math.PI - 1.5) / 3) + 1;
                 L0 = (3 * n) * Math.PI / 180;
                 Caculate.To_Gauss(Form1.el, B, L, ref right_x, ref right_y, L0 + 3.0 / 180 * Math.PI);
                 if (L <= 1.5 && L >= 0)
                 {
                     right_y1 = 120 * 1000000 + 500000 + right_y;
                 }
                 else
                 {
                     right_y1 = (n + 1) * 1000000 + 500000 + right_y;
                 }
                 Caculate.To_Gauss(Form1.el, B, L, ref left_x, ref left_y, L0 - 3.0 / 180 * Math.PI);
                 if (L <= 1.5 && L >= 0)
                 {
                     left_y1 = 120 * 1000000 + 500000 + left_y;
                 }
                 else
                 {
                     left_y1 = (n - 1) * 1000000 + 500000 + left_y;
                 }
             }
             if (radioButton2.Checked)
             {
                 L0 = (Math.Floor(y1 / 1000000.0) * 6 - 3) * Math.PI / 180.0;
                 Caculate.Gauss_To(Form1.el, ref B, ref L, x, y, L0);
                 n  = (int)(L * 180 / Math.PI / 6) + 1;
                 L0 = (6 * n - 3) * Math.PI / 180;
                 Caculate.To_Gauss(Form1.el, B, L, ref right_x, ref right_y, L0 + 6.0 / 180 * Math.PI);
                 if (L == 0)
                 {
                     right_y1 = 60 * 1000000 + 500000 + right_y;
                 }
                 else
                 {
                     right_y1 = (n + 1) * 1000000 + 500000 + right_y;
                 }
                 Caculate.To_Gauss(Form1.el, B, L, ref left_x, ref left_y, L0 - 6.0 / 180 * Math.PI);
                 if (L == 0)
                 {
                     left_y1 = 60 * 1000000 + 500000 + left_y;
                 }
                 else
                 {
                     left_y1 = (n - 1) * 1000000 + 500000 + left_y;
                 }
             }
             textBox5.Text  = left_x.ToString("f4");
             textBox4.Text  = left_y1.ToString("f4");
             textBox10.Text = right_x.ToString("f4");
             textBox9.Text  = right_y1.ToString("f4");
             call           = true;
             Form1.report   = null;
             Form1.report   = getreportstr(call);
         }
         catch
         {
             MessageBox.Show("请输入有效数据!");
             return;
         }
     }
 }
Beispiel #2
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            int[] num = new int[Row_count];
            int   j   = 0;

            if (el.a == 0)
            {
                MessageBox.Show("请选择椭球参数!");
                toolStripStatusLabel1.Text = "未选择椭球!";
                return;
            }
            in_data = new List <Data>();
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                Data data = new Data();
                if (dataGridView1[1, i].Value.ToString() != "" && dataGridView1[3, i].Value.ToString() != "" && dataGridView1[2, i].Value.ToString() != "")
                {
                    data.Name = dataGridView1[0, i].Value.ToString().Trim();
                    data.XY.X = double.Parse(dataGridView1[1, i].Value.ToString().Trim());
                    data.XY.Y = double.Parse(dataGridView1[2, i].Value.ToString().Trim());
                    data.Yi   = double.Parse(dataGridView1[3, i].Value.ToString().Trim());
                    in_data.Add(data);
                    num[j] = i; j++;
                }
                else if ((dataGridView1[1, i].Value.ToString() == "" && dataGridView1[3, i].Value.ToString() != "") || (dataGridView1[1, i].Value.ToString() != "" && dataGridView1[3, i].Value.ToString() == ""))
                {
                    MessageBox.Show("输入数据不完整!");
                    toolStripStatusLabel1.Text = "输入数据不完整!";
                    return;
                }
            }
            if (度带坐标转6度带坐标ToolStripMenuItem.Checked)
            {
                try
                {
                    for (int i = 0; i < in_data.Count; i++)
                    {
                        double B = 0;
                        double L = 0;
                        double x = 0, y = 0, yi = 0;
                        double L0       = 0;
                        int    n        = 0;
                        Data   out_data = new Data();
                        L0 = (Math.Floor(in_data[i].Yi / 1000000.0) * 3) * Math.PI / 180.0;
                        Caculate.Gauss_To(el, ref B, ref L, in_data[i].XY.X, in_data[i].XY.Y, L0);
                        n  = (int)(L * 180 / Math.PI / 6) + 1;
                        L0 = (6 * n - 3) * Math.PI / 180;
                        Caculate.To_Gauss(el, B, L, ref x, ref y, L0);
                        if (L == 0)
                        {
                            yi = 60 * 1000000 + 500000 + y;
                        }
                        else
                        {
                            yi = n * 1000000 + 500000 + y;
                        }
                        out_data.Name = in_data[i].Name;
                        out_data.XY.X = x;
                        out_data.XY.Y = y;
                        out_data.Yi   = yi;
                        Result.Add(out_data);
                        dataGridView1[4, i].Value = x.ToString("f6");
                        dataGridView1[5, i].Value = y.ToString("f6");
                        dataGridView1[6, i].Value = yi.ToString("f6");
                        call = true;
                        toolStripStatusLabel1.Text = "计算成功!";
                    }
                }
                catch
                {
                    MessageBox.Show("请输入有效数据!");
                    toolStripStatusLabel1.Text = "数据无效!";
                    return;
                }
            }
            else if (度带坐标转3度带坐标ToolStripMenuItem.Checked)
            {
                try
                {
                    for (int i = 0; i < in_data.Count; i++)
                    {
                        double B = 0;
                        double L = 0;
                        double x = 0, y = 0, yi = 0;
                        double L0       = 0;
                        int    n        = 0;
                        Data   out_data = new Data();
                        L0 = (Math.Floor(in_data[i].Yi / 1000000.0) * 6 - 3) * Math.PI / 180.0;
                        Caculate.Gauss_To(el, ref B, ref L, in_data[i].XY.X, in_data[i].XY.Y, L0);
                        n  = (int)((L * 180 / Math.PI - 1.5) / 3) + 1;
                        L0 = (3 * n) * Math.PI / 180;
                        Caculate.To_Gauss(el, B, L, ref x, ref y, L0);
                        if (L <= 1.5 && L >= 0 && is3 == 3)
                        {
                            yi = 120 * 1000000 + 500000 + y;
                        }
                        else
                        {
                            yi = n * 1000000 + 500000 + y;
                        }
                        out_data.Name = in_data[i].Name;
                        out_data.XY.X = x;
                        out_data.XY.Y = y;
                        out_data.Yi   = yi;
                        Result.Add(out_data);
                        dataGridView1[4, i].Value = x.ToString("f6");
                        dataGridView1[5, i].Value = y.ToString("f6");
                        dataGridView1[6, i].Value = yi.ToString("f6");
                        call = true;
                        toolStripStatusLabel1.Text = "计算成功!";
                    }
                }
                catch
                {
                    MessageBox.Show("请输入有效数据!");
                    toolStripStatusLabel1.Text = "输入数据无效!";
                    return;
                }
            }
            else
            {
                MessageBox.Show("请先选择功能!");
                toolStripStatusLabel1.Text = "未选择功能!";
                return;
            }
            report = null;
            report = getreportstr(call);
        }