Example #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));
     }
 }
Example #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 LocalCartesianPanel()
        {
            InitializeComponent();

            Geocentric g = new Geocentric();
            m_majorRadiusTextBox.Text = g.MajorRadius.ToString();
            m_flatteningTextBox.Text = g.Flattening.ToString();
            m_lc = new LocalCartesian(g);
            m_functionComboBox.SelectedIndex = (int)m_function;
        }
Example #5
0
        public LocalCartesianPanel()
        {
            InitializeComponent();

            Geocentric g = new Geocentric();

            m_majorRadiusTextBox.Text = g.EquatorialRadius.ToString();
            m_flatteningTextBox.Text  = g.Flattening.ToString();
            m_lc = new LocalCartesian(g);
            m_functionComboBox.SelectedIndex = (int)m_function;
        }
        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);
            }
        }
        public void Should_ConvertLatLonToXY()
        {
            var proj = new LocalCartesian(lat0, lon0);

            var length = latlon.Length;

            for (int i = 0; i < length - 1; i += 2)
            {
                var lat = latlon[i];
                var lon = latlon[i + 1];

                double x, y, z;
                proj.Forward(lat, lon, 0, out x, out y, out z);

                Assert.AreEqual(xy[i], x, TOLERANCE);
                Assert.AreEqual(xy[i + 1], y, TOLERANCE);
            }
        }
Example #8
0
        private void OnSetEllipsoid(object sender, EventArgs e)
        {
            double a, f;

            try
            {
                a = Double.Parse(m_majorRadiusTextBox.Text);
                f = Double.Parse(m_flatteningTextBox.Text);
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                m_lc = new LocalCartesian(new Geocentric(a, f));
            }
            catch (GeographicErr err)
            {
                MessageBox.Show(err.Message, "GeographicLib 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);
 }
Example #10
0
        private void OnSetEllipsoid(object sender, EventArgs e)
        {
            double a, f;
            try
            {
                a = Double.Parse(m_majorRadiusTextBox.Text);
                f = Double.Parse(m_flatteningTextBox.Text);
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                m_lc = new LocalCartesian(new Geocentric(a, f));
            }
            catch (GeographicErr err)
            {
                MessageBox.Show(err.Message, "GeographicLib error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }