Ejemplo n.º 1
0
        /// <summary>
        /// Returns the length of the line or line string represented by the specified <paramref name="points"/>.
        /// </summary>
        /// <param name="points">The points making up the line.</param>
        /// <returns>The length in metres.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="points"/> is <c>null</c>.</exception>
        public static double GetLength(IPoint[] points)
        {
            if (points == null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            double sum = 0;

            // Iterate through each point in the path (skip the first point)
            for (int i = 1; i < points.Length; i++)
            {
                // Calculate the distance between the two points
                sum += DistanceUtils.GetDistance(points[i - 1], points[i]);
            }

            return(sum);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the circumference of the closed path represented by the specified <paramref name="points"/>.
        /// </summary>
        /// <param name="points">The points making up the closed path.</param>
        /// <param name="radius">The radius of the spheroid.</param>
        /// <returns>The circumference in metres.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="points"/> is <c>null</c>.</exception>
        public static double GetCircumference(IPoint[] points, double radius)
        {
            if (points == null)
            {
                throw new ArgumentNullException(nameof(points));
            }

            double sum = 0;

            // Iterate through each point in the path
            for (int i = 0; i < points.Length; i++)
            {
                // While "i" is the index of the first point and "j" is the second point
                int j = i == 0 ? points.Length - 1 : i - 1;

                // Calculate the distance between the two points
                sum += DistanceUtils.GetDistance(points[i], points[j], radius);
            }

            return(sum);
        }