示例#1
0
        public ActionResult Earthquakes()
        {
            NaturalDisastersEntities db = new NaturalDisastersEntities();

            ViewBag.Results = db.EarthQuakeTables;
            return(View());
        }
        public ActionResult SearchTornados()
        {
            NaturalDisastersEntities db = new NaturalDisastersEntities();



            UserLocation User = (UserLocation)Session["UserInfo"];


            ViewBag.User = User;

            double FeltLowLongitude   = User.Longitude - 2.3;
            double FeltHighLongitutde = User.Longitude + 2.3;
            double FeltLowLatitude    = User.Latitude - 2.3;
            double FeltHighLatitude   = User.Latitude + 2.3;


            List <UpdatedTornado> userTornados = new List <UpdatedTornado>();

            userTornados = db.UpdatedTornadoes.Where(x => x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList();

            ViewBag.Results = userTornados;
            double totalNados = userTornados.Count;
            double division   = totalNados / 1160;
            double percent    = division * 100;

            ViewBag.Chance = Math.Round(percent, 6);
            ViewBag.Count  = totalNados;

            Dictionary <string, double> stats = MonthStats(userTornados, totalNados);

            ViewBag.MonthSafety = stats;
            return(View());
        }
示例#3
0
        public List <EarthQuakeTable> EarthquakeDamageRisk()
        {
            NaturalDisastersEntities db   = new NaturalDisastersEntities();
            UserLocation             User = (UserLocation)Session["UserInfo"];

            ViewBag.User = User;
            double DmgLowLongitude  = User.Longitude - 1.5;
            double DmgHighLongitude = User.Longitude + 1.5;
            double DmgLowLatitude   = User.Latitude - 1.5;
            double DmgHighLatitude  = User.Latitude + 1.5;
            List <EarthQuakeTable> userEarthquakesDmg = new List <EarthQuakeTable>();


            userEarthquakesDmg = db.EarthQuakeTables.Where(x => x.Magnitude > 8 && x.Latitude <= DmgHighLatitude && x.Latitude >= DmgLowLatitude &&
                                                           x.Longitude <= DmgHighLongitude && x.Longitude >= DmgLowLongitude).ToList();


            DmgLowLongitude  = User.Longitude - 0.25;
            DmgHighLongitude = User.Longitude + 0.25;
            DmgLowLatitude   = User.Latitude - 0.25;
            DmgHighLatitude  = User.Latitude + 0.25;
            userEarthquakesDmg.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude > 4 && x.Magnitude <= 6 &&
                                                                  x.Latitude <= DmgHighLatitude && x.Latitude >= DmgLowLatitude && x.Longitude <= DmgHighLongitude && x.Longitude >= DmgLowLongitude).ToList());

            DmgLowLongitude  = User.Longitude - 1;
            DmgHighLongitude = User.Longitude + 1;
            DmgLowLatitude   = User.Latitude - 1;
            DmgHighLatitude  = User.Latitude + 1;
            userEarthquakesDmg.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude > 6 && x.Magnitude <= 8 &&
                                                                  x.Latitude <= DmgHighLatitude && x.Latitude >= DmgLowLatitude && x.Longitude <= DmgHighLongitude && x.Longitude >= DmgLowLongitude).ToList());
            List <EarthQuakeTable> dmgRisk = new List <EarthQuakeTable>();

            dmgRisk.AddRange(userEarthquakesDmg.Where(y => y.Magnitude >= 5));

            return(dmgRisk);
        }
