Table of Contents

Class Polygon

Namespace
NetTopologySuite.Geometries
Assembly
NetTopologySuite.dll

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).
public class Polygon : Geometry, IComparable, IComparable<Geometry>, IPolygonal
Inheritance
Polygon
Implements
Inherited Members

Constructors

Polygon(LinearRing)

Constructs a Polygon with the given exterior boundary.

public Polygon(LinearRing shell)

Parameters

shell LinearRing

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

Polygon(LinearRing, GeometryFactory)

Constructs a Polygon with the given exterior boundary.

public Polygon(LinearRing shell, GeometryFactory factory)

Parameters

shell LinearRing

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

factory GeometryFactory

Polygon(LinearRing, LinearRing[])

Initializes a new instance of the Polygon class.

public Polygon(LinearRing shell, LinearRing[] holes)

Parameters

shell LinearRing

The outer boundary of the new Polygon, or null or an empty LinearRing if the empty point is to be created.

holes LinearRing[]

The inner boundaries of the new Polygon , or null or empty LinearRings if the empty point is to be created.

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.

public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory)

Parameters

shell LinearRing

The outer boundary of the new Polygon, or null or an empty LinearRing if the empty point is to be created.

holes LinearRing[]

The inner boundaries of the new Polygon , or null or empty LinearRings if the empty point is to be created.

factory GeometryFactory

Fields

Empty

Represents an empty Polygon.

public static readonly Polygon Empty

Field Value

Polygon

Properties

Area

Returns the area of this Polygon

public override double Area { get; }

Property Value

double

Boundary

public override Geometry Boundary { get; }

Property Value

Geometry

BoundaryDimension

Returns the dimension of this Geometrys inherent boundary.

public override Dimension BoundaryDimension { get; }

Property Value

Dimension

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.

Coordinate

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

public override Coordinate Coordinate { get; }

Property Value

Coordinate

a Coordinate which is a vertex of this Geometry.

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.

public override Coordinate[] Coordinates { get; }

Property Value

Coordinate[]

The vertices of this Geometry.

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

Dimension

Returns the dimension of this geometry.

public override Dimension Dimension { get; }

Property Value

Dimension

The topological dimensions of this geometry

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

public LineString ExteriorRing { get; }

Property Value

LineString

GeometryType

Returns the name of this object's interface.

public override string GeometryType { get; }

Property Value

string

"Polygon"

Holes

public LinearRing[] Holes { get; }

Property Value

LinearRing[]

InteriorRings

public LineString[] InteriorRings { get; }

Property Value

LineString[]

IsEmpty

public override bool IsEmpty { get; }

Property Value

bool

IsRectangle

Tests whether this is a rectangular Polygon.

public override bool IsRectangle { get; }

Property Value

bool

true if the geometry is a rectangle.

Length

Returns the perimeter of this Polygon.

public override double Length { get; }

Property Value

double

NumInteriorRings

public int NumInteriorRings { get; }

Property Value

int

NumPoints

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

public override int NumPoints { get; }

Property Value

int

The number of vertices in this Geometry.

OgcGeometryType

public override OgcGeometryType OgcGeometryType { get; }

Property Value

OgcGeometryType

Shell

public LinearRing Shell { get; }

Property Value

LinearRing

SortIndex

Gets a value to sort the geometry

protected override Geometry.SortIndexValue SortIndex { get; }

Property Value

Geometry.SortIndexValue

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

Apply(ICoordinateFilter)

public override void Apply(ICoordinateFilter filter)

Parameters

filter ICoordinateFilter

Apply(ICoordinateSequenceFilter)

public override void Apply(ICoordinateSequenceFilter filter)

Parameters

filter ICoordinateSequenceFilter

Apply(IEntireCoordinateSequenceFilter)

public override void Apply(IEntireCoordinateSequenceFilter filter)

Parameters

filter IEntireCoordinateSequenceFilter

Apply(IGeometryComponentFilter)

public override void Apply(IGeometryComponentFilter filter)

Parameters

filter IGeometryComponentFilter

Apply(IGeometryFilter)

public override void Apply(IGeometryFilter filter)

Parameters

filter IGeometryFilter

CompareToSameClass(object)

protected override int CompareToSameClass(object o)

Parameters

o object

Returns

int

CompareToSameClass(object, IComparer<CoordinateSequence>)

protected override int CompareToSameClass(object other, IComparer<CoordinateSequence> comparer)

Parameters

other object
comparer IComparer<CoordinateSequence>

Returns

int

ComputeEnvelopeInternal()

protected override Envelope ComputeEnvelopeInternal()

Returns

Envelope

ConvexHull()

public override Geometry ConvexHull()

Returns

Geometry

CopyInternal()

protected override Geometry CopyInternal()

Returns

Geometry

EqualsExact(Geometry, double)

public override bool EqualsExact(Geometry other, double tolerance)

Parameters

other Geometry
tolerance double

Returns

bool

GetInteriorRingN(int)

public LineString GetInteriorRingN(int n)

Parameters

n int

Returns

LineString

GetOrdinates(Ordinate)

Gets an array of double ordinate values

public override double[] GetOrdinates(Ordinate ordinate)

Parameters

ordinate Ordinate

The ordinate index

Returns

double[]

An array of ordinate values

Normalize()

public override void Normalize()

Reverse()

[Obsolete("Call Geometry.Reverse()")]
public override Geometry Reverse()

Returns

Geometry

ReverseInternal()

The actual implementation of the Reverse() function for POLYGONs

protected override Geometry ReverseInternal()

Returns

Geometry

A reversed geometry