Click or drag to resize

Distance Constructor (Coordinate, Coordinate)

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

Namespace:  CoordinateSharp
Assembly:  CoordinateSharp (in CoordinateSharp.dll) Version: 2.12.1.1
Syntax
C#
public Distance(
	Coordinate coord1,
	Coordinate coord2
)

Parameters

coord1
Type: CoordinateSharpCoordinate
Coordinate 1
coord2
Type: CoordinateSharpCoordinate
Coordinate 2
Remarks
Default distance formula uses Haversine (Spherical Earth) calculations.
Examples
The following example grabs the distance in KM and bearing between 2 coordinates using the default Haversine calculations.
Coordinate coordinate1 = new Coordinate(25, 65);
Coordinate coordinate2 = new Coordinate(27.6, 63);

Distance distance = new Distance(coordinate1, coordinate2);

Console.WriteLine(distance.Kilometers); //351.167091506772
Console.WriteLine(distance.Bearing); //214.152133893015
See Also