public async Task <Response <Guid> > GetLocalAirfieldID(IGlobalPoint globalPoint) { try { var temp = await _airfieldRepository.FindAround(globalPoint); return(new Response <Guid>(temp.ID)); } catch (InvalidOperationException) { return(new Response <Guid>("No Airfields around this area", true)); } }
/// <summary> /// The Distance between two points. /// </summary> /// <param name="start">First <see cref="IGlobalPoint"/> point.</param> /// <param name="end">Second <see cref="IGlobalPoint"/> point.</param> /// <returns>The number of meters between two points as <see cref="double"/></returns> public static double Distance(IGlobalPoint start, IGlobalPoint end) { double rlat1 = Math.PI * start.Latitude / 180; double rlat2 = Math.PI * end.Latitude / 180; double theta = start.Longitude - end.Longitude; double rtheta = Math.PI * theta / 180; double dist = Math.Sin(rlat1) * Math.Sin(rlat2) + Math.Cos(rlat1) * Math.Cos(rlat2) * Math.Cos(rtheta); dist = Math.Acos(dist); dist = dist * 180 / Math.PI; dist = dist * 60 * 1.1515; return(dist * 1609.344); }
public Task <Airfield> FindAround(IGlobalPoint globalPoint) { return(GetFullIncludes() .SingleAsync(ent => GlobalPoint.Distance(ent, globalPoint) <= Constants.AIRFIELD_DESIGNATED_AREA_RADIUS)); }