Exemple #1
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         LocalCartesian p = new LocalCartesian();
         p = new LocalCartesian(new Geocentric());
         p = new LocalCartesian(32.0, -86.0, 45.0);
         p = new LocalCartesian(32.0, -86.0, 45.0, new Geocentric());
         double x, y, z, x1, y1, z1;
         double[,] rot;
         p.Forward(32.0, -86.0, 45.0, out x, out y, out z, out rot);
         p.Forward(32.0, -86.0, 45.0, out x1, out y1, out z1);
         if (x != x1 || y != y1 || z != z1)
         {
             throw new Exception("Error in Forward");
         }
         double lat, lon, alt;
         p.Reverse(x, y, z, out lat, out lon, out alt, out rot);
         p.Reverse(x, y, z, out x1, out y1, out z1);
         if (lat != x1 || lon != y1 || alt != z1)
         {
             throw new Exception("Error in Reverse");
         }
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 static void Main(string[] args)
 {
     try {
         Geocentric earth = new Geocentric();
         const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
         LocalCartesian proj = new LocalCartesian(lat0, lon0, 0, earth);
         {
             // Sample forward calculation
             double lat = 50.9, lon = 1.8, h = 0; // Calais
             double x, y, z;
             proj.Forward(lat, lon, h, out x, out y, out z);
             Console.WriteLine(String.Format("{0} {1} {2}", x, y, z));
         }
         {
             // Sample reverse calculation
             double x = -38e3, y = 230e3, z = -4e3;
             double lat, lon, h;
             proj.Reverse(x, y, z, out lat, out lon, out h);
             Console.WriteLine(String.Format("{0} {1} {2}", lat, lon, h));
         }
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
Exemple #3
0
 static void Main(string[] args)
 {
     try {
         Geocentric     earth = new Geocentric();
         const double   lat0 = 48 + 50 / 60.0, lon0 = 2 + 20 / 60.0; // Paris
         LocalCartesian proj = new LocalCartesian(lat0, lon0, 0, earth);
         {
             // Sample forward calculation
             double lat = 50.9, lon = 1.8, h = 0; // Calais
             double x, y, z;
             proj.Forward(lat, lon, h, out x, out y, out z);
             Console.WriteLine(String.Format("{0} {1} {2}", x, y, z));
         }
         {
             // Sample reverse calculation
             double x = -38e3, y = 230e3, z = -4e3;
             double lat, lon, h;
             proj.Reverse(x, y, z, out lat, out lon, out h);
             Console.WriteLine(String.Format("{0} {1} {2}", lat, lon, h));
         }
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
        public void Should_ConvertXYToLatLon()
        {
            var proj = new LocalCartesian(lat0, lon0);

            var length = xy.Length;

            for (int i = 0; i < length - 1; i += 2)
            {
                var x = xy[i];
                var y = xy[i + 1];

                double lat, lon, h;
                proj.Reverse(x, y, 0, out lat, out lon, out h);

                Assert.AreEqual(latlon[i], lat, TOLERANCE);
                Assert.AreEqual(latlon[i + 1], lon, TOLERANCE);
            }
        }
Exemple #5
0
        private void OnConvert(object sender, EventArgs e)
        {
            try
            {
                double lat, lon, alt, x, y, z;
                double[,] rot = null;
                switch (m_function)
                {
                case Functions.Forward:
                    lat = Double.Parse(m_latTextBox.Text);
                    lon = Double.Parse(m_lonTextBox.Text);
                    alt = Double.Parse(m_altTextBox.Text);
                    m_lc.Forward(lat, lon, alt, out x, out y, out z, out rot);
                    m_XTextBox.Text = x.ToString("0.00###");
                    m_YTextBox.Text = y.ToString("0.00###");
                    m_ZTextBox.Text = z.ToString("0.00###");
                    break;

                case Functions.Reverse:
                    x = Double.Parse(m_XTextBox.Text);
                    y = Double.Parse(m_YTextBox.Text);
                    z = Double.Parse(m_ZTextBox.Text);
                    m_lc.Reverse(x, y, z, out lat, out lon, out alt, out rot);
                    m_latTextBox.Text = lat.ToString();
                    m_lonTextBox.Text = lon.ToString();
                    m_altTextBox.Text = alt.ToString();
                    break;
                }
                m_textBox00.Text = rot[0, 0].ToString("#.000000000000");
                m_textBox01.Text = rot[0, 1].ToString("#.000000000000");
                m_textBox02.Text = rot[0, 2].ToString("#.000000000000");
                m_textBox10.Text = rot[1, 0].ToString("#.000000000000");
                m_textBox11.Text = rot[1, 1].ToString("#.000000000000");
                m_textBox12.Text = rot[1, 2].ToString("#.000000000000");
                m_textBox20.Text = rot[2, 0].ToString("#.000000000000");
                m_textBox21.Text = rot[2, 1].ToString("#.000000000000");
                m_textBox22.Text = rot[2, 2].ToString("#.000000000000");
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         LocalCartesian p = new LocalCartesian();
         p = new LocalCartesian(new Geocentric());
         p = new LocalCartesian(32.0, -86.0, 45.0);
         p = new LocalCartesian(32.0, -86.0, 45.0, new Geocentric());
         double x, y, z, x1, y1, z1;
         double[,] rot;
         p.Forward(32.0, -86.0, 45.0, out x, out y, out z, out rot);
         p.Forward(32.0, -86.0, 45.0, out x1, out y1, out z1);
         if (x != x1 || y != y1 || z != z1)
             throw new Exception("Error in Forward");
         double lat, lon, alt;
         p.Reverse(x, y, z, out lat, out lon, out alt, out rot);
         p.Reverse(x, y, z, out x1, out y1, out z1);
         if (lat != x1 || lon != y1 || alt != z1)
             throw new Exception("Error in Reverse");
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }