예제 #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);
            }
        }
예제 #2
0
 /// <summary>
 /// Initializes a Polygon with the given exterior boundary.  The shell and holes
 /// must conform to the assertions specified in the OpenGIS Simple Features
 /// Specification for SQL.
 /// </summary>
 /// <param name="shell">
 ///	The outer boundary of the new Polygon, or null or an empty LinearRing if the empty
 ///	geometry is to be created. Must be oriented clockwise.
 /// </param>
 /// <param name="holes">
 /// The inner boundaries of the new Polygon, or null or empty LinearRings if the empty
 /// geometry is to be created. Each must be oriented counterclockwise.
 /// </param>
 /// <param name="precisionModel">
 /// The specification of the grid of allowable points for this Polygon.
 /// </param>
 /// <param name="SRID">
 /// The ID of the Spatial Reference System used by this Polygon.
 /// </param>
 internal Polygon(LinearRing shell, LinearRing[] holes, PrecisionModel precisionModel, int SRID) : base(precisionModel, SRID)
 {
     if (shell == null)
     {
         shell = _geometryFactory.CreateLinearRing(null);
     }
     if (holes == null)
     {
         holes = new LinearRing[] {};
     }
     //OPTIMIZE: - if fully optimzed, don't bother doing this test.
     if (HasNullElements(holes))
     {
         throw new ArgumentNullException("holes must not contain null elements");
     }
     if (shell.IsEmpty() && HasNonEmptyElements(holes))
     {
         throw new ArgumentException("shell is empty but holes are not");
     }
     _shell = shell;
     _holes = holes;
 }
예제 #3
0
		/// <summary>
		/// Initializes a Polygon with the given exterior boundary.  The shell and holes 
		/// must conform to the assertions specified in the OpenGIS Simple Features
		/// Specification for SQL.
		/// </summary>
		/// <param name="shell">
		///	The outer boundary of the new Polygon, or null or an empty LinearRing if the empty
		///	geometry is to be created. Must be oriented clockwise.
		/// </param>
		/// <param name="holes">
		/// The inner boundaries of the new Polygon, or null or empty LinearRings if the empty 
		/// geometry is to be created. Each must be oriented counterclockwise.
		/// </param>
		/// <param name="precisionModel">
		/// The specification of the grid of allowable points for this Polygon.
		/// </param>
		/// <param name="SRID">
		/// The ID of the Spatial Reference System used by this Polygon.
		/// </param>
		internal Polygon(LinearRing shell, LinearRing[] holes, PrecisionModel precisionModel, int SRID) : base(precisionModel, SRID)
		{
			if (shell == null) 
			{
				shell = _geometryFactory.CreateLinearRing(null);
			}
			if (holes == null) 
			{
				holes = new LinearRing[]{};
			}
			//OPTIMIZE: - if fully optimzed, don't bother doing this test.
			if (HasNullElements(holes)) 
			{
				throw new ArgumentNullException("holes must not contain null elements");
			}
			if (shell.IsEmpty() && HasNonEmptyElements(holes)) 
			{
				throw new ArgumentException("shell is empty but holes are not");
			}
			_shell = shell;
			_holes = holes;
		}
예제 #4
0
 /// <summary>
 /// Determines if this polygon is empty.
 /// </summary>
 /// <returns>True if the polygon is empty.</returns>
 public override bool IsEmpty()
 {
     return(_shell.IsEmpty());
 }
예제 #5
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 );
			}
		}