/// <summary>
        /// Creates a <see cref="LineString" /> whose coordinates are in the reverse order of this objects.
        /// </summary>
        /// <returns>A <see cref="LineString" /> with coordinates in the reverse order.</returns>
        public override Geometry Reverse()
        {
            var seq = _points.Copy();

            CoordinateSequences.Reverse(seq);
            return(Factory.CreateLineString(seq));
        }
Exemple #2
0
        public override Geometry Reverse()
        {
            var sequence = CoordinateSequence.Copy();

            CoordinateSequences.Reverse(sequence);
            return(Factory.CreateLinearRing(sequence));
        }
 private LinearRing CreateLinearRing(CoordinateSequence coordinates, bool ccw)
 {
     if (coordinates != null && Orientation.IsCCW(coordinates) != ccw)
     {
         coordinates = coordinates.Copy();
         CoordinateSequences.Reverse(coordinates);
     }
     return(CreateLinearRing(coordinates));
 }
Exemple #4
0
        private static void Normalize(LinearRing ring, bool clockwise)
        {
            if (ring.IsEmpty)
            {
                return;
            }

            var seq = ring.CoordinateSequence;
            int minCoordinateIndex = CoordinateSequences.MinCoordinateIndex(seq, 0, seq.Count - 2);

            CoordinateSequences.Scroll(seq, minCoordinateIndex, true);
            if (Orientation.IsCCW(seq) == clockwise)
            {
                CoordinateSequences.Reverse(seq);
            }
        }
 /// <summary>
 /// Normalizes a <c>LineString</c>.  A normalized <c>LineString</c>
 /// 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)
             {
                 var copy = _points.Copy();
                 CoordinateSequences.Reverse(copy);
                 _points = copy;
             }
             return;
         }
     }
 }