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.
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).
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
[Serializable]
public class Polygon : Geometry, IComparable, IComparable<Geometry>, IPolygonal
Constructors
| Improve this Doc 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
| Improve this Doc View SourceEmpty
Represents an empty Polygon
.
Declaration
public static readonly Polygon Empty
Field Value
Type | Description |
---|---|
Polygon |
Properties
| Improve this Doc View SourceArea
Returns the area of this Polygon
Declaration
public override double Area { get; }
Property Value
Type | Description |
---|---|
Double |
Overrides
| Improve this Doc View SourceBoundary
Declaration
public override Geometry Boundary { get; }
Property Value
Type | Description |
---|---|
Geometry |
Overrides
| Improve this Doc 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
| Improve this Doc 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(Int32, Int32, Double) method (possibly on the components) to modify the underlying data. If the coordinates are modified, GeometryChanged() must be called afterwards.
See Also
| Improve this Doc 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
| Improve this Doc 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 |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceIsRectangle
Tests whether this is a rectangular Polygon.
Declaration
public override bool IsRectangle { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Overrides
| Improve this Doc View SourceLength
Returns the perimeter of this Polygon
.
Declaration
public override double Length { get; }
Property Value
Type | Description |
---|---|
Double |
Overrides
| Improve this Doc View SourceNumInteriorRings
Declaration
public int NumInteriorRings { get; }
Property Value
Type | Description |
---|---|
Int32 |
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 |
---|---|
Int32 | The number of vertices in this |
Overrides
| Improve this Doc View SourceOgcGeometryType
Declaration
public override OgcGeometryType OgcGeometryType { get; }
Property Value
Type | Description |
---|---|
OgcGeometryType |
Overrides
| Improve this Doc 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
| Improve this Doc View SourceApply(ICoordinateFilter)
Declaration
public override void Apply(ICoordinateFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ICoordinateFilter | filter |
Overrides
| Improve this Doc View SourceApply(ICoordinateSequenceFilter)
Declaration
public override void Apply(ICoordinateSequenceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
ICoordinateSequenceFilter | filter |
Overrides
| Improve this Doc View SourceApply(IEntireCoordinateSequenceFilter)
Declaration
public override void Apply(IEntireCoordinateSequenceFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IEntireCoordinateSequenceFilter | filter |
Overrides
| Improve this Doc View SourceApply(IGeometryComponentFilter)
Declaration
public override void Apply(IGeometryComponentFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IGeometryComponentFilter | filter |
Overrides
| Improve this Doc View SourceApply(IGeometryFilter)
Declaration
public override void Apply(IGeometryFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IGeometryFilter | filter |
Overrides
| Improve this Doc View SourceCompareToSameClass(Object)
Declaration
protected override int CompareToSameClass(object o)
Parameters
Type | Name | Description |
---|---|---|
Object | o |
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc 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 |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceComputeEnvelopeInternal()
Declaration
protected override Envelope ComputeEnvelopeInternal()
Returns
Type | Description |
---|---|
Envelope |
Overrides
| Improve this Doc View SourceConvexHull()
Declaration
public override Geometry ConvexHull()
Returns
Type | Description |
---|---|
Geometry |
Overrides
| Improve this Doc View SourceCopyInternal()
Declaration
protected override Geometry CopyInternal()
Returns
Type | Description |
---|---|
Geometry |
Overrides
| Improve this Doc View SourceEqualsExact(Geometry, Double)
Declaration
public override bool EqualsExact(Geometry other, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | other | |
Double | tolerance |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceGetInteriorRingN(Int32)
Declaration
public LineString GetInteriorRingN(int n)
Parameters
Type | Name | Description |
---|---|---|
Int32 | 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
| Improve this Doc View SourceNormalize()
Declaration
public override void Normalize()
Overrides
| Improve this Doc View SourceReverse()
Declaration
[Obsolete("Call Geometry.Reverse()")]
public override Geometry Reverse()
Returns
Type | Description |
---|---|
Geometry |
Overrides
| Improve this Doc View SourceReverseInternal()
The actual implementation of the Reverse() function for POLYGON
s
Declaration
protected override Geometry ReverseInternal()
Returns
Type | Description |
---|---|
Geometry | A reversed geometry |