radar displays timestamp
This commit is contained in:
parent
6a2317d283
commit
53a9d5f00b
2
dist/index.html
vendored
2
dist/index.html
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.1"><script type="text/javascript" src="resources/data.min.js"></script><script type="text/javascript" src="resources/ws.min.js?_=2.3.1"></script></head><body><div id="version" style="display:none">2.3.1</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.3.2"><script type="text/javascript" src="resources/data.min.js"></script><script type="text/javascript" src="resources/ws.min.js?_=2.3.2"></script></head><body><div id="version" style="display:none">2.3.2</div><div id="container"></div></body></html>
|
|
@ -1,5 +1,5 @@
|
|||
// current weather conditions display
|
||||
/* globals WeatherDisplay, utils, STATUS, draw */
|
||||
/* globals WeatherDisplay, utils, STATUS, draw, luxon */
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
class Radar extends WeatherDisplay {
|
||||
|
@ -25,6 +25,9 @@ class Radar extends WeatherDisplay {
|
|||
return;
|
||||
}
|
||||
|
||||
// date and time parsing
|
||||
const {DateTime} = luxon;
|
||||
|
||||
// get the base map
|
||||
let src = 'images/4000RadarMap2.jpg';
|
||||
if (weatherParameters.State === 'HI') src = 'images/HawaiiRadarMap2.png';
|
||||
|
@ -106,6 +109,7 @@ class Radar extends WeatherDisplay {
|
|||
}
|
||||
|
||||
// Load the most recent doppler radar images.
|
||||
const radarTimes = [];
|
||||
const radarCanvases = await Promise.all(urls.map(async (url) => {
|
||||
// create destination context
|
||||
const canvas = document.createElement('canvas');
|
||||
|
@ -114,6 +118,17 @@ class Radar extends WeatherDisplay {
|
|||
const context = canvas.getContext('2d');
|
||||
context.imageSmoothingEnabled = false;
|
||||
|
||||
// store the time
|
||||
const [, year, month, day, hour, minute] = url.match(/_(\d{4})(\d\d)(\d\d)_(\d\d)(\d\d)_/);
|
||||
radarTimes.push(DateTime.fromObject({
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hour,
|
||||
minute,
|
||||
zone: 'UTC',
|
||||
}).setZone());
|
||||
|
||||
// get the image
|
||||
const blob = await $.ajaxCORS({
|
||||
type: 'GET',
|
||||
|
@ -158,13 +173,14 @@ class Radar extends WeatherDisplay {
|
|||
this.timing.totalScreens = radarCanvases.length;
|
||||
// store the images
|
||||
this.data = radarCanvases;
|
||||
this.times = radarTimes;
|
||||
this.drawCanvas();
|
||||
}
|
||||
|
||||
async drawCanvas() {
|
||||
super.drawCanvas();
|
||||
this.context.drawImage(await this.backgroundImage, 0, 0);
|
||||
|
||||
const {DateTime} = luxon;
|
||||
// Title
|
||||
draw.text(this.context, 'Arial', 'bold 28pt', '#ffffff', 175, 65, 'Local', 2);
|
||||
draw.text(this.context, 'Arial', 'bold 28pt', '#ffffff', 175, 100, 'Radar', 2);
|
||||
|
@ -190,6 +206,7 @@ class Radar extends WeatherDisplay {
|
|||
draw.text(this.context, 'Arial', 'bold 18pt', '#ffffff', 355, 105, '= Incomplete Data', 2);
|
||||
|
||||
this.context.drawImage(this.data[this.screenIndex], 0, 0, 640, 367, 0, 113, 640, 367);
|
||||
draw.text(this.context, 'Star4000 Small', '24pt', '#ffffff', 100, 110, this.times[this.screenIndex].toLocaleString(DateTime.TIME_SIMPLE), 2, 'center');
|
||||
|
||||
this.finishDraw();
|
||||
this.setStatus(STATUS.loaded);
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = '2.3.1';
|
||||
module.exports = '2.3.2';
|
Loading…
Reference in a new issue