ArcGIS Explorer Component Help |
GeodesicUtilities..::.Length Method |
GeodesicUtilities Class Example See Also |
Returns the geodesic length of a Polyline in the requested linear units.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static double Length( Polyline poly, Unit linearUnit ) |
Visual Basic (Declaration) |
---|
Public Shared Function Length ( _ poly As Polyline, _ linearUnit As Unit _ ) As Double |
Parameters
- poly
- Type: ESRI.ArcGISExplorer.Geometry..::.Polyline
The polyline to measure.
- linearUnit
- Type: ESRI.ArcGISExplorer.Geometry..::.Unit
The linear units of the returned measurement.
Return Value
The length, in linearUnit, of the Polyline poly, measured geodesically.Remarks
Geodesic measurements account for the curvature of the earths surface.
Examples
The code below shows how the Length property can be used to retrieve the length of a Polyline with linear
units (a projected coordinate system). It also shows getting the length of a Polyline which has angular
units (a geographic coordinate system) by using the GeodesicUtilities class Length method to return the
length in chosen linear units.
CopyC#
// 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);
CopyVB.NET
' 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)