Пример #1
0
 /// <summary>
 /// Normalizes a <c>LineString</c>.  A normalized linestring
 /// has the first point which is not equal to it's reflected point
 /// less than the reflected point.
 /// </summary>
 public override void Normalize()
 {
     for (int i = 0; i < points.Count / 2; i++)
     {
         int j = points.Count - 1 - i;
         // skip equal points on both ends
         if (!points.GetCoordinate(i).Equals(points.GetCoordinate(j)))
         {
             if (points.GetCoordinate(i).CompareTo(points.GetCoordinate(j)) > 0)
             {
                 CoordinateArrays.Reverse(Coordinates);
             }
             return;
         }
     }
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ring"></param>
        /// <param name="clockwise"></param>
        private void Normalize(ILinearRing ring, bool clockwise)
        {
            if (ring.IsEmpty)
            {
                return;
            }
            Coordinate[] uniqueCoordinates = new Coordinate[ring.Coordinates.Length - 1];
            Array.Copy(ring.Coordinates, 0, uniqueCoordinates, 0, uniqueCoordinates.Length);
            ICoordinate minCoordinate = CoordinateArrays.MinCoordinate(ring.Coordinates);

            CoordinateArrays.Scroll(uniqueCoordinates, minCoordinate);
            Array.Copy(uniqueCoordinates, 0, ring.Coordinates, 0, uniqueCoordinates.Length);
            ring.Coordinates[uniqueCoordinates.Length] = uniqueCoordinates[0];
            if (CGAlgorithms.IsCCW(ring.Coordinates) == clockwise)
            {
                CoordinateArrays.Reverse(ring.Coordinates);
            }
        }