Example #1
0
        public override Geometry Reverse()
        {
            var sequence = CoordinateSequence.Copy();

            CoordinateSequences.Reverse(sequence);
            return(Factory.CreateLinearRing(sequence));
        }
Example #2
0
        /// <summary>
        /// The actual implementation of the <see cref="Geometry.Reverse"/> function for <c>LINESTRING</c>s.
        /// </summary>
        /// <returns>A reversed geometry</returns>
        protected override Geometry ReverseInternal()
        {
            var seq = _points.Copy();

            CoordinateSequences.Reverse(seq);
            return(Factory.CreateLineString(seq));
        }
Example #3
0
        /// <summary>
        /// The actual implementation of the <see cref="Geometry.Reverse"/> function for <c>LINEARRING</c>s.
        /// </summary>
        /// <returns>A reversed geometry</returns>
        protected override Geometry ReverseInternal()
        {
            var sequence = CoordinateSequence.Copy();

            CoordinateSequences.Reverse(sequence);
            return(Factory.CreateLinearRing(sequence));
        }
Example #4
0
 private LinearRing CreateLinearRing(CoordinateSequence coordinates, bool ccw)
 {
     if (coordinates != null && Orientation.IsCCW(coordinates) != ccw)
     {
         coordinates = coordinates.Copy();
         CoordinateSequences.Reverse(coordinates);
     }
     return(CreateLinearRing(coordinates));
 }
Example #5
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 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)
             {
                 CoordinateSequences.Reverse(_points);
             }
             return;
         }
     }
 }
Example #7
0
        /// <summary>
        /// Creates a <see cref="IMultiPoint"/> using the given CoordinateSequence.
        /// A null or empty CoordinateSequence will create an empty MultiPoint.
        /// </summary>
        /// <param name="coordinates">A CoordinateSequence (possibly empty), or <c>null</c>.</param>
        /// <returns>A <see cref="IMultiPoint"/> object</returns>
        public IMultiPoint CreateMultiPoint(ICoordinateSequence coordinates)
        {
            if (coordinates == null)
            {
                coordinates = CoordinateSequenceFactory.Create(new Coordinate[] { });
            }

            var points = new List <IPoint>();

            for (int i = 0; i < coordinates.Count; i++)
            {
                var seq = CoordinateSequenceFactory.Create(1, coordinates.Ordinates);
                CoordinateSequences.Copy(coordinates, i, seq, 0, 1);
                points.Add(CreatePoint(seq));
            }
            return(CreateMultiPoint(points.ToArray()));
        }
Example #8
0
 /// <summary>
 /// Shifts the positions of the coordinates until the coordinate at  <code>firstCoordinateIndex</code>
 /// is first.
 /// </summary>
 /// <param name="seq">The coordinate sequence to rearrange</param>
 /// <param name="indexOfFirstCoordinate">The index of the coordinate to make first</param>
 public static void Scroll(ICoordinateSequence seq, int indexOfFirstCoordinate)
 {
     Scroll(seq, indexOfFirstCoordinate, CoordinateSequences.IsRing(seq));
 }