Gets the total number of points in all of the rings in a single part or multipart Polygon.

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

Syntax

C#
public int PointCountAllRings()
Visual Basic (Declaration)
Public Function PointCountAllRings As Integer

Return Value

The total number of points in all rings in the Polygon.

Remarks

Generally, methods without a parameter indicating a specific ring index are applicable to a single-part Polygon or to the first part of a multipart Polygon, whereas methods with a ring index parameter apply to the specified ring only. The PointCountAllRings method provides an alternative which applies to both single part and multipart polygons and always counts all of the points in all of the rings.

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

Relate Topics:
  AddPoint Method
  AddPoints Method
  AddRing Method
  Clone Method
  Close Method
  CreateFromXmlString Method
  GetLabelPoint Method
  GetPerimeter Method
  GetPoint Method
  GetRing Method
  GetRings Method
  GetXmlSchema Method
  InsertPoint Method
  InsertPoints Method
  InsertRing Method
  PointCount 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.