To find the distance between two points on Earth, you can use the Haversine formula, which is based on the Great Circle Distance between two coordinates. Here is an implementation in C#:
main.cs610 chars19 lines
The inputs lat1
, lon1
, lat2
, and lon2
are the latitude and longitude coordinates of the two points you want to find the distance between. The output is the distance in kilometers.
Note that this implementation assumes that the Earth is a perfect sphere with a radius of 6371 km. This is not completely accurate, as the Earth is oblate spheroidal in shape, but it is a good approximation for most practical purposes.
gistlibby LogSnag