better error handling for api.weather.gov
This commit is contained in:
parent
9a09ccd1ea
commit
eb321005d9
2
dist/index.html
vendored
2
dist/index.html
vendored
File diff suppressed because one or more lines are too long
2
dist/resources/data.min.js
vendored
2
dist/resources/data.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/resources/ws.min.js
vendored
2
dist/resources/ws.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/twc3.html
vendored
2
dist/twc3.html
vendored
|
@ -1 +1 @@
|
||||||
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><link rel="preload" href="fonts/Star4000.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star 4 Radar.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Extended.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large Compressed.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Small.woff" as="font" crossorigin="anonymous"><link rel="stylesheet" type="text/css" href="resources/twc3.min.css?_=2.3.3"><script type="text/javascript" src="resources/data.min.js"></script><script type="text/javascript" src="resources/ws.min.js?_=2.3.3"></script></head><body><div id="version" style="display:none">2.3.3</div><div id="container"></div></body></html>
|
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><link rel="preload" href="fonts/Star4000.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star 4 Radar.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Extended.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large Compressed.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Large.woff" as="font" crossorigin="anonymous"><link rel="preload" href="fonts/Star4000 Small.woff" as="font" crossorigin="anonymous"><link rel="stylesheet" type="text/css" href="resources/twc3.min.css?_=2.4.0"><script type="text/javascript" src="resources/data.min.js"></script><script type="text/javascript" src="resources/ws.min.js?_=2.4.0"></script></head><body><div id="version" style="display:none">2.4.0</div><div id="container"></div></body></html>
|
|
@ -8016,13 +8016,6 @@ const _StationInfo = {
|
||||||
Latitude: 41.8666,
|
Latitude: 41.8666,
|
||||||
Longitude: -87.5833,
|
Longitude: -87.5833,
|
||||||
},
|
},
|
||||||
KIGQ: {
|
|
||||||
StationId: 'KIGQ',
|
|
||||||
City: 'Chicago/Lansing',
|
|
||||||
State: 'IL',
|
|
||||||
Latitude: 41.5333,
|
|
||||||
Longitude: -87.5333,
|
|
||||||
},
|
|
||||||
KZAU: {
|
KZAU: {
|
||||||
StationId: 'KZAU',
|
StationId: 'KZAU',
|
||||||
City: 'Chicago/Artcc',
|
City: 'Chicago/Artcc',
|
||||||
|
@ -8051,13 +8044,6 @@ const _StationInfo = {
|
||||||
Latitude: 39.8333,
|
Latitude: 39.8333,
|
||||||
Longitude: -88.85,
|
Longitude: -88.85,
|
||||||
},
|
},
|
||||||
KDKB: {
|
|
||||||
StationId: 'KDKB',
|
|
||||||
City: 'De Kalb',
|
|
||||||
State: 'IL',
|
|
||||||
Latitude: 41.9333,
|
|
||||||
Longitude: -88.7,
|
|
||||||
},
|
|
||||||
KC73: {
|
KC73: {
|
||||||
StationId: 'KC73',
|
StationId: 'KC73',
|
||||||
City: 'Dixon',
|
City: 'Dixon',
|
||||||
|
@ -8212,20 +8198,6 @@ const _StationInfo = {
|
||||||
Latitude: 41.45,
|
Latitude: 41.45,
|
||||||
Longitude: -90.5166,
|
Longitude: -90.5166,
|
||||||
},
|
},
|
||||||
KC56: {
|
|
||||||
StationId: 'KC56',
|
|
||||||
City: 'Monee',
|
|
||||||
State: 'IL',
|
|
||||||
Latitude: 41.3833,
|
|
||||||
Longitude: -87.6833,
|
|
||||||
},
|
|
||||||
KC09: {
|
|
||||||
StationId: 'KC09',
|
|
||||||
City: 'Morris-Washburn',
|
|
||||||
State: 'IL',
|
|
||||||
Latitude: 41.4333,
|
|
||||||
Longitude: -88.4166,
|
|
||||||
},
|
|
||||||
KAJG: {
|
KAJG: {
|
||||||
StationId: 'KAJG',
|
StationId: 'KAJG',
|
||||||
City: 'Mount Carmel',
|
City: 'Mount Carmel',
|
||||||
|
@ -8317,13 +8289,6 @@ const _StationInfo = {
|
||||||
Latitude: 42.2,
|
Latitude: 42.2,
|
||||||
Longitude: -89.1,
|
Longitude: -89.1,
|
||||||
},
|
},
|
||||||
KRPJ: {
|
|
||||||
StationId: 'KRPJ',
|
|
||||||
City: 'Rochelle/Koritz',
|
|
||||||
State: 'IL',
|
|
||||||
Latitude: 41.8833,
|
|
||||||
Longitude: -89.0833,
|
|
||||||
},
|
|
||||||
KLOT: {
|
KLOT: {
|
||||||
StationId: 'KLOT',
|
StationId: 'KLOT',
|
||||||
City: 'Romeoville/Chi',
|
City: 'Romeoville/Chi',
|
||||||
|
@ -23777,13 +23742,6 @@ const _StationInfo = {
|
||||||
Latitude: 43.4166,
|
Latitude: 43.4166,
|
||||||
Longitude: -88.7,
|
Longitude: -88.7,
|
||||||
},
|
},
|
||||||
KENW: {
|
|
||||||
StationId: 'KENW',
|
|
||||||
City: 'Kenosha',
|
|
||||||
State: 'WI',
|
|
||||||
Latitude: 42.6,
|
|
||||||
Longitude: -87.9333,
|
|
||||||
},
|
|
||||||
KLSE: {
|
KLSE: {
|
||||||
StationId: 'KLSE',
|
StationId: 'KLSE',
|
||||||
City: 'La Crosse',
|
City: 'La Crosse',
|
||||||
|
@ -24085,13 +24043,6 @@ const _StationInfo = {
|
||||||
Latitude: 43.1666,
|
Latitude: 43.1666,
|
||||||
Longitude: -88.7166,
|
Longitude: -88.7166,
|
||||||
},
|
},
|
||||||
KUES: {
|
|
||||||
StationId: 'KUES',
|
|
||||||
City: 'Waukesha Cnty',
|
|
||||||
State: 'WI',
|
|
||||||
Latitude: 43.05,
|
|
||||||
Longitude: -88.25,
|
|
||||||
},
|
|
||||||
KPCZ: {
|
KPCZ: {
|
||||||
StationId: 'KPCZ',
|
StationId: 'KPCZ',
|
||||||
City: 'Waupaca',
|
City: 'Waupaca',
|
||||||
|
|
|
@ -55,6 +55,7 @@ const icons = (() => {
|
||||||
return addPath('Cloudy.gif');
|
return addPath('Cloudy.gif');
|
||||||
|
|
||||||
case 'fog':
|
case 'fog':
|
||||||
|
case 'fog-n':
|
||||||
return addPath('Fog.gif');
|
return addPath('Fog.gif');
|
||||||
|
|
||||||
case 'rain_sleet':
|
case 'rain_sleet':
|
||||||
|
@ -124,7 +125,7 @@ const icons = (() => {
|
||||||
return addPath('Blowing Snow.gif');
|
return addPath('Blowing Snow.gif');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log(`Unable to locate regional icon for ${link} ${isNightTime}`);
|
console.log(`Unable to locate regional icon for ${conditionName} ${link} ${isNightTime}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -245,7 +246,7 @@ const icons = (() => {
|
||||||
return addPath('Blowing-Snow.gif');
|
return addPath('Blowing-Snow.gif');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log(`Unable to locate icon for ${link} ${isNightTime}`);
|
console.log(`Unable to locate icon for ${conditionName} ${link} ${isNightTime}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,6 +50,12 @@ class LatestObservations extends WeatherDisplay {
|
||||||
// cut down to the maximum of 7
|
// cut down to the maximum of 7
|
||||||
this.data = actualConditions.slice(0,this.MaximumRegionalStations);
|
this.data = actualConditions.slice(0,this.MaximumRegionalStations);
|
||||||
|
|
||||||
|
// test for at least one station
|
||||||
|
if (this.data.length < 1) {
|
||||||
|
this.setStatus(STATUS.noData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.drawCanvas();
|
this.drawCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@ class LocalForecast extends WeatherDisplay {
|
||||||
|
|
||||||
// get raw data
|
// get raw data
|
||||||
const rawData = await this.getRawData(weatherParameters);
|
const rawData = await this.getRawData(weatherParameters);
|
||||||
|
// check for data
|
||||||
|
if (!rawData) {
|
||||||
|
this.setStatus(STATUS.failed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// parse raw data
|
// parse raw data
|
||||||
const conditions = this.parseLocalForecast(rawData);
|
const conditions = this.parseLocalForecast(rawData);
|
||||||
|
|
||||||
|
@ -78,7 +83,7 @@ class LocalForecast extends WeatherDisplay {
|
||||||
|
|
||||||
this.currentScreen = 0;
|
this.currentScreen = 0;
|
||||||
this.timing.totalScreens = this.screenTexts.length;
|
this.timing.totalScreens = this.screenTexts.length;
|
||||||
this.drawCanvas();
|
this.setStatus(STATUS.loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the unformatted data (also used by extended forecast)
|
// get the unformatted data (also used by extended forecast)
|
||||||
|
@ -124,11 +129,7 @@ class LocalForecast extends WeatherDisplay {
|
||||||
this.screenTexts[this.screenIndex].split('\n').forEach((text, index) => {
|
this.screenTexts[this.screenIndex].split('\n').forEach((text, index) => {
|
||||||
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 75, 140+40*index, text, 2);
|
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 75, 140+40*index, text, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.finishDraw();
|
this.finishDraw();
|
||||||
this.setStatus(STATUS.loaded);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// format the forecast
|
// format the forecast
|
||||||
|
|
|
@ -16,22 +16,19 @@ class Radar extends WeatherDisplay {
|
||||||
{time: 1, si: 2},
|
{time: 1, si: 2},
|
||||||
{time: 1, si: 3},
|
{time: 1, si: 3},
|
||||||
{time: 1, si: 4},
|
{time: 1, si: 4},
|
||||||
{time: 1, si: 5},
|
{time: 4, si: 5},
|
||||||
{time: 4, si: 6},
|
|
||||||
{time: 1, si: 0},
|
{time: 1, si: 0},
|
||||||
{time: 1, si: 1},
|
{time: 1, si: 1},
|
||||||
{time: 1, si: 2},
|
{time: 1, si: 2},
|
||||||
{time: 1, si: 3},
|
{time: 1, si: 3},
|
||||||
{time: 1, si: 4},
|
{time: 1, si: 4},
|
||||||
{time: 1, si: 5},
|
{time: 4, si: 5},
|
||||||
{time: 4, si: 6},
|
|
||||||
{time: 1, si: 0},
|
{time: 1, si: 0},
|
||||||
{time: 1, si: 1},
|
{time: 1, si: 1},
|
||||||
{time: 1, si: 2},
|
{time: 1, si: 2},
|
||||||
{time: 1, si: 3},
|
{time: 1, si: 3},
|
||||||
{time: 1, si: 4},
|
{time: 1, si: 4},
|
||||||
{time: 1, si: 5},
|
{time: 12, si: 5},
|
||||||
{time: 12, si: 6},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// pre-load background image (returns promise)
|
// pre-load background image (returns promise)
|
||||||
|
@ -214,10 +211,12 @@ class Radar extends WeatherDisplay {
|
||||||
this.data = radarInfo.map(radar=>radar.canvas);
|
this.data = radarInfo.map(radar=>radar.canvas);
|
||||||
|
|
||||||
this.times = radarInfo.map(radar=>radar.time);
|
this.times = radarInfo.map(radar=>radar.time);
|
||||||
|
this.setStatus(STATUS.loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
async drawCanvas() {
|
async drawCanvas() {
|
||||||
super.drawCanvas();
|
super.drawCanvas();
|
||||||
|
if (this.screenIndex === -1) return;
|
||||||
this.context.drawImage(await this.backgroundImage, 0, 0);
|
this.context.drawImage(await this.backgroundImage, 0, 0);
|
||||||
const {DateTime} = luxon;
|
const {DateTime} = luxon;
|
||||||
// Title
|
// Title
|
||||||
|
@ -244,7 +243,6 @@ class Radar extends WeatherDisplay {
|
||||||
draw.text(this.context, 'Star4000 Small', '24pt', '#ffffff', 438, 105, this.times[this.screenIndex].toLocaleString(DateTime.TIME_SIMPLE), 2, 'center');
|
draw.text(this.context, 'Star4000 Small', '24pt', '#ffffff', 438, 105, this.times[this.screenIndex].toLocaleString(DateTime.TIME_SIMPLE), 2, 'center');
|
||||||
|
|
||||||
this.finishDraw();
|
this.finishDraw();
|
||||||
this.setStatus(STATUS.loaded);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility latitude/pixel conversions
|
// utility latitude/pixel conversions
|
||||||
|
|
|
@ -115,6 +115,12 @@ class RegionalForecast extends WeatherDisplay {
|
||||||
// filter out any false (unavailable data)
|
// filter out any false (unavailable data)
|
||||||
const regionalData = regionalDataAll.filter(data => data);
|
const regionalData = regionalDataAll.filter(data => data);
|
||||||
|
|
||||||
|
// test for data present
|
||||||
|
if (regionalData.length === 0) {
|
||||||
|
this.setStatus(STATUS.noData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// return the weather data and offsets
|
// return the weather data and offsets
|
||||||
this.data = {
|
this.data = {
|
||||||
regionalData,
|
regionalData,
|
||||||
|
@ -123,7 +129,6 @@ class RegionalForecast extends WeatherDisplay {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setStatus(STATUS.loaded);
|
this.setStatus(STATUS.loaded);
|
||||||
this.drawCanvas();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildForecast (forecast, city, cityXY) {
|
buildForecast (forecast, city, cityXY) {
|
||||||
|
|
|
@ -59,6 +59,14 @@ class TravelForecast extends WeatherDisplay {
|
||||||
// wait for all forecasts
|
// wait for all forecasts
|
||||||
const forecasts = await Promise.all(forecastPromises);
|
const forecasts = await Promise.all(forecastPromises);
|
||||||
this.data = forecasts;
|
this.data = forecasts;
|
||||||
|
|
||||||
|
// test for some data available in at least one forecast
|
||||||
|
const hasData = this.data.reduce((acc,forecast) => acc || forecast.high, false);
|
||||||
|
if (!hasData) {
|
||||||
|
this.setStatus(STATUS.noData);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.drawCanvas(true);
|
this.drawCanvas(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
module.exports = '2.3.3';
|
module.exports = '2.4.0';
|
Loading…
Reference in a new issue