NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
NetTopologySuite.Geometries.Polygon Class Reference

Represents a polygon with linear edges, which may include holes. The outer boundary (shell) and inner boundaries (holes) of the polygon are represented by LinearRings. The boundary rings of the polygon may have any orientation. Polygons are closed, simple geometries by definition. The polygon model conforms to the assertions specified in the OpenGIS Simple Features Specification for SQL. A Polygon is topologically valid if and only if:

More...

Inheritance diagram for NetTopologySuite.Geometries.Polygon:
NetTopologySuite.Geometries.Geometry

Public Member Functions

 Polygon (ILinearRing shell, ILinearRing[] holes)
 Initializes a new instance of the Polygon class. More...
 
 Polygon (ILinearRing shell, ILinearRing[] holes, IGeometryFactory factory)
 Constructs a Polygon with the given exterior boundary and interior boundaries. More...
 
override double[] GetOrdinates (Ordinate ordinate)
 Gets an array of System.Double ordinate values More...
 
ILineString GetInteriorRingN (int n)
 
override bool EqualsExact (IGeometry other, double tolerance)
 
override void Apply (ICoordinateFilter filter)
 
override void Apply (ICoordinateSequenceFilter filter)
 
override void Apply (IGeometryFilter filter)
 
override void Apply (IGeometryComponentFilter filter)
 
override object Clone ()
 
override IGeometry ConvexHull ()
 
override void Normalize ()
 
override IGeometry Reverse ()
 
 Polygon (ILinearRing shell, IGeometryFactory factory)
 Constructs a Polygon with the given exterior boundary. More...
 
 Polygon (ILinearRing shell)
 Constructs a Polygon with the given exterior boundary. More...
 
- Public Member Functions inherited from NetTopologySuite.Geometries.Geometry
virtual IGeometry GetGeometryN (int n)
 Returns an element Geometry from a GeometryCollection, or More...
 
double Distance (IGeometry g)
 Returns the minimum distance between this Geometry and another Geometry g. More...
 
bool IsWithinDistance (IGeometry geom, double distance)
 Tests whether the distance from this Geometry to another is less than or equal to a specified value. More...
 
void GeometryChanged ()
 Notifies this geometry that its coordinates have been changed by an external party (for example, via a ICoordinateFilter). More...
 
void GeometryChangedAction ()
 Notifies this Geometry that its Coordinates have been changed by an external party. When GeometryChanged is called, this method will be called for this Geometry and its component Geometries. More...
 
bool Disjoint (IGeometry g)
 Tests whether this geometry is disjoint from the argument geometry. More...
 
bool Touches (IGeometry g)
 Tests whether this geometry touches the argument geometry More...
 
bool Intersects (IGeometry g)
 Tests whether this geometry intersects the argument geometry. /summary> More...
 
bool Crosses (IGeometry g)
 
bool Within (IGeometry g)
 Tests whether this geometry is within the specified geometry. More...
 
bool Contains (IGeometry g)
 
bool Overlaps (IGeometry g)
 Tests whether this geometry overlaps the specified geometry. More...
 
bool Covers (IGeometry g)
 Tests whether this geometry covers the argument geometry More...
 
bool CoveredBy (IGeometry g)
 
bool Relate (IGeometry g, string intersectionPattern)
 
IntersectionMatrix Relate (IGeometry g)
 Returns the DE-9IM intersection matrix for the two Geometrys. More...
 
bool Equals (IGeometry g)
 Tests whether this geometry is topologically equal to the argument geometry. This method is included for backward compatibility reasons. It has been superseded by the

See also
EqualsTopologically

method, which has been named to clearly denote its functionality. This method should NOT be confused with the method

See also
Equals(Object)

, which implements an exact equality comparison. More...

 
bool EqualsTopologically (IGeometry g)
 Tests whether this geometry is topologically equal to the argument geometry as defined by the SFS Equals predicate. More...
 
