private double DistanceToIn(GeoCoordinates anotherLocation, double earthRadiusUnit) { double dlon = Radians(anotherLocation.Longitude - this.Longitude); double dlat = Radians(anotherLocation.Latitude - this.Latitude); var a = Math.Sin(dlat / 2) * Math.Sin(dlat / 2) + Math.Cos(Radians(this.Latitude)) * Math.Cos(Radians(anotherLocation.Latitude)) * Math.Sin(dlon / 2) * Math.Sin(dlon / 2) ; var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); var d = earthRadiusUnit * c; return(d); }
public double DistanceToInMeters(GeoCoordinates anotherLocation) { return(DistanceToIn(anotherLocation, EarthRadiusInMeters)); }