public static List <Place> GetForwardLocations(AirplaneBasic airplane, bool isPassNear) { double lat = airplane.Latitude; double lon = airplane.Longitude; double direction = airplane.Direction * Math.PI / 180; double vlat = (Math.Cos(direction) * 0.1); double vlon = (Math.Sin(direction) * 0.1); List <Place> locationsFound = new List <Place>(); int distanceToCover = 100; distanceToCover = (isPassNear) ? 35 : distanceToCover; for (int i = 0; i < 100; i++) { double currentLat = lat + (vlat * i * 0.08); double currentLon = lon + (vlon * i * 0.08); List <Place> listPlacesOver = ListPlacesGPS.Where(s => s.LatitudeX > currentLat && s.LatitudeY < currentLat && s.LongitudeX <currentLon && s.LongitudeY> currentLon).ToList(); if (listPlacesOver.Count > 0) { bool hasFound = locationsFound.Where(s => s.Name == listPlacesOver.FirstOrDefault().Name).Count() > 0; if (!hasFound) { locationsFound.Add(listPlacesOver.FirstOrDefault()); } } } return(locationsFound); }
public static string GetOverLocation(AirplaneBasic airplane) { double lat = airplane.Latitude; double lon = airplane.Longitude; double direction = airplane.Direction * Math.PI / 180; List <string> locationsFound = new List <string>(); double currentLat = lat; double currentLon = lon; if (airplane.State == AirplaneStatus.ParkingOrTaxing) { var listPlacesOverAirport = ListPlacesAirport.Where(s => s.LatitudeX > currentLat && s.LatitudeY < currentLat && s.LongitudeX <currentLon && s.LongitudeY> currentLon).ToList(); if (listPlacesOverAirport.Count > 0) { bool hasFound = locationsFound.Where(s => s == listPlacesOverAirport.FirstOrDefault().Name).Count() > 0; if (!hasFound) { locationsFound.Add(listPlacesOverAirport.FirstOrDefault().Name); } } } else { var listPlacesOver = ListPlacesGPS.Where(s => s.LatitudeX > currentLat && s.LatitudeY < currentLat && s.LongitudeX <currentLon && s.LongitudeY> currentLon).ToList(); if (listPlacesOver.Count > 0) { bool hasFound = locationsFound.Where(s => s == listPlacesOver.FirstOrDefault().Name).Count() > 0; if (!hasFound) { locationsFound.Add(listPlacesOver.FirstOrDefault().Name); } } } return(locationsFound.FirstOrDefault()); }