Gets the a copy of the points in the requested ring of the Polygon.

Namespace:  ESRI.ArcGISExplorer.Geometry
Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.900 (2.0.0.900)

Syntax

C#
public IList<Point> GetRing(
	int ringIndex
)
Visual Basic (Declaration)
Public Function GetRing ( _
	ringIndex As Integer _
) As IList(Of Point)

Parameters

ringIndex
Type: System..::.Int32
The index of the ring within the Polygon

Return Value

An enumerable generic list of points which are copies of the points in the requested ring.

Remarks

GetPoint returns a copy of the Point at a specific pointIndex position within a specific ringIndex within the Polygon. Polygons are created and edited by-value, therefore there is no way to get a direct reference to the same Point that exists inside the Polygon; to change one of the points in a Polygon, use the SetPoint()()() method.

Examples

The code below shows how the GetRing and RemoveRing methods and RingCount property can be used to turn one multipart Polygon into multiple single part polygons. The code assumes there is an existing multipart Polygon called poly.
CopyC#
// Create a list to hold all the created polygons, 
System.Collections.Generic.List<Polygon> singlePrts = new System.Collections.Generic.List<Polygon>(pgon.RingCount);

// Use RingCount and GetRing to iterate through every ring except the first ring in the polygon.
for (int i = 1; i < pgon.RingCount; i++)
{
  // Create a new Polygon from the ring, and add to the list.
  // Note - simplifying will correct turn any inner rings (holes) into outer rings (boundaries).
  Polygon newPoly = GeometryOperations.Simplify(new Polygon(pgon.GetRing(i)));
  singlePrts.Add(newPoly);
}

// Remove the subsequent rings from the original Polygon and add the original Polygon to the list.
while (pgon.RingCount > 1)
{
  pgon.RemoveRing(1);
}
singlePrts.Add(pgon);
CopyVB.NET
' Create a list to hold all the created Polygons, 
Dim singlePrts As System.Collections.Generic.List(Of Polygon) = New System.Collections.Generic.List(Of Polygon)(poly.RingCount)

' Use RingCount and GetRing to iterate through every ring except the first ring in the polygon.
For i As Integer = 1 To poly.RingCount - 1
  ' Create a new Polygon from the ring, and add to the list.
  ' Note - simplifying will correct turn any inner rings (holes) into outer rings (boundaries).
  Dim newPoly As Polygon = GeometryOperations.Simplify(New Polygon(poly.GetRing(i)))
  singlePrts.Add(newPoly)
Next i

' Remove the subsequent rings from the original Polygon and add the original Polygon to the list.
While poly.RingCount > 1
  poly.RemoveRing(1)
End While
singlePrts.Add(poly)

Exceptions

ExceptionCondition
System..::.ArgumentOutOfRangeExceptionThe specified ringIndex must exist in the Polygon.
System..::.InvalidOperationExceptionAn empty Polygon cannot return a ring.

See Also

Relate Topics:
  AddPoint Method
  AddPoints Method
  AddRing Method
  Clone Method
  Close Method
  CreateFromXmlString Method
  GetLabelPoint Method
  GetPerimeter Method
  GetPoint Method
  GetRings Method
  GetXmlSchema Method
  InsertPoint Method
  InsertPoints Method
  InsertRing Method
  PointCount Method
  PointCountAllRings Method
  RemoveAllPoints Method
  RemovePointAt Method
  RemovePointsAt Method
  RemoveRing Method
  SetPoint Method
  SetPoints Method
  SetRing Method
  ToString Method
Created by Atop CHM to web converter,© 2009 all right reserved.