Adds a new empty path to the Polyline.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public void AddPath() |
Visual Basic (Declaration) |
---|
Public Sub AddPath |
Remarks
Use this overloaded method to help define a Polyline with multiple separate paths (a multipart Polyline).
There is no need to call AddPath to add the first path to a newly created Polyline - the first path of a Polyline will be automatically created when points are added to a new Polyline. However, in order to avoid accidental creation of more complex multipart polylines, subsequent path must specifically be created by calling one of the AddPath methods.
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()