/// <summary> /// Gets distance to another coordinate. /// </summary> /// <param name="geoCoord"></param> /// <param name="unit">M=Miles, K=Kilometers, N=NauticalMiles</param> /// <returns></returns> public double GetDistanceTo(GeoCoordinates geoCoord, char unit) { double theta = Longitude - geoCoord.Longitude; double dist = Math.Sin(deg2rad(Latitude)) * Math.Sin(deg2rad(geoCoord.Latitude)) + Math.Cos(deg2rad(Latitude)) * Math.Cos(deg2rad(geoCoord.Latitude)) * Math.Cos(deg2rad(theta)); dist = Math.Acos(dist); dist = rad2deg(dist); dist = dist * 60 * 1.1515; if (unit == 'K') { dist = dist * 1.609344; } else if (unit == 'N') { dist = dist * 0.8684; } return (dist); }
/// <summary> /// Gets distance to another coordinate in miles. /// </summary> /// <param name="geoCoord"></param> /// <returns></returns> public double GetDistanceTo(GeoCoordinates geoCoord) { return GetDistanceTo(geoCoord, 'M'); }