Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a <see cref="MultiPoint"/> 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="MultiPoint"/> object</returns>
        public MultiPoint CreateMultiPoint(CoordinateSequence coordinates)
        {
            if (coordinates == null)
            {
                coordinates = CoordinateSequenceFactory.Create(new Coordinate[] { });
            }

            var points = new List <Point>();

            for (int i = 0; i < coordinates.Count; i++)
            {
                var seq = CoordinateSequenceFactory.Create(1, coordinates.Dimension, coordinates.Measures);
                CoordinateSequences.Copy(coordinates, i, seq, 0, 1);
                points.Add(CreatePoint(seq));
            }
            return(CreateMultiPoint(points.ToArray()));
        }
Ejemplo n.º 6
0
 /// <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;
         }
     }
 }