示例#4
0
        // GET: Earthquake
        public ActionResult EarthquakeRisk()
        {
            NaturalDisastersEntities db = new NaturalDisastersEntities();

            UserLocation User     = (UserLocation)Session["UserInfo"];
            TimeSpan     userTime = (TimeSpan)Session["UserTime"];



            ViewBag.User = User;


            double FeltLowLongitude  = User.Longitude - 5;
            double FeltHighLongitude = User.Longitude + 5;
            double FeltLowLatitude   = User.Latitude - 5;
            double FeltHighLatitude  = User.Latitude + 5;



            List <EarthQuakeTable> userEarthquakes = new List <EarthQuakeTable>();

            foreach (EarthQuakeTable Eq in db.EarthQuakeTables)
            {
                if (Eq.Latitude >= FeltLowLatitude && Eq.Latitude <= FeltHighLatitude &&
                    Eq.Longitude >= FeltLowLongitude && Eq.Longitude <= FeltHighLongitude)

                {
                    if (Eq.Magnitude > 6 && Eq.Magnitude <= 8)
                    {
                        FeltLowLongitude = User.Longitude - 2.5;

                        FeltHighLongitude = User.Longitude + 2.5;

                        FeltLowLatitude  = User.Latitude - 2.5;
                        FeltHighLatitude = User.Latitude + 2.5;
                        if (Eq.Latitude >= FeltLowLatitude && Eq.Latitude <= FeltHighLatitude &&
                            Eq.Longitude >= FeltLowLongitude && Eq.Longitude <= FeltHighLongitude)
                        {
                            userEarthquakes.Add(Eq);
                        }
                    }
                    else if (Eq.Magnitude <= 6 && Eq.Magnitude > 4)
                    {
                        FeltLowLongitude  = User.Longitude - 1.5;
                        FeltHighLongitude = User.Longitude + 1.5;
                        FeltLowLatitude   = User.Latitude - 1.5;
                        FeltHighLatitude  = User.Latitude + 1.5;

                        if (Eq.Latitude >= FeltLowLatitude && Eq.Latitude <= FeltHighLatitude &&
                            Eq.Longitude >= FeltLowLongitude && Eq.Longitude <= FeltHighLongitude)
                        {
                            userEarthquakes.Add(Eq);
                        }
                    }
                    else if (Eq.Magnitude <= 4)
                    {
                        FeltLowLongitude = User.Longitude - 1.2;

                        FeltHighLongitude = User.Longitude + 1.2;

                        FeltLowLatitude  = User.Latitude - 1.2;
                        FeltHighLatitude = User.Latitude + 1.2;
                        if (Eq.Latitude >= FeltLowLatitude && Eq.Latitude <= FeltHighLatitude &&
                            Eq.Longitude >= FeltLowLongitude && Eq.Longitude <= FeltHighLongitude)
                        {
                            userEarthquakes.Add(Eq);
                        }
                    }
                    else
                    {
                        userEarthquakes.Add(Eq);
                    }
                }
            }
            ViewBag.Results = userEarthquakes;

            double totalQuakes = userEarthquakes.Count;
            double allQuakesUS = db.EarthQuakeTables.Count();
            double division    = totalQuakes / allQuakesUS;
            double percent     = division * 100;

            ViewBag.Chance = Math.Round(percent, 6);
            ViewBag.Count  = totalQuakes;


            return(View());
        }
示例#5
0
        public ActionResult SpeedUpSearch()
        {
            NaturalDisastersEntities db = new NaturalDisastersEntities();

            UserLocation User = (UserLocation)Session["UserInfo"];

            TimeSpan userTime = (TimeSpan)Session["UserTime"];

            ViewBag.User = User;

            double FeltLowLongitude   = User.Longitude - 5.0;
            double FeltHighLongitutde = User.Longitude + 5.0;
            double FeltLowLatitude    = User.Latitude - 5.0;
            double FeltHighLatitude   = User.Latitude + 5.0;



            List <EarthQuakeTable> userEarthquakes = new List <EarthQuakeTable>();

            userEarthquakes = db.EarthQuakeTables.Where(x => x.Magnitude > 8 && x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList();

            FeltLowLongitude   = User.Longitude - 2.5;
            FeltHighLongitutde = User.Longitude + 2.5;
            FeltLowLatitude    = User.Latitude - 2.5;
            FeltHighLatitude   = User.Latitude + 2.5;
            userEarthquakes.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude > 6 && x.Magnitude <= 8 &&
                                                               x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList());

            FeltLowLongitude   = User.Longitude - 1.5;
            FeltHighLongitutde = User.Longitude + 1.5;
            FeltLowLatitude    = User.Latitude - 1.5;
            FeltHighLatitude   = User.Latitude + 1.5;
            userEarthquakes.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude > 4 && x.Magnitude <= 6 &&
                                                               x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList());


            FeltLowLongitude   = User.Longitude - 1.2;
            FeltHighLongitutde = User.Longitude + 1.2;
            FeltLowLatitude    = User.Latitude - 1.2;
            FeltHighLatitude   = User.Latitude + 1.2;
            userEarthquakes.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude <= 4 &&
                                                               x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList());



            ViewBag.Results = userEarthquakes;
            double totalQuakes = userEarthquakes.Count;
            double allQuakesUS = 83944;
            double division    = totalQuakes / allQuakesUS;
            double percent     = division * 100;

            ViewBag.Chance = Math.Round(percent, 6);//felt earthquakes only
            List <EarthQuakeTable> dmgRisk = EarthquakeDamageRisk();
            double dmgPercent = Math.Round((100 * (dmgRisk.Count() / totalQuakes)), 6);

            ViewBag.dmgPercent = dmgPercent;
            ViewBag.Count      = totalQuakes;
            double timesSafer = 3370 / totalQuakes;

            ViewBag.Safer = Math.Round(timesSafer, 2);
            double timesDanger = totalQuakes / 2;

            ViewBag.Danger = Math.Round(timesDanger, 2);

            Dictionary <string, double> stats = MonthStats(userEarthquakes, totalQuakes);

            ViewBag.MonthSafety = stats;


            return(View());
        }
