예제 #1
0
		/// <summary>
		///		Determines the topological relationship (location) of a single point
		///		to a Geometry.  It handles both single-element and multi-element Geometries.  
		///		The algorithm for multi-part Geometries is more complex, since it has 
		///		to take into account the boundaryDetermination rule.
		/// </summary>
		/// <param name="p"></param>
		/// <param name="geom"></param>
		/// <returns>Returns the location of the point relative to the input Geometry.</returns>
		public int Locate( Coordinate p, Geometry geom )
		{
			if ( geom.IsEmpty() ) return Location.Exterior;

			if ( geom is LineString )
			{
				return Locate( p, (LineString) geom );
			}
			if ( geom is LinearRing )
			{
				return Locate( p, (LinearRing) geom );
			}
			else if ( geom is Polygon ) 
			{
				return Locate( p, (Polygon) geom );
			}

			_isIn = false;
			_numBoundaries = 0;
			ComputeLocation( p, geom );
			if ( GeometryGraph.IsInBoundary( _numBoundaries ) )
			{
				return Location.Boundary;
			}
			if ( _numBoundaries > 0 || _isIn)
			{
				return Location.Interior;
			}
			return Location.Exterior;
		} // public int Locate( Coordinate p, Geometry geom )
		/// <summary>
		///		Locate is the main location function.  It handles both single-element
		///		and multi-element Geometries.  The algorithm for multi-element Geometries
		///		is more complex, since it has to take into account the boundaryDetermination rule
		/// </summary>
		/// <param name="p"></param>
		/// <param name="geom"></param>
		/// <returns></returns>
		public static int Locate(Coordinate p, Geometry geom)
		{

			if ( geom.IsEmpty() ) return Location.Exterior;

			if ( ContainsPoint( p, geom ) )
			{
				return Location.Interior;
			}
			return Location.Exterior;
		} // public static int Locate(Coordinate p, Geometry geom)
		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);
			
		}
예제 #4
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);
            }
        }
예제 #5
0
		} // public bool IsSimple( MultiPoint mp )

		/// <summary>
		/// Tests to see if geometry is simple.
		/// </summary>
		/// <param name="geom">Geometry to test.</param>
		/// <returns>Returns true if geometry is simple, false otherwise.</returns>
		private bool IsSimpleLinearGeometry( Geometry geom )
		{
			if( geom.IsEmpty() )
			{
				return true;
			}
			GeometryGraph graph = new GeometryGraph( 0, geom );
			LineIntersector li = new RobustLineIntersector();
			SegmentIntersector si = graph.ComputeSelfNodes( li );
			// if no self-intersection, must be simple
			if( !si.HasIntersection )
			{
				return true;
			}
			if( si.HasProperIntersection )
			{
				return false;
			}
			if( HasNonEndpointIntersection( graph ) )
			{
				return false;
			}
			if( HasClosedEndpointIntersection( graph ) )
			{
				return false;
			}
			return true;
		} // private bool IsSimpleLinearGeometry( Geometry geom )
예제 #6
0
		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);
			
			
		}
예제 #7
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);

		}