From 65c422b2bc2b5ae3d483f4146ee4382d7383e248 Mon Sep 17 00:00:00 2001 From: The-Architect01 <84486562+The-Architect01@users.noreply.github.com> Date: Tue, 21 Dec 2021 22:28:30 -0500 Subject: [PATCH] Add project files. --- NWS.net.sln | 25 +++++++ NWS.net/Alert.cs | 65 ++++++++++++++++++ NWS.net/Alerts.cs | 35 ++++++++++ NWS.net/Forecast.cs | 35 ++++++++++ NWS.net/ForecastData.cs | 55 +++++++++++++++ NWS.net/Location.cs | 72 ++++++++++++++++++++ NWS.net/NWS.net.csproj | 16 +++++ NWS.net/NWSAPI.cs | 89 ++++++++++++++++++++++++ NWS.net/TimeZoneTranslate.cs | 128 +++++++++++++++++++++++++++++++++++ NWS.net/WeatherMaps.cs | 69 +++++++++++++++++++ 10 files changed, 589 insertions(+) create mode 100644 NWS.net.sln create mode 100644 NWS.net/Alert.cs create mode 100644 NWS.net/Alerts.cs create mode 100644 NWS.net/Forecast.cs create mode 100644 NWS.net/ForecastData.cs create mode 100644 NWS.net/Location.cs create mode 100644 NWS.net/NWS.net.csproj create mode 100644 NWS.net/NWSAPI.cs create mode 100644 NWS.net/TimeZoneTranslate.cs create mode 100644 NWS.net/WeatherMaps.cs diff --git a/NWS.net.sln b/NWS.net.sln new file mode 100644 index 0000000..6ca88e8 --- /dev/null +++ b/NWS.net.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32002.261 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NWS.net", "NWS.net\NWS.net.csproj", "{C4F2EC71-1D8A-48FE-AB07-4748BF9592A8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C4F2EC71-1D8A-48FE-AB07-4748BF9592A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4F2EC71-1D8A-48FE-AB07-4748BF9592A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4F2EC71-1D8A-48FE-AB07-4748BF9592A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4F2EC71-1D8A-48FE-AB07-4748BF9592A8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {97F484EC-91BC-4CDE-A8C8-0B96FA37D678} + EndGlobalSection +EndGlobal diff --git a/NWS.net/Alert.cs b/NWS.net/Alert.cs new file mode 100644 index 0000000..8dc920b --- /dev/null +++ b/NWS.net/Alert.cs @@ -0,0 +1,65 @@ +namespace NWS.net { + public class Alert { + + public DateTime Effective { get; private set; } + public DateTime Expires { get; private set; } + public string MessageType { get; private set; } + public string Severity { get; private set; } + public string Certainty { get; private set; } + public string Urgency { get; private set; } + public string Event { get; private set; } + public string SendingOffice { get; private set; } + public string Headline { get; private set; } + public string Description { get; private set; } + public string Instructions { get; private set; } + public string Response { get; private set; } + public string MessageHeadline { get; private set; } + public List AffectedZones { get; private set; } = new(); + + public Alert(List Data) { + bool Zone = false; + bool NWSHead = false; + foreach (string dataPoint in Data) { + if (dataPoint.Contains("\"effective\": ")) { + string time = dataPoint.Split("\"effective\": ")[1].Split("\"")[1]; + Effective = new DateTime(int.Parse(time.Split("-")[0]), + int.Parse(time.Split("-")[1]), int.Parse(time.Split("-")[2].Split("T")[0]), + int.Parse(time.Split("-")[2].Split("T")[1]), 0, 0); + } else if (dataPoint.Contains("\"expires\": ")) { + string time = dataPoint.Split("\"expires\": ")[1].Split("\"")[1]; + Expires = new DateTime(int.Parse(time.Split("-")[0]), + int.Parse(time.Split("-")[1]), int.Parse(time.Split("-")[2].Split("T")[0]), + int.Parse(time.Split("-")[2].Split("T")[1]), 0, 0); + } else if (dataPoint.Contains("\"messageType\": ")) { + MessageType = dataPoint.Split("\"messageType\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"severity\": ")) { + Severity = dataPoint.Split("\"severity\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"certainty\": ")) { + Certainty = dataPoint.Split("\"certainty\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"urgency\": ")) { + Urgency = dataPoint.Split("\"urgency\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"event\":")) { + Event = dataPoint.Split("\"event\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"headline\":")) { + Headline = dataPoint.Split("\"headline\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"description\": ")) { + Description = dataPoint.Split("\"description\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"instructions\": ")) { + Instructions = dataPoint.Split("\"instructions\": ")[1].Split("\"")[1]; + } else if (dataPoint.Contains("\"NWSheadline\": ")) { + NWSHead = true; + } else if (dataPoint.Contains("\"UGC\" :")) { + Zone = true; + } else if (Zone) { + AffectedZones.Add(dataPoint.Split("\"")[1]); + } else if (NWSHead) { + MessageHeadline = dataPoint.Split("\"")[1]; + } else if (dataPoint.Contains("],")) { + Zone = false; + NWSHead = false; + } + } + } + + } +} diff --git a/NWS.net/Alerts.cs b/NWS.net/Alerts.cs new file mode 100644 index 0000000..76c2c49 --- /dev/null +++ b/NWS.net/Alerts.cs @@ -0,0 +1,35 @@ +namespace NWS.net { + public class Alerts { + + public Alert[] ActiveAlerts { get; private set; } + + string API_Base { get; } = "https://api.weather.gov/alerts/active?point="; + + public Alerts(double[] Location) { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + string Response = wc.DownloadString(API_Base + Location[0] + "," + Location[1]); + using StringReader parser = new(Response); + string currentLine = string.Empty; + List dataInput = new(); + List data = new(); + bool start = false; + do { + try { + currentLine = parser.ReadLine(); + if (currentLine.Contains("\"id\":")) { start = true; } + if (currentLine.Contains("},") || currentLine.Contains("],")) { + start = false; + data.Add(new Alert(dataInput)); + dataInput.Clear(); + } + if (start) { + dataInput.Add(currentLine); + } + } catch (NullReferenceException) { } + } while (currentLine != null); + ActiveAlerts = data.ToArray(); + } + + } +} diff --git a/NWS.net/Forecast.cs b/NWS.net/Forecast.cs new file mode 100644 index 0000000..c540724 --- /dev/null +++ b/NWS.net/Forecast.cs @@ -0,0 +1,35 @@ +namespace NWS.net { + public class Forecast { + + public ForecastData[] ForecastData { get; private set; } + + public Forecast(string URL) { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + string Response = wc.DownloadString(URL); + using StringReader parser = new(Response); + string currentLine = string.Empty; + List dataInput = new(); + List data = new(); + bool start = false; + do { + currentLine = parser.ReadLine(); + try { + if (currentLine.Contains("\"number\":")) { start = true; } + if (currentLine.Contains("},") || currentLine.Contains("]")) { + if (start) { + start = false; + data.Add(new ForecastData(dataInput)); + dataInput.Clear(); + } + } + if (start) { + dataInput.Add(currentLine); + } + } catch (NullReferenceException) { } + } while (currentLine != null); + ForecastData = data.ToArray(); + } + + } +} diff --git a/NWS.net/ForecastData.cs b/NWS.net/ForecastData.cs new file mode 100644 index 0000000..b92c205 --- /dev/null +++ b/NWS.net/ForecastData.cs @@ -0,0 +1,55 @@ +namespace NWS.net { + public class ForecastData { + + public string Day { get; set; } = "Today"; + public DateTime Start { get; set; } = DateTime.Now; + public DateTime End { get; set; } = DateTime.Today; + public bool Daytime { get; set; } = true; + public int Temperature { get; set; }= 32; + public string TemperatureUnit { get; set; } = "F"; + public string TemperatureTrend { get; set; } = string.Empty; + public int WindSpeed { get; set; } = 0; + public string WindSpeedUnit { get; set; } = "mph"; + public string WindDirection { get; set; } = "N"; + public string ShortForcast { get; set; } = string.Empty; + public string DetailedForecast { get; set; } = string.Empty; + + public ForecastData(List Items) { + foreach(string data in Items) { + if(data.Contains("\"name\": ")) { + Day = data.Split("\"name\": ")[1].Split("\"")[1]; + }else if(data.Contains("\"startTime\": ")) { + string time = data.Split("\"startTime\": ")[1].Split("\"")[1]; + Start = new DateTime(int.Parse(time.Split("-")[0]), + int.Parse(time.Split("-")[1]), int.Parse(time.Split("-")[2].Split("T")[0]), + int.Parse(time.Split("-")[2].Split("T")[1].Split(":")[0]), 0, 0); + } else if(data.Contains("\"endTime\": ")) { + string time = data.Split("\"endTime\": ")[1].Split("\"")[1]; + End = new DateTime(int.Parse(time.Split("-")[0]), + int.Parse(time.Split("-")[1]), int.Parse(time.Split("-")[2].Split("T")[0]), + int.Parse(time.Split("-")[2].Split("T")[1].Split(":")[0]), 0, 0); + } else if(data.Contains("\"isDaytime\": ")) { + Daytime = bool.Parse(data.Split("\"isDaytime\": ")[1].Split(",")[0]); + } else if(data.Contains("\"temperature\": ")) { + Temperature = int.Parse(data.Split("\"temperature\": ")[1].Split(",")[0]); + } else if(data.Contains("\"temperatureUnit\": ")) { + TemperatureUnit = data.Split("\"temperatureUnit\": ")[1].Split("\"")[1]; + } else if(data.Contains("\"temperatureTrend\": ")) { + try { + TemperatureTrend = data.Split("\"temperatureTrend\": ")[1].Split("\"")[1]; + } catch (IndexOutOfRangeException) { TemperatureTrend = string.Empty; } + } else if(data.Contains("\"windSpeed\": ")) { + WindSpeed = int.Parse(data.Split("\"windSpeed\": ")[1].Split("\"")[1].Split(" ")[0]); + WindSpeedUnit = data.Split("\"windSpeed\": ")[1].Split("\"")[1].Split(" ")[1]; + } else if(data.Contains("\"windDirection\" : ")) { + WindDirection = data.Split("\"windDirection\": ")[1].Split("\"")[1].Split(" ")[1]; + } else if(data.Contains("\"shortForecast\": ")) { + ShortForcast = data.Split("\"shortForecast\": ")[1].Split(",")[0]; + } else if(data.Contains("\"detailedForecast\": ")) { + DetailedForecast = data.Split("\"detailedForecast\":")[1].Split("\"")[1].Split(" ")[1]; + } + } + } + + } +} diff --git a/NWS.net/Location.cs b/NWS.net/Location.cs new file mode 100644 index 0000000..18fe89e --- /dev/null +++ b/NWS.net/Location.cs @@ -0,0 +1,72 @@ +namespace NWS.net { + public class Location { + + public string City { get; private set; } = "Washington"; + public string State { get; private set; } = "DC"; + public string County { get; private set; } = "District of Columbia"; + + public TimeZoneInfo TimeZone { get; private set; } = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneTranslate.OlsenToWin32["America/New_York"]); + public string RadarStation { get; private set; } = "KLWX"; + public string ForecastURL { get; private set; } + + public int[] GridCoordinates { get; private set; } = new int[] { 96, 70 }; + public string Zone { get; private set; } = "DCZ001"; + + string BASE_API { get; } = "https://api.weather.gov/points/"; + string API_RESPONSE { get; set; } + + public Location(double[] GPS) { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + API_RESPONSE = wc.DownloadString(BASE_API + GPS[0] + "," + GPS[1]); + using StringReader parser = new(API_RESPONSE); + string currentLine = string.Empty; + + do { + + currentLine = parser.ReadLine(); + try { + if (currentLine.Contains("\"gridX\": ")) { + GridCoordinates[0] = int.Parse(currentLine.Split("\"gridX\": ")[1].Split(",")[0]); + } else if (currentLine.Contains("\"gridY\": ")) { + GridCoordinates[1] = int.Parse(currentLine.Split("\"gridY\": ")[1].Split(",")[0]); + } else if (currentLine.Contains("\"forecast\": ")) { + ForecastURL = currentLine.Split("\"forecast\": ")[1].Split("\"")[1]; + } else if (currentLine.Contains("\"city\": ")) { + City = currentLine.Split("\"city\": ")[1].Split("\"")[1]; + } else if (currentLine.Contains("\"state\": ")) { + State = currentLine.Split("\"state\": ")[1].Split("\"")[1]; + } else if (currentLine.Contains("\"county\": ")) { + try { + County = GetCounty(currentLine.Split("\"county\": ")[1].Split("\"")[1]); + } catch (IndexOutOfRangeException) { } + } else if (currentLine.Contains("\"timeZone\": ")) { + string timeZone = currentLine.Split("\"timeZone\": ")[1].Split("\"")[1]; + TimeZone = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneTranslate.OlsenToWin32[timeZone]); + } else if (currentLine.Contains("\"radarStation\": ")) { + RadarStation = currentLine.Split("\"radarStation\": ")[1].Split("\"")[1]; + } else if (currentLine.Contains("\"forecastZone\": ")) { + Zone = currentLine.Split("\"forecastZone\": ")[1].Split("\"")[1].Split("/")[5]; + } + } catch (NullReferenceException) { } + } while (currentLine != null); + + } + private static string GetCounty(string URL) { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + string Response = wc.DownloadString(URL); + using StringReader parser = new(Response); + string currentLine = string.Empty; + + do { + currentLine = parser.ReadLine(); + if(currentLine.Contains("\"name\": ")) { + return currentLine.Split("\"name\": ")[1].Split("\"")[1]; + } + } while (currentLine != null); + + return null; + } + } +} diff --git a/NWS.net/NWS.net.csproj b/NWS.net/NWS.net.csproj new file mode 100644 index 0000000..0a92bcb --- /dev/null +++ b/NWS.net/NWS.net.csproj @@ -0,0 +1,16 @@ + + + + net5.0 + preview + preview + NWS.net + NWS.net + true + + + + x64 + + + diff --git a/NWS.net/NWSAPI.cs b/NWS.net/NWSAPI.cs new file mode 100644 index 0000000..f8ec938 --- /dev/null +++ b/NWS.net/NWSAPI.cs @@ -0,0 +1,89 @@ +global using System; +global using System.ComponentModel; +global using System.IO; +global using System.Net; +global using System.Collections.Generic; + +namespace NWS.net { + public class NWSAPI { + + #region Non Visible + static readonly double[] DEFAULT = new double[] { 38.9072, -77.0369 }; + private double[] Position { get; set; } = new double[2]; + #endregion + + public Location Location { get { return new Location(Position); } } + public Forecast Forecast { get { return new Forecast(Location.ForecastURL); } } + public Alerts Alerts { get { return new Alerts(Position); } } + public WeatherMaps WeatherMap { get { return new WeatherMaps(Location.RadarStation); } } + + public NWSAPI(string IP) { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + string LOCATION_API = wc.DownloadString("http://ip-api.com/json/" + IP); + try { + Position[0] = double.Parse(LOCATION_API.Split("\"lon\":")[1].Split(",")[0]); + Position[1] = double.Parse(LOCATION_API.Split("\"lat\":")[1].Split(",")[0]); + } catch (Exception) { + Position = DEFAULT; + } + } + + public void SetPosition(double Latitude, double Longitude) { + Position[0] = Latitude; + Position[1] = Longitude; + } + public void SetPosition(string Latitude, string Longitude) { + try { + Position[0] = int.Parse(Latitude); + Position[1] = int.Parse(Longitude); + } catch (Exception) { + Position = DEFAULT; + } + } + public void SetPosition(string IP) { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + string LOCATION_API = wc.DownloadString("http://ip-api.com/json/" + IP); + try { + Position[0] = double.Parse(LOCATION_API.Split("\"lon\":")[1].Split(",")[0]); + Position[1] = double.Parse(LOCATION_API.Split("\"lat\":")[1].Split(",")[0]); + } catch (Exception) { + Position = DEFAULT; + } + } + public void SetPosition() { + using WebClient wc = new(); + wc.Headers.Add("user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"); + string LOCATION_API = wc.DownloadString("http://ip-api.com/json/"); + try { + Position[0] = double.Parse(LOCATION_API.Split("\"lon\":")[1].Split(",")[0]); + Position[1] = double.Parse(LOCATION_API.Split("\"lat\":")[1].Split(",")[0]); + } catch (Exception) { + Position = DEFAULT; + } + } + + public void Reset() { + Position = DEFAULT; + } + + public NWSAPI() { + Position = DEFAULT; + } + + public NWSAPI(double Latitude, double Longitude) { + Position[0] = Latitude; + Position[1] = Longitude; + } + + public NWSAPI(string Latitude, string Longitude) { + try { + Position[0] = int.Parse(Latitude); + Position[1] = int.Parse(Longitude); + } catch (Exception) { + Position = DEFAULT; + } + } + } +} diff --git a/NWS.net/TimeZoneTranslate.cs b/NWS.net/TimeZoneTranslate.cs new file mode 100644 index 0000000..4c7c425 --- /dev/null +++ b/NWS.net/TimeZoneTranslate.cs @@ -0,0 +1,128 @@ +namespace NWS.net { + public struct TimeZoneTranslate { + public static Dictionary OlsenToWin32 { get; } = new() { + { "Africa/Bangui", "W. Central Africa Standard Time" }, + { "Africa/Cairo", "Egypt Standard Time" }, + { "Africa/Casablanca", "Morocco Standard Time" }, + { "Africa/Harare", "South Africa Standard Time" }, + { "Africa/Johannesburg", "South Africa Standard Time" }, + { "Africa/Lagos", "W. Central Africa Standard Time" }, + { "Africa/Monrovia", "Greenwich Standard Time" }, + { "Africa/Nairobi", "E. Africa Standard Time" }, + { "Africa/Windhoek", "Namibia Standard Time" }, + { "America/Anchorage", "Alaskan Standard Time" }, + { "America/Argentina/San_Juan", "Argentina Standard Time" }, + { "America/Asuncion", "Paraguay Standard Time" }, + { "America/Bahia", "Bahia Standard Time" }, + { "America/Bogota", "SA Pacific Standard Time" }, + { "America/Buenos_Aires", "Argentina Standard Time" }, + { "America/Caracas", "Venezuela Standard Time" }, + { "America/Cayenne", "SA Eastern Standard Time" }, + { "America/Chicago", "Central Standard Time" }, + { "America/Chihuahua", "Mountain Standard Time (Mexico)" }, + { "America/Cuiaba", "Central Brazilian Standard Time" }, + { "America/Denver", "Mountain Standard Time" }, + { "America/Fortaleza", "SA Eastern Standard Time" }, + { "America/Godthab", "Greenland Standard Time" }, + { "America/Guatemala", "Central America Standard Time" }, + { "America/Halifax", "Atlantic Standard Time" }, + { "America/Indianapolis", "US Eastern Standard Time" }, + { "America/Indiana/Indianapolis", "US Eastern Standard Time" }, + { "America/La_Paz", "SA Western Standard Time" }, + { "America/Los_Angeles", "Pacific Standard Time" }, + { "America/Mexico_City", "Mexico Standard Time" }, + { "America/Montevideo", "Montevideo Standard Time" }, + { "America/New_York", "Eastern Standard Time" }, + { "America/Noronha", "UTC-02" }, + { "America/Phoenix", "US Mountain Standard Time" }, + { "America/Regina", "Canada Central Standard Time" }, + { "America/Santa_Isabel", "Pacific Standard Time (Mexico)" }, + { "America/Santiago", "Pacific SA Standard Time" }, + { "America/Sao_Paulo", "E. South America Standard Time" }, + { "America/St_Johns", "Newfoundland Standard Time" }, + { "America/Tijuana", "Pacific Standard Time" }, + { "Antarctica/McMurdo", "New Zealand Standard Time" }, + { "Atlantic/South_Georgia", "UTC-02" }, + { "Asia/Almaty", "Central Asia Standard Time" }, + { "Asia/Amman", "Jordan Standard Time" }, + { "Asia/Baghdad", "Arabic Standard Time" }, + { "Asia/Baku", "Azerbaijan Standard Time" }, + { "Asia/Bangkok", "SE Asia Standard Time" }, + { "Asia/Beirut", "Middle East Standard Time" }, + { "Asia/Calcutta", "India Standard Time" }, + { "Asia/Colombo", "Sri Lanka Standard Time" }, + { "Asia/Damascus", "Syria Standard Time" }, + { "Asia/Dhaka", "Bangladesh Standard Time" }, + { "Asia/Dubai", "Arabian Standard Time" }, + { "Asia/Irkutsk", "North Asia East Standard Time" }, + { "Asia/Jerusalem", "Israel Standard Time" }, + { "Asia/Kabul", "Afghanistan Standard Time" }, + { "Asia/Kamchatka", "Kamchatka Standard Time" }, + { "Asia/Karachi", "Pakistan Standard Time" }, + { "Asia/Katmandu", "Nepal Standard Time" }, + { "Asia/Kolkata", "India Standard Time" }, + { "Asia/Krasnoyarsk", "North Asia Standard Time" }, + { "Asia/Kuala_Lumpur", "Singapore Standard Time" }, + { "Asia/Kuwait", "Arab Standard Time" }, + { "Asia/Magadan", "Magadan Standard Time" }, + { "Asia/Muscat", "Arabian Standard Time" }, + { "Asia/Novosibirsk", "N. Central Asia Standard Time" }, + { "Asia/Oral", "West Asia Standard Time" }, + { "Asia/Rangoon", "Myanmar Standard Time" }, + { "Asia/Riyadh", "Arab Standard Time" }, + { "Asia/Seoul", "Korea Standard Time" }, + { "Asia/Shanghai", "China Standard Time" }, + { "Asia/Singapore", "Singapore Standard Time" }, + { "Asia/Taipei", "Taipei Standard Time" }, + { "Asia/Tashkent", "West Asia Standard Time" }, + { "Asia/Tbilisi", "Georgian Standard Time" }, + { "Asia/Tehran", "Iran Standard Time" }, + { "Asia/Tokyo", "Tokyo Standard Time" }, + { "Asia/Ulaanbaatar", "Ulaanbaatar Standard Time" }, + { "Asia/Vladivostok", "Vladivostok Standard Time" }, + { "Asia/Yakutsk", "Yakutsk Standard Time" }, + { "Asia/Yekaterinburg", "Ekaterinburg Standard Time" }, + { "Asia/Yerevan", "Armenian Standard Time" }, + { "Atlantic/Azores", "Azores Standard Time" }, + { "Atlantic/Cape_Verde", "Cape Verde Standard Time" }, + { "Atlantic/Reykjavik", "Greenwich Standard Time" }, + { "Australia/Adelaide", "Cen. Australia Standard Time" }, + { "Australia/Brisbane", "E. Australia Standard Time" }, + { "Australia/Darwin", "AUS Central Standard Time" }, + { "Australia/Hobart", "Tasmania Standard Time" }, + { "Australia/Perth", "W. Australia Standard Time" }, + { "Australia/Sydney", "AUS Eastern Standard Time" }, + { "Etc/GMT", "UTC" }, + { "Etc/GMT+11", "UTC-11" }, + { "Etc/GMT+12", "Dateline Standard Time" }, + { "Etc/GMT+2", "UTC-02" }, + { "Etc/GMT-12", "UTC+12" }, + { "Europe/Amsterdam", "W. Europe Standard Time" }, + { "Europe/Athens", "GTB Standard Time" }, + { "Europe/Belgrade", "Central Europe Standard Time" }, + { "Europe/Berlin", "W. Europe Standard Time" }, + { "Europe/Brussels", "Romance Standard Time" }, + { "Europe/Budapest", "Central Europe Standard Time" }, + { "Europe/Dublin", "GMT Standard Time" }, + { "Europe/Helsinki", "FLE Standard Time" }, + { "Europe/Istanbul", "GTB Standard Time" }, + { "Europe/Kiev", "FLE Standard Time" }, + { "Europe/London", "GMT Standard Time" }, + { "Europe/Minsk", "E. Europe Standard Time" }, + { "Europe/Moscow", "Russian Standard Time" }, + { "Europe/Paris", "Romance Standard Time" }, + { "Europe/Sarajevo", "Central European Standard Time" }, + { "Europe/Warsaw", "Central European Standard Time" }, + { "Indian/Mauritius", "Mauritius Standard Time" }, + { "Pacific/Apia", "Samoa Standard Time" }, + { "Pacific/Auckland", "New Zealand Standard Time" }, + { "Pacific/Fiji", "Fiji Standard Time" }, + { "Pacific/Guadalcanal", "Central Pacific Standard Time" }, + { "Pacific/Guam", "West Pacific Standard Time" }, + { "Pacific/Honolulu", "Hawaiian Standard Time" }, + { "Pacific/Pago_Pago", "UTC-11" }, + { "Pacific/Port_Moresby", "West Pacific Standard Time" }, + { "Pacific/Tongatapu", "Tonga Standard Time" } + }; + } +} diff --git a/NWS.net/WeatherMaps.cs b/NWS.net/WeatherMaps.cs new file mode 100644 index 0000000..5c12447 --- /dev/null +++ b/NWS.net/WeatherMaps.cs @@ -0,0 +1,69 @@ +namespace NWS.net { + public class WeatherMaps { + + [Description("Gets the image for today's national forecast.")] + public static string National_Forecast_Day1 { get; } = "https://www.wpc.ncep.noaa.gov/noaa/noaad1.gif?1640122487"; + + [Description("Gets the image for tomorrow's national forecast.")] + public static string National_Forecast_Day2 { get; } = "https://www.wpc.ncep.noaa.gov/noaa/noaad2.gif?1640122487"; + + [Description("Gets the image for the day after tomorrow's national forecast.")] + public static string National_Forecast_Day3 { get; } = "https://www.wpc.ncep.noaa.gov/noaa/noaad3.gif?1640122487"; + + [Description("Gets the current radar for the forecast area.")] + public string Local_Radar { get { return "https://radar.weather.gov/ridge/lite/" + RadarStation + "_loop.gif"; } } + + string RadarStation { get; set; } = "KLWX"; + + public WeatherMaps(string RadarStation) { this.RadarStation = RadarStation; } + + public static string Convective_Outlook { get; } = "https://www.spc.noaa.gov/products/activity_loop.gif"; + public static string National_Warnings { get; } = "https://forecast.weather.gov/wwamap/png/US.png"; + + public string GetGraphicalHazard(int Day, string Hazard) { + string station = RadarStation[1..].ToLower(); + switch (Hazard.ToUpper()) { + case "COLD": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/ExcessiveColdDay{0}.png", Day, station); + case "HEAT": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/ExcessiveHeatDay{0}.png", Day, station); + case "FIRE": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/FireWeatherDay{0}.png", Day, station); + case "GFDI": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/FireWxGFDIDay{0}.png", Day, station); + case "RAIN": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/FloodingDay{0}.png", Day, station); + case "FOG": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/FogDay{0}.png", Day, station); + case "HAIL": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/HailDay{0}.png", Day, station); + case "LIGHTNING": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/LightningDay{0}.png", Day, station); + case "NONT-STORM WIND": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/NonThunderstormWindDay{0}.png", Day, station); + case "ICE": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/IceAccumulationDay{0}.png", Day, station); + case "SNOW": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/SnowSleetDay{0}.png", Day, station); + case "SPOTTER": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/SpotterOutlookDay{0}.png", Day, station); + case "SEVERE T-STORM": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/SevereThunderstormsDay{0}.png", Day, station); + case "T-STORM WIND": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/ThunderstormWindGustDay{0}.png", Day, station); + case "TORNADO": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/TornadoDay{0}.png", Day, station); + case "COASTAL FLOOD": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/CoastalFloodDay{0}.png", Day, station); + case "SPRAY": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/FreezingSprayDay{0}.png", Day, station); + case "MARINE": + return string.Format("https://www.weather.gov/images/{1}/EHWO/Day{0}/MarineHazardDay{0}.png", Day, station); + default: + break; + } + return string.Empty; + } + + } +}