Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
V0.1.5

Updates:

Added Weather Alerts
  • Loading branch information
ModeratePrawn authored Jun 22, 2022
1 parent 69891da commit 6d04839
Show file tree
Hide file tree
Showing 4 changed files with 335 additions and 7 deletions.
189 changes: 189 additions & 0 deletions AlertInfo.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://new_dynamicfont.tres" type="DynamicFont" id=1]

[node name="AlertInfo" type="VBoxContainer"]
margin_right = 717.0
margin_bottom = 393.0

[node name="Intro" type="HBoxContainer" parent="."]
margin_right = 720.0
margin_bottom = 28.0
alignment = 1

[node name="IntroLabel" type="Label" parent="Intro"]
margin_left = 321.0
margin_right = 394.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Alert #"
align = 1

[node name="AlertNum" type="Label" parent="Intro"]
margin_left = 398.0
margin_right = 398.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )

[node name="Headline" type="HBoxContainer" parent="."]
margin_top = 32.0
margin_right = 720.0
margin_bottom = 91.0
alignment = 1

[node name="HLabel" type="Label" parent="Headline"]
margin_right = 720.0
margin_bottom = 59.0
rect_min_size = Vector2( 720, 15 )
custom_fonts/font = ExtResource( 1 )
text = "Flood Watch issued June 22 at 10:51AM EDT until June 22 at 11:00PM EDT by NWS Baltimore MD/Washington DC"
align = 1
autowrap = true

[node name="HSeparator3" type="HSeparator" parent="."]
margin_top = 95.0
margin_right = 720.0
margin_bottom = 99.0

[node name="AlertInfo1" type="HBoxContainer" parent="."]
margin_top = 103.0
margin_right = 720.0
margin_bottom = 131.0
alignment = 1

[node name="Label" type="Label" parent="AlertInfo1"]
margin_left = 273.0
margin_right = 368.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Severity:"
align = 1

[node name="A1Status" type="Label" parent="AlertInfo1"]
margin_left = 372.0
margin_right = 446.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Severe"
align = 1

[node name="AlertInfo2" type="HBoxContainer" parent="."]
margin_top = 135.0
margin_right = 720.0
margin_bottom = 163.0
alignment = 1

[node name="Label" type="Label" parent="AlertInfo2"]
margin_left = 261.0
margin_right = 367.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Certainty:"
align = 1

[node name="A2Status" type="Label" parent="AlertInfo2"]
margin_left = 371.0
margin_right = 459.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Possible"
align = 1

[node name="AlertInfo3" type="HBoxContainer" parent="."]
margin_top = 167.0
margin_right = 720.0
margin_bottom = 195.0
alignment = 1

[node name="Label" type="Label" parent="AlertInfo3"]
margin_left = 275.0
margin_right = 368.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Urgency:"
align = 1

[node name="A3Status" type="Label" parent="AlertInfo3"]
margin_left = 372.0
margin_right = 445.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Future"
align = 1

[node name="AlertInfo4" type="HBoxContainer" parent="."]
margin_top = 199.0
margin_right = 720.0
margin_bottom = 227.0
alignment = 1

[node name="Label" type="Label" parent="AlertInfo4"]
margin_left = 257.0
margin_right = 325.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Event:"
align = 1

[node name="A4Status" type="Label" parent="AlertInfo4"]
margin_left = 329.0
margin_right = 462.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Flood Watch"
align = 1

[node name="AlertInfo5" type="HBoxContainer" parent="."]
margin_top = 231.0
margin_right = 720.0
margin_bottom = 259.0
alignment = 1

[node name="Label" type="Label" parent="AlertInfo5"]
margin_left = 261.0
margin_right = 370.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Response:"
align = 1

[node name="A5Status" type="Label" parent="AlertInfo5"]
margin_left = 374.0
margin_right = 459.0
margin_bottom = 28.0
custom_fonts/font = ExtResource( 1 )
text = "Prepare"
align = 1

[node name="HSeparator2" type="HSeparator" parent="."]
margin_top = 263.0
margin_right = 720.0
margin_bottom = 267.0

[node name="Desc" type="Label" parent="."]
margin_top = 271.0
margin_right = 720.0
margin_bottom = 1043.0
custom_fonts/font = ExtResource( 1 )
text = "* WHAT...Flash flooding caused by excessive rainfall continues to be\\npossible.\\n\\n* WHERE...Portions of DC, Maryland, Virginia and West Virginia,\\nincluding the following areas: in DC, District of Columbia. In\\nMaryland, Carroll, Central and Eastern Allegany, Central and\\nSoutheast Howard, Central and Southeast Montgomery, Frederick MD,\\nNorthern Baltimore, Northwest Howard, Northwest Montgomery, Prince\\nGeorges, Southern Baltimore and Washington. In Virginia,\\nArlington/Falls Church/Alexandria, Clarke, Culpeper, Eastern\\nLoudoun, Fairfax, Frederick VA, Greene, Madison, Northern\\nFauquier, Northern Virginia Blue Ridge, Orange, Page, Prince\\nWilliam/Manassas/Manassas Park, Rappahannock, Rockingham,\\nShenandoah, Southern Fauquier, Spotsylvania, Stafford, Warren and\\nWestern Loudoun. In West Virginia, Berkeley, Eastern Mineral,\\nHampshire, Hardy, Jefferson and Morgan.\\n\\n* WHEN...From 3 PM EDT this afternoon through this evening.\\n\\n* IMPACTS...Excessive runoff may result in flooding of rivers,\\ncreeks, streams, and other low-lying and flood-prone locations.\\n\\n* ADDITIONAL DETAILS...\\n- Widespread showers and thunderstorms are expected later this\\nafternoon into the evening. Given a very warm and moist air\\nmass, these will produce some very heavy rainfall at times.\\nRainfall amounts of 1 to 3 inches are possible within the\\nspan of a couple of hours, with locally higher amounts\\npossible.\\n- http://www.weather.gov/safety/flood"
align = 1
autowrap = true

[node name="HSeparator4" type="HSeparator" parent="."]
margin_top = 1047.0
margin_right = 720.0
margin_bottom = 1051.0

[node name="Ins" type="Label" parent="."]
margin_top = 1055.0
margin_right = 720.0
margin_bottom = 1083.0
custom_fonts/font = ExtResource( 1 )
text = "Instructions Go Here"
align = 1
autowrap = true

[node name="HSeparator5" type="HSeparator" parent="."]
margin_top = 1087.0
margin_right = 720.0
margin_bottom = 1091.0
97 changes: 96 additions & 1 deletion Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ var CatForecastURL
var WeeklyForecastResult
var HourlyForecastResult
var DetailedForecastNumebr
var CityState = str(city,state)
var CityState
var ZoneURL
var ZoneID
var AlertBase = "https://api.weather.gov/alerts/active/zone/"
var ActiveAlertURL
var Alerts
var AlertCount

func _ready():
print("Program Starting")
Expand All @@ -36,6 +42,8 @@ func _on_Location_request_completed(result, response_code, headers, body):
zipCode = json.result.zip
lat = json.result.lat
long = json.result.lon
#lat = 33.4025 #For Testing.
#long = -84.522 #For Testing
fullURL = str(baseURL, lat, ",", long)
CityState = str(city," ",state)
$GUI/Forecasts/Window/Header/Location.text = String(CityState)
Expand All @@ -57,22 +65,29 @@ func _on_Forecast_request_completed(result, response_code, headers, body):
ForecastURL = GPjson.result.properties.forecast
HForecastURL = GPjson.result.properties.forecastHourly
CatForecastURL = str(ForecastURL,ImpUnits)
ZoneURL = GPjson.result.properties.county
print("Forecast URL:")
print(ForecastURL)
print("Hourly URL:")
print(HForecastURL)
print("Full Weekly URL:")
print(CatForecastURL)
print("Zone URL:")
print(ZoneURL)
print("Getting Weekly Forecast")
getHourlyForecast()
getWeeklyForecast()
getZoneID()

func getHourlyForecast():
$NetworkController/HoulyForecast.request(HForecastURL)

func getWeeklyForecast():
$NetworkController/WeeklyForecast.request(CatForecastURL)

func getZoneID():
$NetworkController/ZoneIDRequest.request(ZoneURL)

func _on_HoulyForecast_request_completed(result, response_code, headers, body):
var HourlyForecastJSON = JSON.parse(body.get_string_from_utf8())
HourlyForecastResult = HourlyForecastJSON.result.properties.periods
Expand All @@ -83,6 +98,85 @@ func _on_WeeklyForecast_request_completed(result, response_code, headers, body):
WeeklyForecastResult = WeeklyForecastJSON.result.properties.periods
PrintWeeklyResults()

func _on_ZoneIDRequest_request_completed(result, response_code, headers, body):
var ZoneIDRequestResult = JSON.parse(body.get_string_from_utf8())
ZoneID = ZoneIDRequestResult.result.properties.id
ActiveAlertURL = str(AlertBase,ZoneID)
print("ZoneID:")
print(ZoneID)
print("Active Alerts URL:")
print(ActiveAlertURL)
getAlerts()

func getAlerts():
$NetworkController/AlertRequest.request(ActiveAlertURL)

func _on_AlertRequest_request_completed(result, response_code, headers, body):
var AlertJSON = JSON.parse(body.get_string_from_utf8())
Alerts = AlertJSON.result.features
AlertHandler()

func AlertHandler():
print("Alerts:")
if Alerts == []:
print("No Alerts")
$GUI/Forecasts/Window/NowCast/Alert.visible = false
else:
$GUI/Forecasts/Window/NowCast/Alert.visible = true
print("ALERT!")
AlertCount = Alerts.size()
#AlertCount = 3 #Testing.
print("Alert Count:")
print(AlertCount)
alertProcessing()

func alertProcessing():
var i = AlertCount
var Counter = 0
var AlertNumber = 1
var scene = ResourceLoader.load("res://AlertInfo.tscn")
var path = get_tree().get_root().get_node("Main/GUI/AlertDisplay/Body/AlertScroll/Target")
print(path)
print(scene)
print(i)

for number in range(i):
#Make Instance
print("Loop:", Counter)
var NewInstance = scene.instance()
NewInstance.name = "AlertInfo" + String(Counter)
path.add_child(NewInstance)
print("New Instance Name:")
print(NewInstance.name)
NewInstance.get_node("Intro/AlertNum").text = String(AlertNumber)
NewInstance.get_node("Headline/HLabel").text = String(Alerts[Counter].properties.headline)
NewInstance.get_node("AlertInfo1/A1Status").text = String(Alerts[Counter].properties.severity)
NewInstance.get_node("AlertInfo2/A2Status").text = String(Alerts[Counter].properties.certainty)
NewInstance.get_node("AlertInfo3/A3Status").text = String(Alerts[Counter].properties.urgency)
NewInstance.get_node("AlertInfo4/A4Status").text = String(Alerts[Counter].properties.event)
NewInstance.get_node("AlertInfo5/A5Status").text = String(Alerts[Counter].properties.response)
NewInstance.get_node("Desc").text = String(Alerts[Counter].properties.description)
print("Instructions:")
print(Alerts[Counter].properties.instruction)

if Alerts[Counter].properties.instruction == null:
print("NULL!!!!")
NewInstance.get_node("Ins").text = "No Further Instructions at this Time"
else:
print("Instructions Present")
NewInstance.get_node("Ins").text = String(Alerts[Counter].properties.instruction)

Counter = Counter + 1
AlertNumber = AlertNumber + 1

func _on_Alert_pressed():
$GUI/AlertDisplay.visible = true
$GUI/Forecasts.visible = false

func _on_ForecastReturn_pressed():
$GUI/AlertDisplay.visible = false
$GUI/Forecasts.visible = true

func PrintHourlyResults():
#NowCast
$GUI/Forecasts/Window/NowCast/NowTemp/Temp.text = String(HourlyForecastResult[0].temperature)
Expand All @@ -99,6 +193,7 @@ func PrintHourlyResults():

func PrintWeeklyResults():
$GUI/Forecasts/Window/WeeklyScroll.get_v_scrollbar().modulate = Color(0, 0, 0, 0) #Hide Scroll Bar
$GUI/AlertDisplay/Body/AlertScroll.get_v_scrollbar().modulate = Color(0, 0, 0, 0) #Hide Scroll Bar
$GUI/Forecasts/Window/WeeklyScroll/WeekCast/W0/Date.text = String(WeeklyForecastResult[0].name)
$GUI/Forecasts/Window/WeeklyScroll/WeekCast/W0/W0Temp/Temp.text = String(WeeklyForecastResult[0].temperature)
$GUI/Forecasts/Window/WeeklyScroll/WeekCast/W0/W0Temp/Unit.text = String(WeeklyForecastResult[0].temperatureUnit)
Expand Down
Loading

0 comments on commit 6d04839

Please sign in to comment.