Assembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
Field Value
A double indicating the length of the Polyline.Remarks
For geometries with linear units (those with a projected coordinate system), the units of measurement of the Length property are the same as the units of the CoordinateSystem of the geometry (Geometry.CoordinateSystem.Units).
Note: |
---|
Geometries with geographical coordinate systems have angular units. Angular units are not a rational measurement for length; angular units vary according to their location on the earth, meaning the Length of two geometries at different locations in angular units would not be comparable. This API indicates this by throwing an exception. The GeodesicUtilities class offers helper methods to retrieve spatial properties such as Length by returning the value in a specified linear unit. |
Examples
// Create a Polyline with a projected coordinate system. Polyline bngPolyline = new Polyline(CoordinateSystem.ProjectedCoordinateSystems.NationalGrids.Europe.BritishNationalGrid); bngPolyline.AddPoints(new ESRI.ArcGISExplorer.Geometry.Point[] { new ESRI.ArcGISExplorer.Geometry.Point(326872.482358681, 673940.581779784), new ESRI.ArcGISExplorer.Geometry.Point(326937.296501129, 673957.506541019), new ESRI.ArcGISExplorer.Geometry.Point(326953.836608697, 673895.000320552)}); // For geometries with projected coordinate systems, the Length can be retrieved directly. // British national grid uses Meters as its unit. double bngLength = bngPolyline.Length; // Project the Polyline to create a geometry with a geographic coordinate system. Polyline wgs84Polyline = (Polyline)GeometryOperations.Project(bngPolyline, CoordinateSystem.GeographicCoordinateSystems.World.WGS1984, new GeographicTransformation(1195)); // Use GeodesicUtilities to get Length for a geometry with a geographic coordinate system, // which has angular units double wgs84Length = GeodesicUtilities.Length(wgs84Polyline, Unit.Linear.Meters);
' Create a Polyline with a projected coordinate system. Dim bngPolyline As New Polyline(CoordinateSystem.ProjectedCoordinateSystems.NationalGrids.Europe.BritishNationalGrid) bngPolyline.AddPoints(New ESRI.ArcGISExplorer.Geometry.Point() {New ESRI.ArcGISExplorer.Geometry.Point(326872.482358681, 673940.581779784), New ESRI.ArcGISExplorer.Geometry.Point(326937.296501129, 673957.506541019), New ESRI.ArcGISExplorer.Geometry.Point(326953.836608697, 673895.000320552)}) ' For geometries with projected coordinate systems, the Length can be retrieved directly. ' British national grid uses Meters as its unit. Dim bngLength As Double = bngPolyline.Length ' Project the Polyline to create a geometry with a geographic coordinate system. Dim wgs84Polyline As Polyline = CType(GeometryOperations.Project(bngPolyline, CoordinateSystem.GeographicCoordinateSystems.World.WGS1984, New GeographicTransformation(1195)), Polyline) ' Use GeodesicUtilities to get Length for a geometry with a geographic coordinate system, ' which has angular units Dim wgs84Length As Double = GeodesicUtilities.Length(wgs84Polyline, Unit.Linear.Meters)
Exceptions
Exception | Condition |
---|---|
System..::.NotSupportedException | Getting the Length of a Polyline in angular units is not supported; try using the GeodesicUtilities class and specifying a linear unit. |