Class Polygon
Represents a polygon with linear edges, which may include holes. The outer boundary (shell) and inner boundaries (holes) of the polygon are represented by {@link LinearRing}s. 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. APolygon
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).
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
[Serializable]
public class Polygon : Geometry, IComparable, IComparable<Geometry>, IPolygonal
Constructors
| Edit this page View SourcePolygon(LinearRing)
Constructs a Polygon
with the given exterior boundary.
Declaration
public Polygon(LinearRing shell)
Parameters
Type | Name | Description |
---|---|---|
LinearRing | shell | The outer boundary of the new |
Polygon(LinearRing, GeometryFactory)
Constructs a Polygon
with the given exterior boundary.
Declaration
public Polygon(LinearRing shell, GeometryFactory factory)
Parameters
Type | Name | Description |
---|---|---|
LinearRing | shell | The outer boundary of the new |
GeometryFactory | factory |
Polygon(LinearRing, LinearRing[])
Initializes a new instance of the Polygon class.
Declaration
public Polygon(LinearRing shell, LinearRing[] holes)
Parameters
Type | Name | Description |
---|---|---|
LinearRing | shell | The outer boundary of the new |
LinearRing[] | holes | The inner boundaries of the new |
Remarks
For create this Geometry is used a standard GeometryFactory
with PrecisionModel ==
Floating.
Polygon(LinearRing, LinearRing[], GeometryFactory)
Constructs a Polygon
with the given exterior boundary and
interior boundaries.
Declaration
public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory)
Parameters
Type | Name | Description |
---|---|---|
LinearRing | shell | The outer boundary of the new |
LinearRing[] | holes | The inner boundaries of the new |
GeometryFactory | factory |
Fields
| Edit this page View SourceEmpty
Represents an empty Polygon
.
Declaration
public static readonly Polygon Empty
Field Value
Type | Description |
---|---|
Polygon |
Properties
| Edit this page View SourceArea
Returns the area of this Polygon
Declaration
public override double Area { get; }
Property Value
Type | Description |
---|---|
double |
Overrides
| Edit this page View SourceBoundary
Declaration
public override Geometry Boundary { get; }
Property Value
Type | Description |
---|---|
Geometry |
Overrides
| Edit this page View SourceBoundaryDimension
Returns the dimension of this Geometry
s inherent boundary.
Declaration
public override Dimension BoundaryDimension { get; }
Property Value
Type | Description |
---|---|
Dimension | The dimension of the boundary of the class implementing this
interface, whether or not this object is the empty point. Returns
|
Overrides
| Edit this page View SourceCoordinate
Returns a vertex of this Geometry
(usually, but not necessarily, the first one).
Declaration
public override Coordinate Coordinate { get; }
Property Value
Type | Description |
---|---|
Coordinate | a Coordinate which is a vertex of this |
Overrides
Remarks
The returned coordinate should not be assumed to be an actual Coordinate object used in the internal representation.
Coordinates
Returns an array containing the values of all the vertices for this geometry.
Declaration
public override Coordinate[] Coordinates { get; }
Property Value
Type | Description |
---|---|
Coordinate[] | The vertices of this |
Overrides
Remarks
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 SetOrdinate(int, int, double) method (possibly on the components) to modify the underlying data. If the coordinates are modified, GeometryChanged() must be called afterwards.
See Also
| Edit this page View SourceDimension
Returns the dimension of this geometry.
Declaration
public override Dimension Dimension { get; }
Property Value
Type | Description |
---|---|
Dimension | The topological dimensions of this geometry |
Overrides
Remarks
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).
ExteriorRing
Declaration
public LineString ExteriorRing { get; }
Property Value
Type | Description |
---|---|
LineString |
GeometryType
Returns the name of this object's interface.
Declaration
public override string GeometryType { get; }
Property Value
Type | Description |
---|---|
string | "Polygon" |
Overrides
| Edit this page View SourceHoles
Declaration
public LinearRing[] Holes { get; }
Property Value
Type | Description |
---|---|
LinearRing[] |
InteriorRings
Declaration
public LineString[] InteriorRings { get; }
Property Value
Type | Description |
---|---|
LineString[] |
IsEmpty
Declaration
public override bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceIsRectangle
Tests whether this is a rectangular Polygon.
Declaration
public override bool IsRectangle { get; }
Property Value
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceLength
Returns the perimeter of this Polygon
.
Declaration
public override double Length { get; }
Property Value
Type | Description |
---|---|
double |
Overrides
| Edit this page View SourceNumInteriorRings
Declaration
public int NumInteriorRings { get; }
Property Value
Type | Description |
---|---|
int |
NumPoints
Returns the count of this Geometry
s vertices. The Geometry
s contained by composite Geometry
s must be
Geometry's; that is, they must implement NumPoints
.
Declaration
public override int NumPoints { get; }
Property Value
Type | Description |
---|---|
int | The number of vertices in this |
Overrides
| Edit this page View SourceOgcGeometryType
Gets the OGC geometry type
Declaration
public override OgcGeometryType OgcGeometryType { get; }
Property Value
Type | Description |
---|---|
OgcGeometryType |
Overrides
| Edit this page View SourceShell
Declaration
public LinearRing Shell { get; }
Property Value
Type | Description |
---|---|
LinearRing |
SortIndex
Gets a value to sort the geometry
Declaration
protected override Geometry.SortIndexValue SortIndex { get; }
Property Value
Type | Description |
---|---|
Geometry.SortIndexValue |
Overrides
Remarks
NOTE:
For JTS v1.17 this property's getter has been renamed to getTypeCode()
.
In order not to break binary compatibility we did not follow.
Methods
| Edit this page View SourceApply(ICoordinateFilter)
Performs an operation with or on this Geometry
's coordinates.
Declaration
public override void Apply(ICoordinateFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ICoordinateFilter | filter | The filter to apply to this |
Overrides
Remarks
If this method modifies any coordinate values, GeometryChanged() must be called to update the geometry state. Note that you cannot use this method to modify this Geometry if its underlying CoordinateSequence's #get method returns a copy of the Coordinate, rather than the actual Coordinate stored (if it even stores Coordinate objects at all).
Apply(ICoordinateSequenceFilter)
Performs an operation on the coordinates in this Geometry
's CoordinateSequences.
Declaration
public override void Apply(ICoordinateSequenceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ICoordinateSequenceFilter | filter | The filter to apply |
Overrides
Remarks
If the filter reports that a coordinate value has been changed, GeometryChanged() will be called automatically.
Apply(IEntireCoordinateSequenceFilter)
Performs an operation on this Geometry
's CoordinateSequences.
Declaration
public override void Apply(IEntireCoordinateSequenceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IEntireCoordinateSequenceFilter | filter | The filter to apply |
Overrides
Remarks
If the filter reports that a coordinate value has been changed, GeometryChanged() will be called automatically.
Apply(IGeometryComponentFilter)
Performs an operation with or on this Geometry and its component Geometry's. Only GeometryCollections and Polygons have component Geometry's; for Polygons they are the LinearRings of the shell and holes.
Declaration
public override void Apply(IGeometryComponentFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IGeometryComponentFilter | filter | The filter to apply to this |
Overrides
| Edit this page View SourceApply(IGeometryFilter)
Performs an operation with or on this Geometry
and its
subelement Geometry
s (if any).
Only GeometryCollections and subclasses
have subelement Geometry's.
Declaration
public override void Apply(IGeometryFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IGeometryFilter | filter | The filter to apply to this |
Overrides
| Edit this page View SourceCompareToSameClass(object)
Declaration
protected override int CompareToSameClass(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
Returns
Type | Description |
---|---|
int |
Overrides
| Edit this page View SourceCompareToSameClass(object, IComparer<CoordinateSequence>)
Declaration
protected override int CompareToSameClass(object other, IComparer<CoordinateSequence> comparer)
Parameters
Type | Name | Description |
---|---|---|
object | other | |
IComparer<CoordinateSequence> | comparer |
Returns
Type | Description |
---|---|
int |
Overrides
| Edit this page View SourceComputeEnvelopeInternal()
Declaration
protected override Envelope ComputeEnvelopeInternal()
Returns
Type | Description |
---|---|
Envelope |
Overrides
| Edit this page View SourceConvexHull()
Declaration
public override Geometry ConvexHull()
Returns
Type | Description |
---|---|
Geometry |
Overrides
| Edit this page View SourceCopyInternal()
An internal method to copy subclass-specific geometry data.
Declaration
protected override Geometry CopyInternal()
Returns
Type | Description |
---|---|
Geometry | A copy of the target geometry object. |
Overrides
| Edit this page View SourceEqualsExact(Geometry, double)
Declaration
public override bool EqualsExact(Geometry other, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | other | |
double | tolerance |
Returns
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceGetInteriorRingN(int)
Declaration
public LineString GetInteriorRingN(int n)
Parameters
Type | Name | Description |
---|---|---|
int | n |
Returns
Type | Description |
---|---|
LineString |
GetOrdinates(Ordinate)
Gets an array of double ordinate values
Declaration
public override double[] GetOrdinates(Ordinate ordinate)
Parameters
Type | Name | Description |
---|---|---|
Ordinate | ordinate | The ordinate index |
Returns
Type | Description |
---|---|
double[] | An array of ordinate values |
Overrides
| Edit this page View SourceNormalize()
Declaration
public override void Normalize()
Overrides
| Edit this page View SourceReverse()
Computes a new geometry which has all component coordinate sequences in reverse order (opposite orientation) to this one.
Declaration
[Obsolete("Call Geometry.Reverse()")]
public override Geometry Reverse()
Returns
Type | Description |
---|---|
Geometry | A reversed geometry |
Overrides
Remarks
Don't override this function, implement ReverseInternal().
ReverseInternal()
The actual implementation of the Reverse() function for POLYGON
s
Declaration
protected override Geometry ReverseInternal()
Returns
Type | Description |
---|---|
Geometry | A reversed geometry |