Beispiel #1
0
        ///<summary>
        /// Converts a linearring to be sure it is clockwise.
        ///</summary>
        ///<remarks>Normal form is a unique representation
        /// for Geometry's. It can be used to test whether two Geometrys are equal in a way that is
        /// independent of the ordering of the coordinates within them. Normal form equality is a stronger
        /// condition than topological equality, but weaker than pointwise equality. The definitions for
        /// normal form use the standard lexicographical ordering for coordinates. Sorted in order of
        /// coordinates means the obvious extension of this ordering to sequences of coordinates.
        ///</remarks>
        private void Normalize(LinearRing ring, bool clockwise)
        {
            if (ring.IsEmpty())
            {
                return;
            }
            Coordinates uniqueCoordinates = new Coordinates();

            for (int i = 0; i < ring.GetNumPoints() - 1; i++)
            {
                uniqueCoordinates.Add(ring.GetCoordinateN(i));                                  // copy all but last one into uniquecoordinates
            }
            Coordinate minCoordinate = MinCoordinate(ring.GetCoordinates());

            Scroll(uniqueCoordinates, minCoordinate);
            Coordinates ringCoordinates = ring.GetCoordinates();

            ringCoordinates.Clear();
            ringCoordinates.AddRange(uniqueCoordinates);
            ringCoordinates.Add(uniqueCoordinates[0].Clone());                          // add back in the closing point.
            if (_cgAlgorithms.IsCCW(ringCoordinates) == clockwise)
            {
                ReversePointOrder(ringCoordinates);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns the number of points in this polygon.
        /// </summary>
        /// <returns>The number of points in the polygon
        /// (both the shell and interior rings if they exist).</returns>
        public override int GetNumPoints()
        {
            int count = _shell.GetNumPoints();

            if (_holes != null)
            {
                for (int i = 0; i < _holes.Length; i++)
                {
                    count += _holes[i].GetNumPoints();
                }
            }
            return(count);
        }
Beispiel #3
0
		///<summary>
		/// Converts a linearring to be sure it is clockwise.
		///</summary>
		///<remarks>Normal form is a unique representation
		/// for Geometry's. It can be used to test whether two Geometrys are equal in a way that is 
		/// independent of the ordering of the coordinates within them. Normal form equality is a stronger 
		/// condition than topological equality, but weaker than pointwise equality. The definitions for 
		/// normal form use the standard lexicographical ordering for coordinates. Sorted in order of 
		/// coordinates means the obvious extension of this ordering to sequences of coordinates.
		///</remarks>
		private void Normalize( LinearRing ring, bool clockwise ) 
		{
			if ( ring.IsEmpty() ) 
			{
				return;
			}
			Coordinates uniqueCoordinates = new Coordinates();
			for ( int i=0; i < ring.GetNumPoints()-1; i++ )
			{
				uniqueCoordinates.Add( ring.GetCoordinateN( i ) );		// copy all but last one into uniquecoordinates
			}
			Coordinate minCoordinate = MinCoordinate( ring.GetCoordinates() );
			Scroll( uniqueCoordinates, minCoordinate );
			Coordinates ringCoordinates = ring.GetCoordinates();
			ringCoordinates.Clear();
			ringCoordinates.AddRange( uniqueCoordinates );
			ringCoordinates.Add( uniqueCoordinates[0].Clone() );		// add back in the closing point.
			if ( _cgAlgorithms.IsCCW( ringCoordinates ) == clockwise )
			{
				ReversePointOrder( ringCoordinates );
			}
		}