GeoPolygon Class

A polygon, such as a country or a lake: an exterior ring, then the rings of its holes, as in GeoJSON.

public sealed class GeoPolygon : GeoGeometry
Inheritance
GeoGeometry GeoPolygon

Constructors

NameDescription
GeoPolygon(IEnumerable<IEnumerable<GeoPosition>>)Initializes a new instance of the GeoPolygon class.

GeoPolygon(IEnumerable<IEnumerable<GeoPosition>>)

GeoPolygon.cs

Initializes a new instance of the GeoPolygon class.

public GeoPolygon(IEnumerable<IEnumerable<GeoPosition>> rings)

Parameters

rings IEnumerable<IEnumerable<GeoPosition>>
The rings: the exterior ring first, then the holes. A ring may repeat its first position at its end.

Properties

NameDescription
RingsGets the rings: the exterior ring first, then the holes.
TypeGets the type of the geometry.

Gets the rings: the exterior ring first, then the holes.

public IReadOnlyList<IReadOnlyList<GeoPosition>> Rings { get; }

Gets the type of the geometry.

public override GeoGeometryType Type { get; }

Property value

GeoGeometryType

Methods

NameDescription
Contains(GeoPosition)Gets a value that indicates whether a position is inside the polygon and outside its holes.
Contains(GeoPosition, GeoEdgeType)Gets a value that indicates whether a position is inside the polygon and outside its holes, whose edges are drawn as an edge type says.
GetPositions()Gets the positions of the geometry: every position of every point, line and ring, in order.

Contains overloads

Contains(GeoPosition)

GeoPolygon.cs

Gets a value that indicates whether a position is inside the polygon and outside its holes.

public bool Contains(GeoPosition position)
Parameters
position GeoPosition
The position. The altitude is ignored.
Returns

bool true when the position is inside the polygon; otherwise, false.

Remarks

The test is made on the longitudes and latitudes, as on an equirectangular map: the edges are straight in degrees, not great circles, as GeoEdgeType.Planar says. A polygon that crosses the 180th meridian must be split along it first, with GeoGeometry.SplitAtAntimeridian. The result is unspecified for a position on an edge.

Contains(GeoPosition, GeoEdgeType)

GeoPolygon.cs

Gets a value that indicates whether a position is inside the polygon and outside its holes, whose edges are drawn as an edge type says.

public bool Contains(GeoPosition position, GeoEdgeType edgeType)
Parameters
position GeoPosition
The position. The altitude is ignored.
edgeType GeoEdgeType
How the edges are drawn.
Returns

bool true when the position is inside the polygon; otherwise, false.

Exceptions
ArgumentOutOfRangeException
edgeType is not a value of GeoEdgeType.
Remarks

With GeoEdgeType.Geodesic, each edge is the shortest great-circle arc between its ends, on a sphere: a polygon may cross the 180th meridian without being split. The rings may turn in either direction: the polygon is the side of its exterior ring that does not contain the poles, or, for a ring that goes around a pole, such as the coast of Antarctica, the side that contains the pole it is nearest to.

The result is unspecified for a position on an edge.

GetPositions()

GeoPolygon.cs

Gets the positions of the geometry: every position of every point, line and ring, in order.

public override IEnumerable<GeoPosition> GetPositions()

Returns

IEnumerable<GeoPosition> The positions.