/// <summary>
        /// Returns the minimum coordinate, using the usual lexicographic comparison.
        /// </summary>
        /// <param name="coordinates">Array to search.</param>
        /// <returns>The minimum coordinate in the array, found using <c>CompareTo</c>.</returns>
        /// <seeaalso cref="Coordinate.CompareTo"/>
        public static Coordinate MinCoordinate(Coordinate[] coordinates)
        {
            Coordinate minCoord = null;

            for (int i = 0; i < coordinates.Length; i++)
            {
                if (minCoord == null || minCoord.CompareTo(coordinates[i]) > 0)
                {
                    minCoord = coordinates[i];
                }
            }
            return(minCoord);
        }
 /// <summary>
 /// Determines whether two <see cref="Coordinate" /> arrays of equal length
 /// are equal in opposite directions.
 /// </summary>
 /// <param name="pts1"></param>
 /// <param name="pts2"></param>
 /// <returns></returns>
 private static bool IsEqualReversed(Coordinate[] pts1, Coordinate[] pts2)
 {
     for (int i = 0; i < pts1.Length; i++)
     {
         Coordinate p1 = pts1[i];
         Coordinate p2 = pts2[pts1.Length - i - 1];
         if (p1.CompareTo(p2) != 0)
         {
             return(false);
         }
     }
     return(true);
 }
Example #3
0
        /// <summary>
        /// Returns whether this <c>Geometry</c> is greater than, equal to,
        /// or less than another <c>Geometry</c> having the same class.
        /// </summary>
        /// <param name="other">A <c>Geometry</c> having the same class as this <c>Geometry</c>.</param>
        /// <returns>
        /// A positive number, 0, or a negative number, depending on whether
        /// this object is greater than, equal to, or less than <c>o</c>, as
        /// defined in "Normal Form For Geometry" in the NTS Technical
        /// Specifications.
        /// </returns>
        public override int CompareToSameClass(object other)
        {
            Point point = (Point)other;

            return(Coordinate.CompareTo(point.Coordinate));
        }