Add stats for considerable destructive t-storm, confirmed tornado

This commit is contained in:
2025-03-19 17:11:17 -04:00
parent e37e4d7718
commit 503776de4a
2 changed files with 56 additions and 10 deletions

View File

@ -4,7 +4,7 @@ let alerts = msg.payload
let ts = alerts.filter(function(alert) { let ts = alerts.filter(function(alert) {
if (alert.raw.properties && if (alert.raw.properties &&
alert.raw.properties.event === "Severe Thunderstorm Warning") { (alert.raw.properties.event === "Severe Thunderstorm Warning" || alert.raw.properties.event === "Considerable Destructive Severe Thunderstorm Warning")) {
return true return true
} }
}) })
@ -14,7 +14,7 @@ let ts = alerts.filter(function(alert) {
let tstp = alerts.filter(function(alert) { let tstp = alerts.filter(function(alert) {
if (alert.raw.properties && if (alert.raw.properties &&
alert.raw.properties.event === "Severe Thunderstorm Warning" && (alert.raw.properties.event === "Severe Thunderstorm Warning" || alert.raw.properties.event === "Considerable Destructive Severe Thunderstorm Warning") &&
alert.raw.properties.parameters && alert.raw.properties.parameters &&
alert.raw.properties.parameters.tornadoDetection && alert.raw.properties.parameters.tornadoDetection &&
alert.raw.properties.parameters.tornadoDetection.length > 0) { alert.raw.properties.parameters.tornadoDetection.length > 0) {
@ -23,11 +23,27 @@ let tstp = alerts.filter(function(alert) {
} }
}) })
// Filter for considerable destructive severe thunderstorm warnings
let cdst = alerts.filter(function(alert) {
if (alert.raw.properties &&
alert.raw.properties.event === "Considerable Destructive Severe Thunderstorm Warning") {
return true
}
})
// Filter for Tornado Warnings // Filter for Tornado Warnings
let tornado = alerts.filter(function(alert) { let tornado = alerts.filter(function(alert) {
if (alert.raw.properties && if (alert.raw.properties &&
alert.raw.properties.event === "Tornado Warning") { (alert.raw.properties.event === "Tornado Warning" || alert.raw.properties.event === "Confirmed Tornado Warning")) {
return true
}
})
let confirmed_tornado = alerts.filter(function(alert) {
if (alert.raw.properties &&
alert.raw.properties.event === "Confirmed Tornado Warning") {
return true return true
} }
}) })
@ -38,14 +54,16 @@ let tstormMsg = {
"payload": { "payload": {
"alerts": ts, "alerts": ts,
"count": ts.length, "count": ts.length,
"tornado_possible": tstp.length "tornado_possible": tstp.length,
"considerable_destructive": cdst.length
} }
} }
let tornadoWarnMsg = { let tornadoWarnMsg = {
"payload": { "payload": {
"alerts": tornado, "alerts": tornado,
"count": tornado.length "count": tornado.length,
"confirmed": confirmed_tornado.length
} }
} }

View File

@ -1,11 +1,13 @@
let alerts = msg.payload.features let alerts = msg.payload.features
let tornado_possible = false let tornado_possible = false
let considerable_destructive = false
let confirmed = false
// Filter for Severe Thunderstorm Warnings // Filter for Severe Thunderstorm Warnings
let ts = alerts.filter(function(alert) { let ts = alerts.filter(function(alert) {
if (alert.properties && if (alert.properties &&
alert.properties.event === "Severe Thunderstorm Warning") { (alert.properties.event === "Severe Thunderstorm Warning" || alert.properties.event === "Considerable Destructive Severe Thunderstorm Warning")) {
return true return true
} }
}) })
@ -15,7 +17,7 @@ let ts = alerts.filter(function(alert) {
let tstp = alerts.filter(function(alert) { let tstp = alerts.filter(function(alert) {
if (alert.properties && if (alert.properties &&
alert.properties.event === "Severe Thunderstorm Warning" && (alert.properties.event === "Severe Thunderstorm Warning" || alert.properties.event === "Considerable Destructive Severe Thunderstorm Warning") &&
alert.properties.parameters && alert.properties.parameters &&
alert.properties.parameters.tornadoDetection && alert.properties.parameters.tornadoDetection &&
alert.properties.parameters.tornadoDetection.length > 0) { alert.properties.parameters.tornadoDetection.length > 0) {
@ -28,29 +30,55 @@ if (tstp.length > 0) {
tornado_possible = true tornado_possible = true
} }
// Filter for considerable destructive severe thunderstorm warnings
let cdst = alerts.filter(function(alert) {
if (alert.properties &&
alert.properties.event === "Considerable Destructive Severe Thunderstorm Warning") {
return true
}
})
if (cdst.length > 0) {
considerable_destructive = true
}
// Filter for Tornado Warnings // Filter for Tornado Warnings
let tornado = alerts.filter(function(alert) { let tornado = alerts.filter(function(alert) {
if (alert.properties && if (alert.properties &&
alert.properties.event === "Tornado Warning") { (alert.properties.event === "Tornado Warning" || alert.properties.event === "Confirmed Tornado Warning")) {
return true return true
} }
}) })
let confirmed_tornado = alerts.filter(function(alert) {
if (alert.properties &&
alert.properties.event === "Confirmed Tornado Warning") {
return true
}
})
if (confirmed_tornado.length > 0) {
confirmed = true
}
// If there are any alerts, return them // If there are any alerts, return them
let tstormMsg = { let tstormMsg = {
"payload": { "payload": {
"alerts": ts, "alerts": ts,
"count": ts.length, "count": ts.length,
"tornado_possible": tornado_possible "tornado_possible": tornado_possible,
"considerable_destructive": considerable_destructive
} }
} }
let tornadoWarnMsg = { let tornadoWarnMsg = {
"payload": { "payload": {
"alerts": tornado, "alerts": tornado,
"count": tornado.length "count": tornado.length,
"confirmed": confirmed
} }
} }