示例#6
0
        //public ActionResult OtherFEMADisasters(string Disaster, string StateCode, string UserCounty)//method to call the others in the DisasterDeclarationSummaries API - available options (their count):
        //																							//"Coastal Storm"(474), "Chemical"(9), "Dam/Levee Break" (6), "Drought" (1292), "Fire" (3040), "Fishing Losses" (42), "Flood" (9739), "Freezing" (301), "Hurricane" (10555),
        //																							//"Mud/Landslide" (31), "Severe Ice Storm" (1990), "Severe Storm(s)" (16127), "Snow" (3659), "Tsunami" (9), "Typhoon" (135), "Volcano" (51- 47 of these are from Mt. Helens on 1980)
        //{


        //	NaturalDisastersEntities db = new NaturalDisastersEntities();

        //	//will need to add the comment code below to the UserLocation() to grab this data and find the matching county incidents.
        //	//string StateCode = ParsedLocation[0]["address_components"][2]["short_name"].ToString();
        //	//string UserCounty = ParsedLocation[0]["address_components"][1]["short_name"].ToString();



        //	int offset;

        //	//there is a total of 49314 disaster declarations as of 3-17-19
        //	List<FemaDisaster> UniqueDisasters = new List<FemaDisaster>();
        //	//for loop size will change based on the disaster entered into the OtherFEMADisasters()
        //	for (offset = 0; offset <= 2000; offset += 1000)
        //	{
        //		string APIText = "https://www.fema.gov/api/open/v1/DisasterDeclarationsSummaries?$filter=(incidentType eq '" + Disaster + "') and (incidentBeginDate gt '1970-01-01T00:00:00.000z') and (state eq '" + StateCode + "' and declaredCountyArea eq '" + UserCounty + " County')&$skip=" + offset;

        //		HttpWebRequest request = WebRequest.CreateHttp(APIText);
        //		HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        //          }
        //          for (int i = 0; i < Tornados.Count(); i++)
        //          {
        //              Tornados[i].declaredCountyArea = Tornados[i].declaredCountyArea.Replace("(", "").Replace(")", "");

        //		StreamReader rd = new StreamReader(response.GetResponseStream());
        //		string data = rd.ReadToEnd();
        //		rd.Close();

        //		MetaDataWrapper Disasters = JsonConvert.DeserializeObject<MetaDataWrapper>(data);
        //		UniqueDisasters.AddRange(Disasters.DisasterDeclarationsSummaries.ToList());

        //		//warning county returns null at times we will need to default to the state name for the long and lat


        //	int offset;

        //	//there is a total of 49314 disaster declarations as of 3-17-19
        //	List<FemaDisaster> UniqueDisasters = new List<FemaDisaster>();
        //	//for loop size will change based on the disaster entered into the OtherFEMADisasters()
        //	for (offset = 0; offset <= 2000; offset += 1000)
        //	{
        //		string APIText = "https://www.fema.gov/api/open/v1/DisasterDeclarationsSummaries?$filter=(incidentType eq '" + Disaster + "') and (incidentBeginDate gt '1970-01-01T00:00:00.000z') and (state eq '" + StateCode + "' and declaredCountyArea eq '" + UserCounty + " County')&$skip=" + offset;

        //		HttpWebRequest request = WebRequest.CreateHttp(APIText);
        //		HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        //          }
        //          for (int i = 0; i < Tornados.Count(); i++)
        //          {
        //              Tornados[i].declaredCountyArea = Tornados[i].declaredCountyArea.Replace("(", "").Replace(")", "");

        //		StreamReader rd = new StreamReader(response.GetResponseStream());
        //		string data = rd.ReadToEnd();
        //		rd.Close();

        //		MetaDataWrapper Disasters = JsonConvert.DeserializeObject<MetaDataWrapper>(data);
        //		UniqueDisasters.AddRange(Disasters.DisasterDeclarationsSummaries.ToList());


        //		//warning county returns null at times we will need to default to the state name for the long and lat


        //		//.add only does one object, while .addRange does ALL the objects



        //		//.add only does one object, while .addRange does ALL the objects


        //	}


        //	ViewBag.Disasters = UniqueDisasters;

        //	return View();
        //}

        public ActionResult SearchBoth()
        {
            NaturalDisastersEntities db = new NaturalDisastersEntities();



            UserLocation User     = (UserLocation)Session["UserInfo"];
            TimeSpan     userTime = (TimeSpan)Session["UserTime"];

            ViewBag.User = User;

            double FeltLowLongitude   = User.Longitude - 2.3;
            double FeltHighLongitutde = User.Longitude + 2.3;
            double FeltLowLatitude    = User.Latitude - 2.3;
            double FeltHighLatitude   = User.Latitude + 2.3;


            List <EarthQuakeTable> userEarthquakes = new List <EarthQuakeTable>();

            userEarthquakes = db.EarthQuakeTables.Where(x => x.Magnitude > 8 && x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList();

            FeltLowLongitude   = User.Longitude - 1.5;
            FeltHighLongitutde = User.Longitude + 1.5;
            FeltLowLatitude    = User.Latitude - 1.5;
            FeltHighLatitude   = User.Latitude + 1.5;
            userEarthquakes.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude > 6 && x.Magnitude <= 8 &&
                                                               x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList());

            FeltLowLongitude   = User.Longitude - 1.2;
            FeltHighLongitutde = User.Longitude + 1.2;
            FeltLowLatitude    = User.Latitude - 1.2;
            FeltHighLatitude   = User.Latitude + 1.2;
            userEarthquakes.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude > 4 && x.Magnitude <= 6 &&
                                                               x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList());


            FeltLowLongitude   = User.Longitude - 0.9;
            FeltHighLongitutde = User.Longitude + 0.9;
            FeltLowLatitude    = User.Latitude - 0.9;
            FeltHighLatitude   = User.Latitude + 0.9;
            userEarthquakes.AddRange(db.EarthQuakeTables.Where(x => x.Magnitude <= 4 &&
                                                               x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList());


            FeltLowLongitude   = User.Longitude - 2.3;
            FeltHighLongitutde = User.Longitude + 2.3;
            FeltLowLatitude    = User.Latitude - 2.3;
            FeltHighLatitude   = User.Latitude + 2.3;
            List <UpdatedTornado> userTornados = new List <UpdatedTornado>();

            userTornados = db.UpdatedTornadoes.Where(x => x.Latitude <= FeltHighLatitude && x.Latitude >= FeltLowLatitude && x.Longitude <= FeltHighLongitutde && x.Longitude >= FeltLowLongitude).ToList();

            ViewBag.nadoResults = userTornados;
            double totalNados   = userTornados.Count;
            double nadoDivision = totalNados / 1160;
            double nadoPercent  = nadoDivision * 100;

            ViewBag.NadoChance = Math.Round(nadoPercent, 6);
            ViewBag.NadoCount  = totalNados;


            ViewBag.quakeResults = userEarthquakes;
            double totalQuakes = userEarthquakes.Count;
            double allQuakesUS = 83944;
            double division    = totalQuakes / allQuakesUS;
            double percent     = division * 100;

            ViewBag.QuakeChance = Math.Round(percent, 6);
            ViewBag.QuakeCount  = totalQuakes;

            Dictionary <string, double> quakeStats = QuakeStats(userEarthquakes, totalQuakes);

            ViewBag.QuakeSafety = quakeStats;
            Dictionary <string, double> nadoStats = NadoStats(userTornados, totalNados);

            ViewBag.NadoSafety = nadoStats;

            ViewBag.TotalDisaster = totalNados + totalQuakes;
            return(View());
        }