public ActionResult Index() { string airportCode = Request.QueryString["airportCode"]; DateTime date = DateTime.Parse(Request.QueryString["date"]); WeatherIncidentType?filterType = GetWeatherIncidentTypeFromRequest(Request); double radius; if (!double.TryParse(Request.QueryString["radius"], out radius)) { radius = 15; } var mainAirport = AirportList.GetAirport(airportCode); var airports = new List <Airport> { mainAirport }; airports.AddRange(AirportList.FindNearbyAirports(mainAirport.Geocode, radius)); airports = airports.Distinct().ToList(); var weatherUnderground = new WeatherUnderground(); List <WeatherIncident> weatherUndergroundIncidents = new List <WeatherIncident>(); foreach (var airport in airports) { weatherUndergroundIncidents.AddRange(weatherUnderground.GetEvents(airport.AirportCode, date, filterType)); } return(Json(weatherUndergroundIncidents.Distinct(), JsonRequestBehavior.AllowGet)); }
public void TestFindNearbyAirports() { var address = Address.Search("East Lansing, MI").First(); address.GeocodeAddress(); var airports = AirportList.FindNearbyAirports(address.Geocode, 50.0).Select(a => a.AirportCode).ToList(); airports.Sort(); Assert.IsTrue(airports.SequenceEqual(new [] { "KAMN", "KBTL", "KFNT", "KJXN", "KLAN" })); }