Share via


GeoPolygon Class

Definition

Represents a polygon consisting of outer ring and optional inner rings.

[System.Text.Json.Serialization.JsonConverter(typeof(Azure.Core.GeoJson.GeoJsonConverter))]
public sealed class GeoPolygon : Azure.Core.GeoJson.GeoObject
[<System.Text.Json.Serialization.JsonConverter(typeof(Azure.Core.GeoJson.GeoJsonConverter))>]
type GeoPolygon = class
    inherit GeoObject
Public NotInheritable Class GeoPolygon
Inherits GeoObject
Inheritance
GeoPolygon
Attributes

Examples

Creating a polygon:

var polygon = new GeoPolygon(new[]
{
    new GeoPosition(-122.108727, 47.649383),
    new GeoPosition(-122.081538, 47.640846),
    new GeoPosition(-122.078634, 47.576066),
    new GeoPosition(-122.112686, 47.578559),
    new GeoPosition(-122.108727, 47.649383),
});

Creating a polygon with holes:

var polygon = new GeoPolygon(new[]
{
    // Outer ring
    new GeoLinearRing(new[]
    {
        new GeoPosition(-122.108727, 47.649383),
        new GeoPosition(-122.081538, 47.640846),
        new GeoPosition(-122.078634, 47.576066),
        new GeoPosition(-122.112686, 47.578559),
        // Last position same as first
        new GeoPosition(-122.108727, 47.649383),
    }),
    // Inner ring
    new GeoLinearRing(new[]
    {
        new GeoPosition(-122.102370, 47.607370),
        new GeoPosition(-122.083488, 47.608007),
        new GeoPosition(-122.085419, 47.597879),
        new GeoPosition(-122.107005, 47.596895),
        // Last position same as first
        new GeoPosition(-122.102370, 47.607370),
    })
});

Constructors

GeoPolygon(IEnumerable<GeoLinearRing>)

Initializes new instance of GeoPolygon.

GeoPolygon(IEnumerable<GeoLinearRing>, GeoBoundingBox, IReadOnlyDictionary<String,Object>)

Initializes new instance of GeoPolygon.

GeoPolygon(IEnumerable<GeoPosition>)

Initializes new instance of GeoPolygon.

Properties

BoundingBox

Represents information about the coordinate range of the GeoObject.

(Inherited from GeoObject)
Coordinates

Returns a view over the coordinates array that forms this geometry.

OuterRing

Returns the outer ring of the polygon.

Rings

Gets a set of rings that form the polygon.

Type

Gets the GeoJSON type of this object.

Methods

ToString()

Converts an instance of GeoObject to a GeoJSON representation.

(Inherited from GeoObject)
TryGetCustomProperty(String, Object)

Tries to get a value of a custom property associated with the GeoObject.

(Inherited from GeoObject)

Applies to