override bool Equals (Object o)
 Tests whether this geometry is structurally and numerically equal to a given Object. More...
 
override int GetHashCode ()
 Gets a hash code for the Geometry. More...
 
override string ToString ()
 Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text format, see the OpenGIS Simple Features Specification. More...
 
string ToText ()
 Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text format, see the OpenGIS Simple Features Specification. More...
 
string AsText ()
 ToText More...
 
byte[] ToBinary ()
 Returns the Well-known Binary representation of this Geometry. For a definition of the Well-known Binary format, see the OpenGIS Simple Features Specification. More...
 
byte[] AsBinary ()
 ToBinary More...
 
XmlReader ToGMLFeature ()
 Returns the feature representation as GML 2.1.1 XML document. This XML document is based on Geometry.xsd schema. NO features or XLink are implemented here! More...
 
IGeometry Buffer (double distance)
 Computes a buffer area around this geometry having the given width. The buffer of a Geometry is the Minkowski sum or difference of the geometry with a disc of radius Abs(distance). More...
 
IGeometry Buffer (double distance, BufferStyle endCapStyle)
 Computes a buffer region around this Geometry having the given width. The buffer of a Geometry is the Minkowski sum or difference of the geometry with a disc of radius Abs(distance). More...
 
IGeometry Buffer (double distance, EndCapStyle endCapStyle)
 Computes a buffer region around this Geometry having the given width. The buffer of a Geometry is the Minkowski sum or difference of the geometry with a disc of radius Abs(distance). More...
 
IGeometry Buffer (double distance, int quadrantSegments)
 Computes a buffer region around this Geometry having the given width and with a specified accuracy of approximation for circular arcs. The buffer of a Geometry is the Minkowski sum of the Geometry with a disc of radius distance. Curves in the buffer polygon are approximated with line segments. This method allows specifying the accuracy of that approximation. More...
 
IGeometry Buffer (double distance, int quadrantSegments, BufferStyle endCapStyle)
 Computes a buffer region around this Geometry having the given width and with a specified number of segments used to approximate curves. The buffer of a Geometry is the Minkowski sum of the Geometry with a disc of radius distance. Curves in the buffer polygon are approximated with line segments. This method allows specifying the accuracy of that approximation. More...
 
IGeometry Buffer (double distance, int quadrantSegments, EndCapStyle endCapStyle)
 Computes a buffer region around this Geometry having the given width and with a specified number of segments used to approximate curves. The buffer of a Geometry is the Minkowski sum of the Geometry with a disc of radius distance. Curves in the buffer polygon are approximated with line segments. This method allows specifying the accuracy of that approximation. More...
 
IGeometry Buffer (double distance, IBufferParameters bufferParameters)
 Computes a buffer region around this Geometry having the given width and with a specified number of segments used to approximate curves. The buffer of a Geometry is the Minkowski sum of the Geometry with a disc of radius distance. Curves in the buffer polygon are approximated with line segments. This method allows specifying the accuracy of that approximation. More...
 
IGeometry Intersection (IGeometry other)
 Computes a Geometry representing the point-set which is common to both this Geometry and the other Geometry. The intersection of two geometries of different dimension produces a result geometry of dimension less than or equal to the minimum dimension of the input geometries. The result geometry may be a heterogenous IGeometryCollection. If the result is empty, it is an atomic geometry with the dimension of the lowest input dimension. Intersection of IGeometryCollections is supported only for homogeneous collection types. Non-empty heterogeneous IGeometryCollection arguments are not supported. More...
 
IGeometry Union (IGeometry other)
 Computes a Geometry representing the point-set which is contained in both this Geometry and the other Geometry. More...
 
IGeometry Difference (IGeometry other)
 Computes a Geometry representing the closure of the point-set of the points contained in this Geometry that are not contained in the other Geometry. If the result is empty, it is an atomic geometry with the dimension of the left-hand input. Non-empty IGeometryCollection arguments are not supported. More...
 
