Beispiel #1
0
        /// <summary>
        /// Returns the area of the rectangle in square metres.
        /// </summary>
        /// <param name="radius">The radius of the spheroid.</param>
        /// <returns>The area in square metres.</returns>
        public double GetArea(double radius)
        {
            Point southWest = new Point(SouthWest.Latitude, SouthWest.Longitude);
            Point northEast = new Point(NorthEast.Latitude, NorthEast.Longitude);
            Point southEast = new Point(SouthWest.Latitude, NorthEast.Longitude);
            Point northWest = new Point(NorthEast.Latitude, SouthWest.Longitude);

            return(MapsUtils.GetArea(new IPoint[] { northEast, northWest, southWest, southEast }, radius));
        }
        /// <summary>
        /// Returns the area of the specified <paramref name="polygon"/> measured in sqaure metres.
        /// </summary>
        /// <param name="polygon">The polygon.</param>
        /// <returns>A <see cref="double"/> representing the area in square metres.</returns>
        /// <remarks>For this method to work, it is assumed that coordinates are specified using the
        /// <strong>WGS 84</strong> coordinate system (eg. used by the Global Positioning System).</remarks>
        /// <see>
        ///     <cref>https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84</cref>
        /// </see>
        /// <see>
        ///     <cref>https://en.wikipedia.org/wiki/Global_Positioning_System</cref>
        /// </see>
        /// <exception cref="ArgumentNullException"><paramref name="polygon"/> is <c>null</c>.</exception>
        public static double GetArea(WktPolygon polygon)
        {
            if (polygon == null)
            {
                throw new ArgumentNullException(nameof(polygon));
            }

            // Get the overall area from the outer points
            double area = MapsUtils.GetArea(polygon.Outer.Select(x => new Point(x.Y, x.X)));

            // Substract the area of the inner points
            foreach (WktPoint[] inner in polygon.Inner)
            {
                area -= MapsUtils.GetArea(inner.Select(x => new Point(x.Y, x.X)));
            }

            return(area);
        }
Beispiel #3
0
 /// <summary>
 /// Returns the area of the polygon in square metres.
 /// </summary>
 /// <returns>The area in square metres.</returns>
 public double GetArea()
 {
     return(MapsUtils.GetArea(Outer));
 }