二阶段12.14

  今天,我们设计了导线计算的窗口,同样增加了百度

和标准的查询按钮,还为其加入了数据的导入导出,加入

了等级的选择和限差的显示与判断,使数据判断简单化。

  图片:

程序:

private void 计算_Click(object sender, EventArgs e)
{
string[] sd = new string[dataGridView1.RowCount - 5];
double[] sdr = new double[sd.Length];
double[] cr = new double[sd.Length];
double x2, y2, x3, y3;
double sum = 0;
x2 = Convert.ToDouble(dataGridView1.Rows[1].Cells[12].Value);
y2 = Convert.ToDouble(dataGridView1.Rows[1].Cells[13].Value);
x3 = Convert.ToDouble(dataGridView1.Rows[sd.Length - 1].Cells[12].Value);
y3 = Convert.ToDouble(dataGridView1.Rows[sd.Length - 1].Cells[13].Value);
cr[0] = dmstorad(Convert.ToString(dataGridView1.Rows[0].Cells[4].Value));

double acd = dmstorad(Convert.ToString(dataGridView1.Rows[sd.Length - 1].Cells[4].Value));
for (int i = 1; i < sd.Length; i++)
{
sd[i] = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value);
sdr[i] = dmstorad(sd[i]);
}
sum = fangweijiao(sdr, cr);
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[1].Value = radtodms(sum);
double fd, fdx;

string str1 = comboBox1.Text;
string str2 = "图根导线";
string str3 = "一级导线";
string str4 = "二级导线";
string str5 = "三级导线";
string str6 = "四等导线";
string str7 = "测量等级";

if (str1.Equals(str7, StringComparison.OrdinalIgnoreCase) == true)
{
MessageBox.Show("请选择导线等级!");
fdx = 0;
}
else if(str1.Equals(str2, StringComparison.OrdinalIgnoreCase) == true)
{
fdx = 60 * Math.Sqrt(sd.Length - 1);
}
else if (str1.Equals(str3, StringComparison.OrdinalIgnoreCase) == true)
{
fdx = 10 * Math.Sqrt(sd.Length - 1);
}
else if (str1.Equals(str4, StringComparison.OrdinalIgnoreCase) == true)
{
fdx = 16 * Math.Sqrt(sd.Length - 1);
}
else if (str1.Equals(str5, StringComparison.OrdinalIgnoreCase) == true)
{
fdx = 24 * Math.Sqrt(sd.Length - 1);

}
else if (str1.Equals(str6, StringComparison.OrdinalIgnoreCase) == true)
{
fdx = 5 * Math.Sqrt(sd.Length - 1);
}
else
{
fdx = 3.6 * Math.Sqrt(sd.Length - 1);
}
fd = cr[cr.Length - 1] - acd;

dataGridView1.Rows[dataGridView1.RowCount - 3].Cells[1].Value =
Convert.ToString(Math.Round(fd * 180 / Math.PI * 3600, 2)) + "″";
dataGridView1.Rows[dataGridView1.RowCount - 2].Cells[1].Value =
Convert.ToString(Math.Round(fdx, 2)) + "″";