IGeometry SymmetricDifference (IGeometry other)
 Computes a Geometry representing the closure of the point-set which is the union of the points in this Geometry which are not contained in the other Geometry, with the points in the other Geometry not contained in this Geometry. If the result is empty, it is an atomic geometry with the dimension of the highest input dimension. Non-empty IGeometryCollection arguments are not supported. More...
 
IGeometry Union ()
 Computes the union of all the elements of this geometry. More...
 
bool EqualsExact (IGeometry other)
 Returns true if the two Geometrys are exactly equal. Two Geometries are exactly equal if:

  • they have the same class,
  • they have the same values of Coordinates in their internal Coordinate lists, in exactly the same order.

This provides a stricter test of equality than EqualsTopologically, which is more useful in certain situations (such as using geometries as keys in collections). This method does not test the values of the GeometryFactory, the SRID, or the UserData fields. To properly test equality between different geometries, it is usually necessary to Normalize them first. More...

 
bool EqualsNormalized (IGeometry g)
 Tests whether two geometries are exactly equal in their normalized forms. More...
 
IGeometry Normalized ()
 Creates a new Geometry which is a normalized copy of this Geometry. More...
 
int CompareTo (object o)
 Returns whether this Geometry is greater than, equal to, or less than another Geometry. More...
 
int CompareTo (IGeometry geom)
 Returns whether this Geometry is greater than, equal to, or less than another Geometry. More...
 
int CompareTo (Object o, IComparer< ICoordinateSequence > comp)
 Returns whether this Geometry is greater than, equal to, or less than another Geometry, using the given . More...
 

Static Public Attributes

static readonly IPolygon Empty = new GeometryFactory().CreatePolygon(null, null)
 Represents an empty Polygon. More...
 
- Static Public Attributes inherited from NetTopologySuite.Geometries.Geometry
static readonly IGeometryFactory DefaultFactory = GeometryFactory.Default
 A predefined GeometryFactory with PrecisionModel == PrecisionModels.Fixed. More...
 

Protected Member Functions

override Envelope ComputeEnvelopeInternal ()
 
- Protected Member Functions inherited from NetTopologySuite.Geometries.Geometry
 Geometry (IGeometryFactory factory)
 Creates a new Geometry via the specified GeometryFactory. More...
 
virtual bool IsEquivalentClass (IGeometry other)
 Returns whether the two Geometrys are equal, from the point of view of the EqualsExact method. 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. More...
 
void CheckNotGeometryCollection (IGeometry g)
 Throws an exception if g's class is GeometryCollection. (its subclasses do not trigger an exception). More...
 

Properties

override Coordinate Coordinate [get]
 Returns a vertex of this Geometry (usually, but not necessarily, the first one). More...
 
override Coordinate[] Coordinates [get]
 Returns an array containing the values of all the vertices for this geometry. More...
 
override int NumPoints [get]
 Returns the count of this Geometrys vertices. The Geometry s contained by composite Geometrys must be Geometry's; that is, they must implement NumPoints. More...
 
override Dimension Dimension [get]
 Returns the dimension of this geometry. More...
 
override Dimension BoundaryDimension [get]
 Returns the dimension of this Geometrys inherent boundary. More...
 
override bool IsEmpty [get]
 
ILineString ExteriorRing [get]
 
int NumInteriorRings [get]
 
ILineString[] InteriorRings [get]
 
override string GeometryType [get]
 Returns the name of this object's interface. More...
 
override OgcGeometryType OgcGeometryType [get]
 
override double Area [get]
 Returns the area of this Polygon More...
 
override double Length [get]
 Returns the perimeter of this Polygon. More...
 
override IGeometry Boundary [get]
 
override bool IsRectangle [get]
 
ILinearRing Shell [get]
 
ILinearRing[] Holes [get]
 
- Properties inherited from NetTopologySuite.Geometries.Geometry
IGeometryFactory Factory [get]
 Gets the factory which contains the context in which this point was created. More...
 
object UserData [get, set]
 Gets/Sets the user data object for this point, if any. More...
 
