I`d like calculate the distance of two geo points. the points are given in longitude and latitude.
the coordinates are:
point 1: 36.578581, -118.291994
I used the formula from Wikipedia and put it in a lambda function:
Func<double, double, double, double, double> CalcDistance = (lat1, lon1, lat2, lon2) =>
{
Func<double, double> Radians = (angle) =>
{
return angle * (180.0 / Math.PI);
};
const double radius = 6371;
double delataSigma = Math.Acos(Math.Sin(Radians(lat1)) * Math.Sin(Radians(lat2)) +
Math.Cos(Radians(lat1)) * Math.Cos(Radians(lat2)) * Math.Cos(Math.Abs(Radians(lon2) - Radians(lon1))));
double distance = radius * delataSigma;
return distance;
};