Fhnw.Ecnf.RoutePlanner.RoutePlannerLib.WayPoint.Distance C# (CSharp) Method

Distance() public method

public Distance ( WayPoint target ) : Double
target WayPoint
return Double
        public Double Distance(WayPoint target)
        {
            double R = 6371;    // earth radius
            double slat = ConvertToRadians(this.Latitude), slong = ConvertToRadians(this.Longitude);
            double tlat = ConvertToRadians(target.Latitude), tlong = ConvertToRadians(target.Longitude);
            double d = R*
                       Math.Acos(Math.Sin(slat)*Math.Sin(tlat) +
                                 Math.Cos(slat) * Math.Cos(tlat) *
                                 Math.Cos(slong - tlong));

            return d;
        }

Usage Example

Example #1
0
 public List <City> FindNeighbours(WayPoint location, double distance)
 {
     return(CityList
            .Where(c => location.Distance(c.Location) <= distance)
            .OrderBy(c => location.Distance(c.Location))
            .ToList());
 }
All Usage Examples Of Fhnw.Ecnf.RoutePlanner.RoutePlannerLib.WayPoint::Distance