int SRID [get, set]
 Sets the ID of the Spatial Reference System used by the Geometry. More...
 
abstract string GeometryType [get]
 Returns the name of this Geometry's actual class. More...
 
abstract OgcGeometryType OgcGeometryType [get]
 Gets the OGC geometry type More...
 
IPrecisionModel PrecisionModel [get]
 Returns the PrecisionModel used by the Geometry. More...
 
abstract Coordinate Coordinate [get]
 Returns a vertex of this Geometry (usually, but not necessarily, the first one). More...
 
abstract Coordinate[] Coordinates [get]
 Returns an array containing the values of all the vertices for this geometry. More...
 
abstract int NumPoints [get]
 Returns the count of this Geometrys vertices. The Geometry s contained by composite Geometrys must be Geometry's; that is, they must implement NumPoints. More...
 
virtual int NumGeometries [get]
 Returns the number of Geometryes in a GeometryCollection, or 1, if the geometry is not a collection. More...
 
bool IsSimple [get]
 Tests whether this IGeometry is simple. The SFS definition of simplicity follows the general rule that a Geometry is simple if it has no points of self-tangency, self-intersection or other anomalous points. Simplicity is defined for each IGeometry subclass as follows:

  • Valid polygonal geometries are simple, since their rings must not self-intersect. IsSimple tests for this condition and reports
More...
 
virtual bool IsValid [get]
 Tests whether this Geometry is topologically valid, according to the OGC SFS specification.For validity rules see the documentation for the specific geometry subclass. More...
 
abstract bool IsEmpty [get]
 Tests whether the set of points covered in this Geometry is empty. More...
 
virtual double Area [get]
 Returns the area of this Geometry. Areal Geometries have a non-zero area. They override this function to compute the area. Others return 0.0 More...
 
virtual double Length [get]
 Returns the length of this Geometry. Linear geometries return their length. Areal geometries return their perimeter. They override this function to compute the length. Others return 0.0 More...
 
IPoint Centroid [get]
 Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension geometries contribute zero "weight" to the centroid). The centroid of an empty geometry is POINT EMPTY. More...
 
IPoint InteriorPoint [get]
 Computes an interior point of this Geometry. More...
 
IPoint PointOnSurface [get]
 InteriorPoint More...
 
virtual Dimension Dimension [get, set]
 Returns the dimension of this geometry. More...
 
virtual IGeometry Boundary [get, set]
 Returns the boundary, or an empty geometry of appropriate dimension if this Geometry is empty. For a discussion of this function, see the OpenGIS Simple Features Specification. As stated in SFS Section 2.1.13.1, "the boundary of a Geometry is a set of Geometries of the next lower dimension." More...
 
virtual Dimension BoundaryDimension [get, set]
 Returns the dimension of this Geometrys inherent boundary. More...
 
IGeometry Envelope [get]
 Gets a geometry representing the envelope (bounding box) of this Geometry. More...
 
Envelope EnvelopeInternal [get]
 Gets an GeoAPI.Geometries.Envelope containing the minimum and maximum x and y values in this Geometry. If the geometry is empty, an empty Envelope is returned. More...
 
bool IsGeometryCollection [get]
 
virtual bool IsRectangle [get]
 

Additional Inherited Members

- Static Public Member Functions inherited from NetTopologySuite.Geometries.Geometry
static bool HasNullElements (object[] array)
 Returns true if the array contains any null elements. More...
 
static bool operator== (Geometry obj1, IGeometry obj2)
 
static bool operator!= (Geometry obj1, IGeometry obj2)
 
- Static Protected Member Functions inherited from NetTopologySuite.Geometries.Geometry
static bool HasNonEmptyElements (IGeometry[] geometries)
 Returns true if the array contains any non-empty Geometrys. More...
 
