示例#1
0
 private static PolygonResult PolyLength(double[][] points)
 {
     s_polyline.Clear();
     for (int i = 0; i < points.Length; ++i)
     {
         s_polyline.AddPoint(points[i][0], points[i][1]);
     }
     return(s_polyline.Compute(false, true));
 }
示例#2
0
        private static void CalcuateLenghtIncrements(List <Coordinate> points)
        {
            // setting the polyline to true allows us
            // to calculate length of a polyline
            var calc = new PolygonArea(Geodesic.WGS84, true);

            foreach (var point in points)
            {
                calc.AddPoint(point.X, point.Y);
                var length = calc.Compute().Perimeter;
                Console.WriteLine("Adding Point({0},{1}) : Curent Length : {2}", point.X, point.Y, length);
            }
        }
示例#3
0
        private static void CalculateLength(List <Coordinate> points)
        {
            // setting the polyline to true allows us
            // to calculate length of a polyline
            var calc = new PolygonArea(Geodesic.WGS84, true);

            foreach (var point in points)
            {
                calc.AddPoint(point.X, point.Y);
            }
            var length = calc.Compute().Perimeter;

            Console.WriteLine("Length Is : {0}", length);
        }
示例#4
0
        private static void CalculateArea(List <Coordinate> points)
        {
            // setting the polyline to false allows us
            // to calculate length of a polyline
            var calc = new PolygonArea(Geodesic.WGS84, false);

            foreach (var point in points)
            {
                calc.AddPoint(point.X, point.Y);
            }
            var area = calc.Compute();

            Console.WriteLine("Area Is      : {0}", area.Area);
            Console.WriteLine("Perimeter Is : {0}", area.Perimeter);
        }
示例#5
0
        private void OnAddPoint(object sender, EventArgs e)
        {
            try
            {
                double lat = Double.Parse(m_latitudeTextBox.Text);
                double lon = Double.Parse(m_longitudeTextBox.Text);
                double length, area;

                m_poly.AddPoint(lat, lon);
                m_edgeButton.Enabled    = true;
                m_currLatTextBox.Text   = m_latitudeTextBox.Text;
                m_currLonTextBox.Text   = m_longitudeTextBox.Text;
                m_numPointsTextBox.Text = m_poly.Compute(false, false, out length, out area).ToString();
                m_lengthTextBox.Text    = length.ToString();
                if (!m_polylineCheckBox.Checked)
                {
                    m_areaTextBox.Text = area.ToString();
                }
            }
            catch (Exception xcpt)
            {
                MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
 static void Main(string[] args)
 {
     try {
         Geodesic geod = new Geodesic();  // WGS84
         PolygonArea poly = new PolygonArea(geod, true);
         poly.AddPoint( 52,  0);     // London
         poly.AddPoint( 41,-74);     // New York
         poly.AddPoint(-23,-43);     // Rio de Janeiro
         poly.AddPoint(-26, 28);     // Johannesburg
         double perimeter, area;
         uint n = poly.Compute(false, true, out perimeter, out area);
         Console.WriteLine(String.Format("{0} {1} {2}", n, perimeter, area));
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
示例#7
0
 static void Main(string[] args)
 {
     try {
         Geodesic    geod = new Geodesic(); // WGS84
         PolygonArea poly = new PolygonArea(geod, true);
         poly.AddPoint(52, 0);              // London
         poly.AddPoint(41, -74);            // New York
         poly.AddPoint(-23, -43);           // Rio de Janeiro
         poly.AddPoint(-26, 28);            // Johannesburg
         double perimeter, area;
         uint   n = poly.Compute(false, true, out perimeter, out area);
         Console.WriteLine(String.Format("{0} {1} {2}", n, perimeter, area));
     }
     catch (GeographicErr e) {
         Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
     }
 }
示例#8
0
        public static void main(string[] args)
        {
            PolygonArea p = new PolygonArea(Geodesic.WGS84, false);

            try
            {
                var inp = (from arg in args select double.Parse(arg)).GetEnumerator();
                while (inp.MoveNext())
                {
                    double lat = inp.Current;
                    inp.MoveNext();
                    double lon = inp.Current;
                    p.AddPoint(lat, lon);
                }
            }
            catch (Exception e) { }
            PolygonResult r = p.Compute();

            Console.WriteLine(r.Num + " " + r.Perimeter + " " + r.Area);
        }
示例#9
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         double      lat, lon, perim, area;
         PolygonArea pa = new PolygonArea(new Geodesic(50000.0, 0.001), true);
         pa = new PolygonArea(false);
         pa.AddPoint(32.0, -86.0);
         pa.AddEdge(20.0, 10000.0);
         pa.AddEdge(-45.0, 10000.0);
         pa.CurrentPoint(out lat, out lon);
         pa.Compute(false, false, out perim, out area);
         pa.TestEdge(-70.0, 5000.0, false, false, out perim, out area);
         pa.TestPoint(31.0, -86.5, false, false, out perim, out area);
         MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#10
0
 private void OnValidate(object sender, EventArgs e)
 {
     try
     {
         double lat, lon, perim, area;
         PolygonArea pa = new PolygonArea(new Geodesic(50000.0, 0.001), true);
         pa = new PolygonArea(false);
         pa.AddPoint(32.0, -86.0);
         pa.AddEdge(20.0, 10000.0);
         pa.AddEdge(-45.0, 10000.0);
         pa.CurrentPoint(out lat, out lon);
         pa.Compute(false, false, out perim, out area);
         pa.TestEdge(-70.0, 5000.0, false, false, out perim, out area);
         pa.TestPoint(31.0, -86.5, false, false, out perim, out area);
         MessageBox.Show("No errors detected", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception xcpt)
     {
         MessageBox.Show(xcpt.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }