Functions for general alerts and Defiance-specific alerts
This commit is contained in:
@ -23,11 +23,11 @@ let tstp = alerts.filter(function(alert) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Filter for Flash Flood Warnings
|
// Filter for Tornado Warnings
|
||||||
|
|
||||||
let flash_flood = alerts.filter(function(alert) {
|
let tornado = alerts.filter(function(alert) {
|
||||||
if (alert.raw.properties &&
|
if (alert.raw.properties &&
|
||||||
alert.raw.properties.event === "Flash Flood Warning") {
|
alert.raw.properties.event === "Tornado Warning") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -40,7 +40,7 @@ msg.ts_count = ts.length
|
|||||||
msg.tstp = tstp
|
msg.tstp = tstp
|
||||||
msg.tstp_count = tstp.length
|
msg.tstp_count = tstp.length
|
||||||
|
|
||||||
msg.flash_flood = flash_flood
|
msg.tornado = tornado
|
||||||
msg.flash_flood_count = flash_flood.length
|
msg.tornado_count = tornado.length
|
||||||
|
|
||||||
return msg
|
return msg
|
46
weather/defiance.js
Normal file
46
weather/defiance.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
let alerts = msg.payload.features
|
||||||
|
|
||||||
|
// Filter for Severe Thunderstorm Warnings
|
||||||
|
|
||||||
|
let ts = alerts.filter(function(alert) {
|
||||||
|
if (alert.properties &&
|
||||||
|
alert.properties.event === "Severe Thunderstorm Warning") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Filter for Severe Thunderstorm Warnings with tornado detection
|
||||||
|
// that have a tornado possible parameter
|
||||||
|
|
||||||
|
let tstp = alerts.filter(function(alert) {
|
||||||
|
if (alert.properties &&
|
||||||
|
alert.properties.event === "Severe Thunderstorm Warning" &&
|
||||||
|
alert.properties.parameters &&
|
||||||
|
alert.properties.parameters.tornadoDetection &&
|
||||||
|
alert.properties.parameters.tornadoDetection.length > 0) {
|
||||||
|
let tornadoPossible = alert.properties.parameters.tornadoDetection[0]
|
||||||
|
return tornadoPossible === "POSSIBLE"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Filter for Tornado Warnings
|
||||||
|
|
||||||
|
let tornado = alerts.filter(function(alert) {
|
||||||
|
if (alert.properties &&
|
||||||
|
alert.properties.event === "Tornado Warning") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// If there are any alerts, return them
|
||||||
|
|
||||||
|
msg.ts = ts
|
||||||
|
msg.ts_count = ts.length
|
||||||
|
|
||||||
|
msg.tstp = tstp
|
||||||
|
msg.tstp_count = tstp.length
|
||||||
|
|
||||||
|
msg.tornado = tornado
|
||||||
|
msg.tornado_count = tornado.length
|
||||||
|
|
||||||
|
return msg
|
Reference in New Issue
Block a user