static int Compare (List< IGeometry > a, List< IGeometry > b)
 Returns the first non-zero result of CompareTo encountered as the two Collections are iterated over. If, by the time one of the iterations is complete, no non-zero result has been encountered, returns 0 if the other iteration is also complete. If b completes before a, a positive number is returned; if a before b, a negative number. More...
 
static bool Equal (Coordinate a, Coordinate b, double tolerance)
 
static double[] CreateArray (int size, double value)
 
static double[] CreateArray (ICoordinateSequence sequence, Ordinate ordinate)
 

Detailed Description

Represents a polygon with linear edges, which may include holes. The outer boundary (shell) and inner boundaries (holes) of the polygon are represented by LinearRings. The boundary rings of the polygon may have any orientation. Polygons are closed, simple geometries by definition.

The polygon model conforms to the assertions specified in the OpenGIS Simple Features Specification for SQL.

A Polygon is topologically valid if and only if:

  • the coordinates which define it are valid coordinates
  • the linear rings for the shell and holes are valid (i.e. are closed and do not self-intersect)
  • holes touch the shell or another hole at at most one point (which implies that the rings of the shell and holes must not cross)
  • the interior of the polygon is connected, or equivalently no sequence of touching holes makes the interior of the polygon disconnected (i.e. effectively split the polygon into two pieces).

Constructor & Destructor Documentation

NetTopologySuite.Geometries.Polygon.Polygon ( ILinearRing  shell,
ILinearRing[]  holes 
)

Initializes a new instance of the Polygon class.

Parameters
shellThe outer boundary of the new Polygon, or null or an empty LinearRing if the empty point is to be created.
holesThe inner boundaries of the new Polygon , or null or empty LinearRings if the empty point is to be created.

For create this Geometry is used a standard GeometryFactory with PrecisionModel == PrecisionModels.Floating.

NetTopologySuite.Geometries.Polygon.Polygon ( ILinearRing  shell,
ILinearRing[]  holes,
IGeometryFactory  factory 
)

Constructs a Polygon with the given exterior boundary and interior boundaries.

Parameters
shellThe outer boundary of the new Polygon, or null or an empty LinearRing if the empty point is to be created.
holesThe inner boundaries of the new Polygon , or null or empty LinearRings if the empty point is to be created.
factory
NetTopologySuite.Geometries.Polygon.Polygon ( ILinearRing  shell,
IGeometryFactory  factory 
)

Constructs a Polygon with the given exterior boundary.

Parameters
shellThe outer boundary of the new Polygon, or null or an empty LinearRing if the empty polygon is to be created.
factory
NetTopologySuite.Geometries.Polygon.Polygon ( ILinearRing  shell)

Constructs a Polygon with the given exterior boundary.

Parameters
shellThe outer boundary of the new Polygon, or null or an empty LinearRing if the empty polygon is to be created.

Member Function Documentation

override void NetTopologySuite.Geometries.Polygon.Apply ( ICoordinateFilter  filter)
virtual

Parameters
filter

Implements NetTopologySuite.Geometries.Geometry.

override void NetTopologySuite.Geometries.Polygon.Apply ( IGeometryFilter  filter)
virtual

Parameters
filter

Implements NetTopologySuite.Geometries.Geometry.

override void NetTopologySuite.Geometries.Polygon.Apply ( IGeometryComponentFilter  filter)
virtual

Parameters
filter

Implements NetTopologySuite.Geometries.Geometry.

override object NetTopologySuite.Geometries.Polygon.Clone ( )
virtual

Returns

Reimplemented from NetTopologySuite.Geometries.Geometry.

override Envelope NetTopologySuite.Geometries.Polygon.ComputeEnvelopeInternal ( )
protectedvirtual
override IGeometry NetTopologySuite.Geometries.Polygon.ConvexHull ( )
virtual

Returns

Reimplemented from NetTopologySuite.Geometries.Geometry.

override bool NetTopologySuite.Geometries.Polygon.EqualsExact ( IGeometry  other,
double  tolerance 
)
virtual

Parameters
other
tolerance
Returns

