175 lines
7.3 KiB
HTML
175 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>RLX Severe Helper</title>
|
|
</head>
|
|
<body>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js" integrity="sha512-WNLxfP/8cVYL9sj8Jnp6et0BkubLP31jhTG9vhL/F5uEZmg5wEzKoXp1kJslzPQWwPT1eyMiSxlKCgzHLOTOTQ==" crossorigin="anonymous"></script>
|
|
<link href="https://unpkg.com/tabulator-tables@4.7.2/dist/css/tabulator.min.css" rel="stylesheet">
|
|
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.7.2/dist/js/tabulator.min.js"></script>
|
|
|
|
<div id="disclaimer">
|
|
A factor of 2.5 is applied to raw outages to account for household size<br>
|
|
|
|
Click on the product id to go directly to the IAState page for the polygon<br>
|
|
Click on the number under potentially verifying outages to evaluate the individual polygon/radar/outages<br>
|
|
Click on Ver LSRs to see the LSRs that have been submitted for the polygon<br>
|
|
Note: To prevent continuous calls to IAState for LSRs, you will need to refresh the page to update verifying LSRs<br>
|
|
Note: The 5 mile buffer helps to account for my outage points being the centroid of any outage polygon, if this number is large compared to the other outage number you may need to take look at the archived power map to see where they are (I'm going to add just showing all outage points for the valid time of the polygon + a selectable buffer and showing the outage polygons to my todo list!)
|
|
|
|
</div>
|
|
<div id="outages"></div>
|
|
|
|
<script>
|
|
lsrdata = {}
|
|
function googleMap(cell, formatterParams){
|
|
return "http://maps.google.com/maps?t=k&q=loc:" + cell.getData().lat + "+" + cell.getData().lon + "&basemap=satellite";
|
|
}
|
|
|
|
function datestrings() {
|
|
const now = new Date();
|
|
const currentDateTimeISO = now.toISOString().slice(0, -8) + 'Z';
|
|
const oneMonthAgo = new Date();
|
|
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
|
|
const oneMonthAgoISO = oneMonthAgo.toISOString().slice(0, -8) + 'Z';
|
|
return {currentDateTimeISO, oneMonthAgoISO}
|
|
}
|
|
|
|
dates = datestrings()
|
|
start = dates['oneMonthAgoISO']
|
|
end = dates['currentDateTimeISO']
|
|
url = `https://mesonet.agron.iastate.edu/api/1/cow.json?wfo=RLX&begints=${dates.oneMonthAgoISO}&endts=${dates.currentDateTimeISO}&phenomena=SV&phenomena=TO&lsrtype=SV&lsrtype=TO`
|
|
$.getJSON(url, function(json) {
|
|
lsrdata = json;
|
|
console.log("LSR Data Loaded:", lsrdata.events.features.length, "events");
|
|
}).done(function() {
|
|
table.setData("powerapi.php?svrpolys=potato");
|
|
table.setSort([
|
|
{column:"vtec", dir: "desc"},
|
|
]);
|
|
var timeout = setInterval(reloadData, 300000);
|
|
});
|
|
|
|
function lsrfortable(cell, formatterParams) {
|
|
vtectext = cell.getData().vtec;
|
|
vtectext = vtectext.slice(1,-1);
|
|
potato = vtectext.split('.');
|
|
vtecstring = "#20" + potato[6].substring(0,2) + "-";
|
|
}
|
|
|
|
function vtecget(cell, formatterParams){
|
|
vtectext = cell.getData().vtec;
|
|
vtectext = vtectext.slice(1,-1);
|
|
potato = vtectext.split('.');
|
|
vtecstring = "#20" + potato[6].substring(0,2) + "-";
|
|
for (let i = 0; i < 6; i++) {
|
|
vtecstring = vtecstring.concat(potato[i]);
|
|
if (i < 5) {
|
|
vtecstring = vtecstring.concat("-");
|
|
}
|
|
}
|
|
return "https://mesonet.agron.iastate.edu/vtec/" + vtecstring
|
|
}
|
|
|
|
function poppcnt(cell, formatterParams) {
|
|
out = cell.getData().outagesvalid / cell.getData().polygonpop;
|
|
return out
|
|
}
|
|
|
|
function findFeatureById(featureCollection, id) {
|
|
return featureCollection.features.find(feature => feature.id === id);
|
|
}
|
|
|
|
function reloadData() {
|
|
table.replaceData("powerapi.php?svrpolys=potato");
|
|
table.setSort([
|
|
{column:"vtec", dir: "desc"},
|
|
]);
|
|
}
|
|
|
|
var table = new Tabulator("#outages", {
|
|
height: '100%',
|
|
responsiveLayout: true,
|
|
tooltipsHeader: true,
|
|
columns: [
|
|
{title:"VTEC", field:"vtec", formatter:"link", formatterParams:{url: vtecget, target:"_blank"}},
|
|
{title:"Outages During Warning + 2hrs", field:"outagesvalid"},
|
|
{title:"Polygon Population", field:"polygonpop"},
|
|
{title:"5 Mile Buffer on Polygon Outages", field:"outagesbuffer"},
|
|
{title:"Potentially Ver Outages", field:"lsrids", formatter:function(cell) {
|
|
var lsrids = cell.getData().lsrids;
|
|
if (lsrids != null) {
|
|
let array = lsrids.replace(/[{}]/g, '').split(',').filter(Boolean).map(Number);
|
|
lsrstring = lsrids.replace(/[{}]/g, '');
|
|
var vtec = cell.getData().vtec;
|
|
return "<a href='lsrtool.html?vtec=" + vtec + "&id=" + lsrstring + "' target='_blank'>"+ array.length +"</a>"
|
|
} else {
|
|
return "None"
|
|
}
|
|
}},
|
|
{title:"Ver LSRs", field:"vtec", formatter:function(cell) {
|
|
var vtec = cell.getData().vtec;
|
|
potato = vtec.split('.');
|
|
warnid = "20" + potato[6].substring(0,2) + "RLX" + Number(potato[5]) + potato[3] + "W1";
|
|
console.log("VTEC:", vtec, "WarnID:", warnid);
|
|
|
|
foundFeature = findFeatureById(lsrdata.events, warnid);
|
|
console.log("Found Event:", foundFeature ? foundFeature.properties : "Not found");
|
|
|
|
if (foundFeature) {
|
|
let stormreports = foundFeature.properties.stormreports;
|
|
if (typeof stormreports === "string") {
|
|
stormreports = stormreports.split(',').map(id => id.trim()).filter(id => id !== "");
|
|
}
|
|
stormreports = Array.isArray(stormreports) ? stormreports : [];
|
|
console.log("Storm Reports IDs:", stormreports);
|
|
|
|
let lsrs = [];
|
|
for (let i = 0; i < stormreports.length; i++) {
|
|
let remark = getlsrtext(stormreports[i], lsrdata.stormreports);
|
|
lsrs.push(remark ? remark : "No remark available for ID " + stormreports[i]);
|
|
console.log("ID:", stormreports[i], "Remark:", remark);
|
|
}
|
|
let value = lsrs.length;
|
|
|
|
let clickable = document.createElement("span");
|
|
clickable.innerHTML = value;
|
|
clickable.style.cursor = "pointer";
|
|
clickable.style.textDecoration = "underline";
|
|
|
|
// Bind the current lsrs and warnid to the click event
|
|
clickable.addEventListener("click", (function(localLsrs, localWarnid) {
|
|
return function() {
|
|
let reportText = localLsrs.length > 0
|
|
? localLsrs.join("\n\n")
|
|
: "No storm reports available.";
|
|
alert("Storm Reports for " + localWarnid + ":\n\n" + reportText);
|
|
};
|
|
})(lsrs.slice(), warnid)); // Pass copies to avoid reference issues
|
|
|
|
if (value == 0) {
|
|
color = 'red';
|
|
} else if (value == 1) {
|
|
color = 'yellow';
|
|
} else {
|
|
color = 'green';
|
|
}
|
|
cell.getElement().style.backgroundColor = color;
|
|
return clickable;
|
|
} else {
|
|
cell.getElement().style.backgroundColor = 'red';
|
|
return 'None';
|
|
}
|
|
}}
|
|
],
|
|
});
|
|
|
|
function getlsrtext(id, lsrs) {
|
|
foundFeature = findFeatureById(lsrs, id);
|
|
return foundFeature ? foundFeature.properties.remark : null;
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |