ArcGIS Explorer Component Help |
Polyline..::.PointCountAllPaths Method |
Polyline Class Example See Also |
Gets the total number of points in all of the paths in a single part or multipart Polyline.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public int PointCountAllPaths() |
Visual Basic (Declaration) |
---|
Public Function PointCountAllPaths As Integer |
Return Value
The total number of points in all paths in the Polyline.Remarks
Generally, methods without a parameter indicating a specific path index are applicable to a single-part Polyline or to the first part of a multipart Polyline, whereas methods with a path index parameter apply to the specified path only. The PointCountAllPaths method provides an alternative which applies to both single part and multipart polylines and always counts all of the points in all of the paths.
Examples
The code below demonstrates how to create a multipart Polyline by adding and defining multiple path using
the AddPath overloads. The code creates a multipart Polyline with 2 separate paths. The
PointCountAllPaths method can be used to count the total number of vertices in all paths of the Polyline.
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 Polyline with the default coordinate system and define the first path by adding points. IEnumerable<ESRI.ArcGISExplorer.Geometry.Point> firstPath = 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) }; Polyline multipartPolyline = new Polyline(firstPath); // Now add a second path. Start by adding a new empty path. multipartPolyline.AddPath(); multipartPolyline.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.4)); multipartPolyline.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.4)); multipartPolyline.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.6)); multipartPolyline.AddPoint(1, new ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.6)); // Alternatively, a new path can be added and defined at the same time using the // AddPath overload. multipartPolyline.AddPath(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 PointCountAllPaths method can be used to sum the vertices in the Polylines paths. // DO NOT use PointCountAllPaths to iterate through the points in a Polyline. int verticeCount = multipartPolyline.PointCountAllPaths();
CopyVB.NET
' Create a Polyline with the default coordinate system and define the first path by adding points. Dim firstPath 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 multipartPolyline As Polyline = New Polyline(firstPath) ' Now add a second path. Start by adding a new empty path. multipartPolyline.AddPath() multipartPolyline.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.4)) multipartPolyline.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.4)) multipartPolyline.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.6, 0.6)) multipartPolyline.AddPoint(1, New ESRI.ArcGISExplorer.Geometry.Point(0.4, 0.6)) ' Alternatively, a new path can be added and defined at the same time using the ' AddPath overload. multipartPolyline.AddPath(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 PointCountAllPaths method can be used to sum the vertices in the Polylines paths. ' DO NOT use PointCountAllPaths to iterate through the points in a Polyline. Dim verticeCount As Integer = multipartPolyline.PointCountAllPaths()