CommonServiceSoap.GetGreatCircleDistances Method

CommonServiceSoap.GetGreatCircleDistances Method

Takes an array of latitude and longitude pairs, and returns an array of great circle distances between the specified points. Distances can be returned in either kilometers or miles. Given n elements in the incoming array, the method returns n-1 elements in the return array.


Public Function GetGreatCircleDistances (latLongs As [Namespace].LatLong() ) As System.Double()

    

[C#]

public System.Double[] GetGreatCircleDistances ( LatLong[] latLongs);
   

Parameters

  • latLongs
    An array of latitude and longitude pairs (LatLong[] objects). The array can contain from 2 to 500 items.

Remarks

  • Entry x in the output array returns the distance between points x and x+1 in the input array. For example, for an input array with points A, B, and C, the output array returns an array of distances for AB and BC.

Example

[Visual Basic]

'Get the distance between two latitude and longitude coordinates
Dim commonService As New CommonServiceSoap()
Dim myLatLong(1) As LatLong
Dim returnDistances() As Double
myLatLong(0) = New LatLong()
myLatLong(1) = New LatLong()
myLatLong(0).Latitude = 47.59975
myLatLong(0).Longitude = -122.33456
myLatLong(1).Latitude = 47.58306
myLatLong(1).Longitude = -122.23064

returnDistances = commonService.GetGreatCircleDistances(myLatLong)
Console.WriteLine(returnDistances(0).ToString())



[C#]

//This example assumes that the MapPoint Web Service 
//namespace has been imported
         
//Get the distance between two latitude and longitude coordinates
CommonServiceSoap commonService = new CommonServiceSoap();
LatLong[] myLatLong = new LatLong[2];
double[] returnDistances;

myLatLong[0] = new LatLong();
myLatLong[1] = new LatLong();
myLatLong[0].Latitude = 47.59975;
myLatLong[0].Longitude = -122.33456;
myLatLong[1].Latitude = 47.58306;
myLatLong[1].Longitude = -122.23064;

returnDistances = commonService.GetGreatCircleDistances(myLatLong);
Console.WriteLine(returnDistances[0].ToString());


See Also

  CommonServiceSoap Class   |   DistanceUnit Enumeration   |   LatLong Class   |   UserInfoHeader.DefaultDistanceUnit Property