高斯投影正反算及邻带换算

时间:2022-04-15 16:15:17
【文件属性】:

文件名称:高斯投影正反算及邻带换算

文件大小:5KB

文件格式:CS

更新时间:2022-04-15 16:15:17

c#

话不多说,直接上代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace _高斯投影 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } double DD2RAD(double n) { double DD; double MM; double SS; DD = Math.Floor(n); MM = Math.Floor((n - DD) * 100); SS = ((n - DD) * 100 - MM) * 100; n = (DD + MM / 60.0 + SS / 3600.0) * Math.PI / 180.0; return n; } private void Form2_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { double B, L; B = double.Parse(textBox1.Text); B = DD2RAD(B); L = double.Parse(textBox2.Text); L = DD2RAD(L); double L0 = double.Parse(textBox3.Text); L0 = DD2RAD(L0); double a = double.Parse(textBoxa.Text); double e2 = double.Parse(textBoxe2.Text); double A = 1.0 + 3.0 * e2 / 4 + 45.0 * e2 * e2 / 64 + 175.0 * Math.Pow(e2, 3) / 256 + 11025.0 * Math.Pow(e2, 4) / 16384 + 43659.0 * Math.Pow(e2, 5) / 65536; double B0 = 3.0 * e2 / 4 + 15.0 * e2 * e2 / 16 + 525.0 * Math.Pow(e2, 3) / 512 + 2205.0 * Math.Pow(e2, 4) / 2048 + 72765.0 * Math.Pow(e2, 5) / 65536; double C = 15.0 * e2 * e2 / 64 + 105.0 * Math.Pow(e2, 3) / 256 + 2205.0 * Math.Pow(e2, 4) / 4096 + 10395.0 * Math.Pow(e2, 5) / 16384; double D = 35.0 * Math.Pow(e2, 3) / 512 + 315.0 * Math.Pow(e2, 4) / 2048 + 31185.0 * Math.Pow(e2, 5) / 131072; double α = A * a * (1 - e2);//α double β = -B0 * a * (1 - e2) / 2.0;//β double γ = C * a * (1 - e2) / 4.0; double σ = -D * a * (1 - e2) / 6.0; double X = α * B + β * Math.Sin(2 * B) + γ * Math.Sin(4 * B) + σ * Math.Sin(6 * B);//数值X double N; N = a / Math.Sqrt((1 - e2 * Math.Pow(Math.Sin(B), 2))); double q = e2 / (1 - e2); //E'2 double c = q * Math.Pow(Math.Cos(B), 2);//n2 double t = Math.Tan(B); double l = L - L0; double x = X + N * Math.Sin(B) * Math.Cos(B) * l * l / 2.0 + N * Math.Sin(B) * Math.Pow(Math.Cos(B), 3) * Math.Pow(l, 4) * (5 - t * t + 9 * c + 4 * Math.Pow(c, 2)) / 24.0 + N * Math.Sin(B) * Math.Pow(Math.Cos(B), 5) * Math.Pow(l, 6) * (61 - 58 * t * t + Math.Pow(t, 4) + 270 * c - 330 * c * Math.Pow(t, 2)) / 720.0; double y = N * Math.Cos(B) * l + N * Math.Pow(Math.Cos(B), 3) * (1 - t * t + c) * Math.Pow(l, 3) / 6.0 + N * Math.Pow(Math.Cos(B), 5) * (5 - 18 * t * t + Math.Pow(t, 4) + 14 * c - 58 * c * t * t) * Math.Pow(l, 5) / 120.0; x = Math.Round(x, 6); y = Math.Round(y, 6); double o = double.Parse(textBox6.Text); double P = y + 500000 + o * 1000000; textBox4.Text = x.ToString(); textBox5.Text = P.ToString(); } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox2.Text == "BJ54") { double a = 6378245; double e2 = 0.006693421622966; textBoxa.Text = Convert.ToString(a); textBoxe2.Text = Convert.ToString(e2); } if (comboBox2.Text == "XA80") { double a = 6378140; double e2 = 0.006694384999588; textBoxa.Text = Convert.ToString(a); textBoxe2.Text = Convert.ToString(e2); } if (comboBox2.Text == "WGS84") { double a = 6378137; double e2 = 0.00669437999013; textBoxa.Text = Convert.ToString(a); textBoxe2.Text = Convert.ToString(e2); } if (comboBox2.Text == "CGCS2000") { double a = 6378137; double e2 = 0.00669438002290; textBoxa.Text = Convert.ToString(a); textBoxe2.Text = Convert.ToString(e2); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { double o = 0.0; double LL = double.Parse(textBox2.Text); double L0 = 0.0; if (comboBox1.Text == "6度带") { o = Math.Floor(LL / 6.0) + 1; L0 = 6 * o - 3; textBox6.Text = Convert.ToString(o); textBox3.Text = Convert.ToString(L0); } if (comboBox1.Text == "3度带") { o = LL / 3.0; o = Math.Round(o, 0); L0 = 3 * o; textBox6.Text = Convert.ToString(o); textBox3.Text = Convert.ToString(L0); } } private void label9_Click(object sender, EventArgs e) { } } } 仅为正算,正反算请联系博主,谢谢。


网友评论