Adds a new ring to the Polygon by copying the specified set of points.

Namespace:  ESRI.ArcGISExplorer.Geometry

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public void AddRing(
	IEnumerable<Point> points
)
Visual Basic (Declaration)
Public Sub AddRing ( _
	points As IEnumerable(Of Point) _
)

Parameters

points
Type: System.Collections.Generic..::.IEnumerable<(Of <(Point>)>)

A generic enumerable set of Point objects to copy into the new ring within the Polygon.

Remarks

Use this overloaded method to help define a Polygon with multiple separate rings (a multipart Polygon).

There is no need to call AddRing to add the first ring to a newly created Polygon - the first ring of a Polygon will be automatically created when points are added to a new Polygon. However, in order to avoid accidental creation of more complex multipart polygons, subsequent rings must specifically be created by calling one of the AddRing methods.

Examples

The code below demonstrates how to create a multipart Polygon by adding and defining multiple rings using the AddRing overloads. The code creates a multipart Polygon with 2 separate outer rings, and a hole. The PointCountAllRings method can be used to count the total number of vertices in all rings of the Polygon. The code assumes there is a using (Imports in Visual Basic) statement for the Geometry namespace. Instances of the Point class are fully-qualified to avoid namespace clashes with System.Drawing.Point.
CopyC#
    // Create a Polygon with the default coordinate system and define the first ring in the usual way
    // by adding points in a clockwise direction.
    IEnumerable<ESRI.ArcGISExplorer.Geometry.Point> firstRing = new ESRI.ArcGISExplorer.Geometry.Point[] { 
new ESRI.ArcGISExplorer.Geometry.Point(0, 0), 
new ESRI.ArcGISExplorer.Geometry.Point(0, 1), 
new ESRI.ArcGISExplorer.Geometry.Point(1, 1), 
new ESRI.ArcGISExplorer.Geometry.Point(1, 0) };
    Polygon multipartPolygon = new Polygon(firstRing);

    // Now add a second inner ring (hole). Start by adding a new empty ring.
    multipartPolygon.AddRing();
    // As this is an inner ring, define the vertices in a counterclockwise direction.
    multipartPolygon.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.4));
    multipartPolygon.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.4));
    multipartPolygon.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.6));
    multipartPolygon.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.6));

    // Alternatively, a new ring can be added and defined at the same time using the 
    // AddRing overload. As this is an outer ring again, the vertices are clockwise.
    multipartPolygon.AddRing(new ESRI.ArcGISExplorer.Geometry.Point[] { 
new ESRI.ArcGISExplorer.Geometry.Point(2, 2), 
new ESRI.ArcGISExplorer.Geometry.Point(2, 3), 
new ESRI.ArcGISExplorer.Geometry.Point(3, 3), 
new ESRI.ArcGISExplorer.Geometry.Point(3, 2)});

    // The Close method will close each ring in the Polygon separately.
    multipartPolygon.Close();

    // The PointCountAllRings method can be used to sum the vertices in the Polygons rings.
    // DO NOT use PointCountAllRings to iterate through the points in a Polygon.
    int verticeCount = multipartPolygon.PointCountAllRings();
CopyVB.NET
' Create a Polygon with the default coordinate system and define the first ring in the usual way
' by adding points in a clockwise direction.
Dim firstRing As IEnumerable(Of ESRI.ArcGISExplorer.Geometry.Point) = New ESRI.ArcGISExplorer.Geometry.Point() { _
    New ESRI.ArcGISExplorer.Geometry.Point(0, 0), _
    New ESRI.ArcGISExplorer.Geometry.Point(0, 1), _
    New ESRI.ArcGISExplorer.Geometry.Point(1, 1), _
    New ESRI.ArcGISExplorer.Geometry.Point(1, 0)}
Dim multipartPolygon As Polygon = New Polygon(firstRing)

' Now add a second inner ring (hole). Start by adding a new empty ring.
multipartPolygon.AddRing()
' As this is an inner ring, define the vertices in a counterclockwise direction.
multipartPolygon.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.4))
multipartPolygon.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.4))
multipartPolygon.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.6))
multipartPolygon.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.6))

' Alternatively, a new ring can be added and defined at the same time using the 
' AddRing overload. As this is an outer ring again, the vertices are clockwise.
multipartPolygon.AddRing(New ESRI.ArcGISExplorer.Geometry.Point() { _
 New ESRI.ArcGISExplorer.Geometry.Point(2, 2), _
 New ESRI.ArcGISExplorer.Geometry.Point(2, 3), _
 New ESRI.ArcGISExplorer.Geometry.Point(3, 3), _
 New ESRI.ArcGISExplorer.Geometry.Point(3, 2)})

' The Close method will close each ring in the Polygon separately.
multipartPolygon.Close()

' The PointCountAllRings method can be used to sum the vertices in the Polygons rings.
' DO NOT use PointCountAllRings to iterate through the points in a Polygon.
Dim verticeCount As Integer = multipartPolygon.PointCountAllRings()

See Also