Click or drag to resize

Distance Constructor (Coordinate, Coordinate, Shape)

Initializes a Distance object based on the distance between 2 coordinates.

Namespace:  CoordinateSharp
Assembly:  CoordinateSharp (in CoordinateSharp.dll) Version:
Distance formula may either be Haversine (Spherical Earth) or Vincenty (Ellipsoidal Earth) calculations.
The following example grabs the distance in KM and bearing between 2 coordinates using Vincenty (ellipsoidal earth) calculations.
Coordinate coordinate1 = new Coordinate(25, 65);
Coordinate coordinate2 = new Coordinate(27.6, 63);

Distance distance = new Distance(coordinate1, coordinate2, Shape.Ellipsoid);

Console.WriteLine(distance.Kilometers); //350.50857212259
Console.WriteLine(distance.Bearing); //215.183316089463
See Also