public void TestFindNearbyCounties()
        {
            var address = Address.Search("East Lansing, MI").First();

            address.GeocodeAddress();
            var counties = CountyList.FindNearbyCounties(address.Geocode, 25.0).Select(c => c.Name).ToList();

            counties.Sort();
            Assert.IsTrue(counties.SequenceEqual(new[] { "Eaton", "Ingham" }));
        }
        public ActionResult Index()
        {
            string filterAsString = Request.QueryString["incidentFilter"];
            WeatherIncidentType?filter;

            try
            {
                filter = (WeatherIncidentType)Enum.Parse(typeof(WeatherIncidentType), filterAsString);
            }
            catch (ArgumentException)
            {
                filter = null;
            }

            double radius;

            if (!double.TryParse(Request.QueryString["radius"], out radius))
            {
                radius = 15;
            }

            County mainCounty = CountyList.GetCounty(Request.QueryString["county"], new State(Request.QueryString["state"]));

            List <County> counties = new List <County> {
                mainCounty
            };

            counties.AddRange(CountyList.FindNearbyCounties(mainCounty.Geocode, radius));
            counties = counties.Distinct().ToList();

            var ncdc = new Ncdc();
            List <WeatherIncident> ncdcIncidents = new List <WeatherIncident>();

            foreach (var county in counties)
            {
                ncdcIncidents.AddRange(ncdc.GetEvents(
                                           county.State,
                                           county.Name,
                                           DateTime.Parse(Request.QueryString["startDate"]),
                                           DateTime.Parse(Request.QueryString["endDate"]), filter));
            }

            return(Json(ncdcIncidents.Distinct(), JsonRequestBehavior.AllowGet));
        }