Esempio n. 1
0
		///<summary>
		/// Throws an exception if geometry's class is GeometryCollection.
		/// (Its subclasses do not trigger an exception).  
		///</summary>
		///<param name="geometry">The Geometry to check.</param>
		///<exception cref="ArgumentException">Throws an exception if geometry is a GeometryCollection
		/// but not one of its subclasses</exception>
		protected virtual void CheckNotGeometryCollection(Geometry geometry) 
		{
			//Don't use is because we want to allow subclasses e.g. multipolygon etc...
			string name=geometry.GetType().FullName;
			if (geometry.GetType().FullName=="Geotools.Geometries.GeometryCollection")
			{
				throw new ArgumentException("This method does not support GeometryCollection arguments");
			}
		}
		public bool HasRepeatedPoint(Geometry g)
		{
			
			if ( g.IsEmpty() ) return false;
			if (g is Point)                   return false;
			else if (g is MultiPoint)         return false;
				// LineString also handles LinearRings
			else if (g is LineString)         
			{
				return HasRepeatedPoint(((LineString) g).GetCoordinates() );
			}
			else if (g is Polygon)            return HasRepeatedPoint((Polygon) g);
			else if (g is GeometryCollection) return HasRepeatedPoint((GeometryCollection) g);
			else  throw new NotSupportedException(g.GetType().Name);
			
		}
Esempio n. 3
0
        private void Add(Geometry g)
        {
            if ( g.IsEmpty() ) return;

            // check if this Geometry should obey the Boundary Determination Rule
            // all collections except MultiPolygons obey the rule
            if ( g is GeometryCollection  && !(g is MultiPolygon) )
            {
                _useBoundaryDeterminationRule = true;
            }
            if ( g is Polygon )
            {
                AddPolygon( (Polygon) g );
            }
                // LineString also handles LinearRings
            else if ( g is LineString )
            {
                AddLineString( (LineString) g );
            }
            else if ( g is Point )
            {
                AddPoint( (Point) g );
            }
            else if ( g is MultiPoint )
            {
                AddCollection( (MultiPoint) g );
            }
            else if ( g is MultiLineString )
            {
                AddCollection( (MultiLineString) g );
            }
            else if ( g is MultiPolygon )
            {
                AddCollection( (MultiPolygon) g );
            }
            else if ( g is GeometryCollection )
            {
                AddCollection( (GeometryCollection) g );
            }
            else
            {
                throw new NotSupportedException(g.GetType().Name);
            }
        }
Esempio n. 4
0
		///<summary>
		/// Returns whether the two Geometrys are equal, from the point of view of the equalsExact method. 
		///</summary>
		///<remarks>Called by equalsExact. In general, two Geometry classes are considered to be "equivalent" only
		/// if they are the same class. An exception is LineString, which is considered to be equivalent
		/// to its subclasses.</remarks>
		///<param name="geometry"> the Geometry with which to compare this Geometry  for equality </param>
		///<returns>Returns true if the classes of the two Geometries are considered to be equal by the
		/// equalsExact method.</returns>
		protected  virtual bool IsEquivalentClass(Geometry geometry) 
		{
			return this.GetType().Name.Equals( geometry.GetType().Name );
		}
		private void Add(Geometry g)
		{
			
			if ( g.IsEmpty() ) return;

			if (g is Polygon)                 AddPolygon((Polygon) g);
			// LineString also handles LinearRings
			else if (g is LineString)         AddLineString((LineString) g);
			else if (g is Point)              AddPoint((Point) g);
			else if (g is MultiPoint)         AddCollection((MultiPoint) g);
			else if (g is MultiLineString)    AddCollection((MultiLineString) g);
			else if (g is MultiPolygon)       AddCollection((MultiPolygon) g);
			else if (g is GeometryCollection) AddCollection((GeometryCollection) g);
			else throw new NotSupportedException(g.GetType().Name);
			
			
		}
Esempio n. 6
0
		private void CheckValid(Geometry g)
		{
			
			if (_isChecked)
			{
				return;
			}
			_validErr = null;
			if ( g.IsEmpty() )
			{
					return;
			}
			if (g is Point)   
			{
				return;
			}
			else if (g is MultiPoint)
			{
				return;
			}
				// LineString also handles LinearRings
			else if (g is LineString) 
			{
				CheckValid( (LineString) g);
			}
			else if (g is Polygon)    
			{
				CheckValid( (Polygon) g);
			}
			else if (g is MultiPolygon) 
			{
				CheckValid( (MultiPolygon) g);
			}
			else if (g is GeometryCollection)
			{
				CheckValid( (GeometryCollection) g);
			}
			else  throw new NotSupportedException(g.GetType().Name);

		}