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
GeoGeometryGeoPolygon
Constructors
| Name | Description |
|---|---|
| GeoPolygon(IEnumerable<IEnumerable<GeoPosition>>) | Initializes a new instance of the GeoPolygon class. |
GeoPolygon(IEnumerable<IEnumerable<GeoPosition>>)
GeoPolygon.csInitializes a new instance of the GeoPolygon class.
public GeoPolygon(IEnumerable<IEnumerable<GeoPosition>> rings)Parameters
ringsIEnumerable<IEnumerable<GeoPosition>>- The rings: the exterior ring first, then the holes. A ring may repeat its first position at its end.
Properties
| Name | Description |
|---|---|
| Rings | Gets the rings: the exterior ring first, then the holes. |
| Type | Gets the type of the geometry. |
Rings
GeoPolygon.csGets the rings: the exterior ring first, then the holes.
public IReadOnlyList<IReadOnlyList<GeoPosition>> Rings { get; }Property value
Type
GeoPolygon.csMethods
| Name | Description |
|---|---|
| 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.csGets a value that indicates whether a position is inside the polygon and outside its holes.
public bool Contains(GeoPosition position)Parameters
positionGeoPosition- 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.csGets 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
positionGeoPosition- The position. The altitude is ignored.
edgeTypeGeoEdgeType- How the edges are drawn.
Returns
bool true when the position is inside the polygon; otherwise, false.
Exceptions
ArgumentOutOfRangeExceptionedgeTypeis not a value ofGeoEdgeType.
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.csGets 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.