if (Math.Abs(fd * 180 / Math.PI * 3600) > fdx)
{
textBox3.Text = "角度闭合差超限!";
}
else
{
textBox3.Text = "角度闭合差合格";

double vd = -fd / (sd.Length - 1);
double sumvd = 0;
for (int i = 1; i < sd.Length; i++)
{
sdr[i] += vd;
sumvd += vd;
dataGridView1.Rows[i].Cells[2].Value =Convert.ToString(Math.Round(vd * 180 / Math.PI * 3600, 2)) + "″";
dataGridView1.Rows[i].Cells[3].Value = radtodms(sdr[i]);
}
if (Math.Round(sumvd, 8) != Math.Round(-fd, 8))
MessageBox.Show("角度改正数分配有误!");
else
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[2].Value =Convert.ToString(Math.Round(sumvd * 180 / Math.PI * 3600, 2)) + "″";
sum = fangweijiao(sdr, cr);
if (Math.Round(cr[cr.Length - 1], 8) != Math.Round(acd, 8))
MessageBox.Show("坐标方位角推算有误!");
else
{
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[3].Value =radtodms(sum);
for (int i = 0; i < sd.Length; i++)
dataGridView1.Rows[i].Cells[4].Value = radtodms(cr[i]);
}
//坐标计算与调整
double[] juli = new double[sd.Length - 1];
double[] dx = new double[sd.Length - 1];
double[] dy = new double[sd.Length - 1];
double[] vx = new double[sd.Length - 1];
double[] vy = new double[sd.Length - 1];
double[] cx = new double[sd.Length - 1];
double[] cy = new double[sd.Length - 1];
double[] x = new double[sd.Length - 1];
double[] y = new double[sd.Length - 1];
double sumjuli = 0;
double sumdx = 0;
double sumdy = 0;
double fx, fy, fxy, k1;
double sumvx = 0;
double sumvy = 0;
double sumcx = 0;
double sumcy = 0;
for (int i = 1; i < juli.Length; i++)
{
juli[i] = Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value);
sumjuli += juli[i];
dx[i] = juli[i] * Math.Cos(cr[i]);
dy[i] = juli[i] * Math.Sin(cr[i]);
sumdx += dx[i];
sumdy += dy[i];
dataGridView1.Rows[i].Cells[6].Value = Convert.ToString(Math.Round(dx[i], 3));
dataGridView1.Rows[i].Cells[7].Value = Convert.ToString(Math.Round(dy[i], 3));
}
x[1] = x2;
y[1] = y2;
fx = sumdx - (x3 - x2);
fy = sumdy - (y3 - y2);
fxy = Math.Sqrt(fx * fx + fy * fy);
k1 = sumjuli / fxy;
double xiancha = 0.0;
if (str1.Equals(str6, StringComparison.OrdinalIgnoreCase) == true)
{xiancha=35000;}
else if (str1.Equals(str2, StringComparison.OrdinalIgnoreCase) == true)
{xiancha = 2000;}
else if (str1.Equals(str3, StringComparison.OrdinalIgnoreCase) == true)
{xiancha = 15000;}
else if (str1.Equals(str4, StringComparison.OrdinalIgnoreCase) == true)
{xiancha = 10000;}
else if (str1.Equals(str5, StringComparison.OrdinalIgnoreCase) == true)
{ xiancha = 5000;}
else if (str1.Equals(str7, StringComparison.OrdinalIgnoreCase) == true)
{xiancha = 55000;}
else
{xiancha = 1000000000000000000000000000000000000000000000.0;}
if (k1> xiancha )
{
textBox3.AppendText("\r\n");
textBox3.AppendText("导线全长相对闭合差合格");
}
else
{
textBox3.AppendText("\r\n");
textBox3.AppendText("导线全长相对闭合差超限!");
}
for (int j = 1; j <= vx.Length - 1; j++)
{
vx[j] = -fx * juli[j] / sumjuli;
vy[j] = -fy * juli[j] / sumjuli;
sumvx += vx[j];
sumvy += vy[j];
dataGridView1.Rows[j].Cells[8].Value = Convert.ToString(Math.Round(vx[j], 4));//将坐标增量改正数放入表格
dataGridView1.Rows[j].Cells[9].Value = Convert.ToString(Math.Round(vy[j], 4));

cx[j] = dx[j] + vx[j];
cy[j] = dy[j] + vy[j];
sumcx += cx[j];
sumcy += cy[j];
dataGridView1.Rows[j].Cells[10].Value = Convert.ToString(Math.Round(cx[j], 3));
dataGridView1.Rows[j].Cells[11].Value = Convert.ToString(Math.Round(cy[j], 3));
}
if (Math.Round(sumvx, 4) != Math.Round(-fx, 4) || Math.Round(sumvy, 4) != Math.Round(-fy, 4))
MessageBox.Show("坐标增量分配有错误!");
if (Math.Round(sumcx, 4) != Math.Round(x3 - x2, 4) || Math.Round(sumcy, 4) != Math.Round(y3 - y2, 4))
MessageBox.Show("改正后坐标增量计算有错误!");
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[8].Value = Convert.ToString(Math.Round(sumvx, 3));
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[9].Value = Convert.ToString(Math.Round(sumvy, 3));
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[10].Value = Convert.ToString(Math.Round(sumcx, 3));
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[11].Value = Convert.ToString(Math.Round(sumcy, 3));
for (int j = 1; j < x.Length - 1; j++)
{
x[j + 1] = x[j] + cx[j];
y[j + 1] = y[j] + cy[j];
dataGridView1.Rows[j + 1].Cells[12].Value = Convert.ToString(Math.Round(x[j + 1], 3));
dataGridView1.Rows[j + 1].Cells[13].Value = Convert.ToString(Math.Round(y[j + 1], 3));
}

if (Math.Round(x[x.Length - 1] + cx[cx.Length - 1], 3) != Math.Round(x3, 3) || Math.Round
(y[y.Length - 1] + cy[cy.Length - 1], 3) != Math.Round(y3, 3)) MessageBox.Show("坐标计算有错误!");

dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[5].Value = Convert.ToString(sumjuli);
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[6].Value = Convert.ToString(Math.Round(sumdx, 3));
dataGridView1.Rows[dataGridView1.RowCount - 4].Cells[7].Value = Convert.ToString(Math.Round(sumdy, 3));
dataGridView1.Rows[dataGridView1.RowCount - 3].Cells[7].Value = Convert.ToString(Math.Round(fx, 3));
dataGridView1.Rows[dataGridView1.RowCount - 2].Cells[7].Value = Convert.ToString(Math.Round(fy, 3));
dataGridView1.Rows[dataGridView1.RowCount - 3].Cells[10].Value = Convert.ToString(Math.Round(fxy, 3));
dataGridView1.Rows[dataGridView1.RowCount - 2].Cells[11].Value = Convert.ToString(Math.Round(k1, 0));

}
}

猜你喜欢

转载自www.cnblogs.com/wtctd/p/10121556.html