Implements NetTopologySuite.Geometries.Geometry.

ILineString NetTopologySuite.Geometries.Polygon.GetInteriorRingN ( int  n)

Parameters
n
Returns
override double [] NetTopologySuite.Geometries.Polygon.GetOrdinates ( Ordinate  ordinate)
virtual

Gets an array of System.Double ordinate values

Parameters
ordinateThe ordinate index
Returns
An array of ordinate values

Implements NetTopologySuite.Geometries.Geometry.

override void NetTopologySuite.Geometries.Polygon.Normalize ( )
virtual

Member Data Documentation

readonly IPolygon NetTopologySuite.Geometries.Polygon.Empty = new GeometryFactory().CreatePolygon(null, null)
static

Represents an empty Polygon.

Property Documentation

override double NetTopologySuite.Geometries.Polygon.Area
get

Returns the area of this Polygon

Returns
override IGeometry NetTopologySuite.Geometries.Polygon.Boundary
get

override Dimension NetTopologySuite.Geometries.Polygon.BoundaryDimension
get

Returns the dimension of this Geometrys inherent boundary.

Returns
The dimension of the boundary of the class implementing this interface, whether or not this object is the empty point. Returns Dimension.False if the boundary is the empty point.

NOTE: make abstract, remove setter and change geoapi

override Coordinate NetTopologySuite.Geometries.Polygon.Coordinate
get

Returns a vertex of this Geometry (usually, but not necessarily, the first one).

The returned coordinate should not be assumed to be an actual Coordinate object used in the internal representation.

Returns

a Coordinate which is a vertex of this Geometry.

null if this Geometry is empty.

override Coordinate [] NetTopologySuite.Geometries.Polygon.Coordinates
get

Returns an array containing the values of all the vertices for this geometry.

If the geometry is a composite, the array will contain all the vertices for the components, in the order in which the components occur in the geometry.

In general, the array cannot be assumed to be the actual internal storage for the vertices. Thus modifying the array may not modify the geometry itself. Use the ICoordinateSequence.SetOrdinate method (possibly on the components) to modify the underlying data. If the coordinates are modified, IGeometry.GeometryChanged must be called afterwards.

Returns
The vertices of this Geometry.
See also
IGeometry.GeometryChanged, ICoordinateSequence.SetOrdinate
override Dimension NetTopologySuite.Geometries.Polygon.Dimension
get

Returns the dimension of this geometry.

The dimension of a geometry is is the topological dimension of its embedding in the 2-D Euclidean plane. In the NTS spatial model, dimension values are in the set {0,1,2}.

Note that this is a different concept to the dimension of the vertex Coordinates. The geometry dimension can never be greater than the coordinate dimension. For example, a 0-dimensional geometry (e.g. a Point) may have a coordinate dimension of 3 (X,Y,Z).

Returns
The topological dimensions of this geometry
ILineString NetTopologySuite.Geometries.Polygon.ExteriorRing
get

override string NetTopologySuite.Geometries.Polygon.GeometryType
get

Returns the name of this object's interface.

Returns
"Polygon"
ILinearRing [] NetTopologySuite.Geometries.Polygon.Holes
get

ILineString [] NetTopologySuite.Geometries.Polygon.InteriorRings
get

override bool NetTopologySuite.Geometries.Polygon.IsEmpty
get

override bool NetTopologySuite.Geometries.Polygon.IsRectangle
get

Returns
override double NetTopologySuite.Geometries.Polygon.Length
get

Returns the perimeter of this Polygon.

Returns
int NetTopologySuite.Geometries.Polygon.NumInteriorRings
get

override int NetTopologySuite.Geometries.Polygon.NumPoints
get

Returns the count of this Geometrys vertices. The Geometry s contained by composite Geometrys must be Geometry's; that is, they must implement NumPoints.

Returns
The number of vertices in this Geometry.
ILinearRing NetTopologySuite.Geometries.Polygon.Shell
get


The documentation for this class was generated from the following file: