ArcGIS Explorer Component Help |
Polygon..::.PointCount Method (Int32) |
Polygon Class Example See Also |
Gets the number of points in the specified ring of a multipart Polygon.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public int PointCount( int ringIndex ) |
Visual Basic (Declaration) |
---|
Public Function PointCount ( _ ringIndex As Integer _ ) As Integer |
Parameters
- ringIndex
- Type: System..::.Int32
The ring to count points of.
Return Value
An integer indicating the number of points in the specified ring.Remarks
Use this method to return the number of Points in a specific ring of a multipart Polygon. This method is often used with other methods which have a ring index parameter; for example, a very common use is to use PointCount(int) with GetPoint(Int32, Int32) to iterate through all of the points in a ring by point index number.
Alternatives are the PointCount()()() overload which counts points in the first ring (ideal if using single part polygons), or the PointCountAllRings()()() method which counts the total number of points in all rings in the Polygon.
Examples
The code below shows how to use GetPoint and PointCount overloads to enumerate over each vertex in each ring of
a multipart Polygon by ring and point index number.
The code assumes there is an existing multipart Polygon called poly. Instances of the
Point class are fully-qualified to avoid namespace clashes with System.Drawing.Point.
CopyC#
// For an existing single part Polygon called pline, use PointCount to iterate points by index number. for (int partIndx = 0; partIndx < pgon.RingCount; partIndx++) { for (int pointIndx = 0; pointIndx < pgon.PointCount(); pointIndx++) { // Use GetPoint overload to get a copy of the specific point in the specific ring. System.Diagnostics.Debug.WriteLine(pgon.GetPoint(partIndx, pointIndx).ToString()); } }
CopyVB.NET
' For an existing single part Polygon called poly, use PointCount to iterate points by index number. For partIndx As Integer = 0 To poly.RingCount - 1 For pointIndx As Integer = 0 To poly.PointCount(partIndx) - 1 ' Use GetPoint overload to get a copy of the specific point in the specific ring. System.Diagnostics.Debug.WriteLine(poly.GetPoint(partIndx, pointIndx).ToString()) Next pointIndx Next partIndx
Exceptions
Exception | Condition |
---|---|
System..::.ArgumentOutOfRangeException | the specified ringIndex must already exist in the Polygon. |
System..::.InvalidOperationException | An empty Polygon cannot return a PointCount. |