mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 15:49:31 -07:00
some marine forecast updates
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
import STATUS from './status.mjs';
|
import STATUS from './status.mjs';
|
||||||
import WeatherDisplay from './weatherdisplay.mjs';
|
import WeatherDisplay from './weatherdisplay.mjs';
|
||||||
import { registerDisplay } from './navigation.mjs';
|
import { registerDisplay } from './navigation.mjs';
|
||||||
import getExtendedForecast from './extendedforecast.mjs';
|
|
||||||
import getHourlyForecast from './hourly.mjs';
|
import getHourlyForecast from './hourly.mjs';
|
||||||
|
|
||||||
class MarineForecast extends WeatherDisplay {
|
class MarineForecast extends WeatherDisplay {
|
||||||
@@ -19,11 +18,8 @@ class MarineForecast extends WeatherDisplay {
|
|||||||
async getData() {
|
async getData() {
|
||||||
if (!super.getData()) return;
|
if (!super.getData()) return;
|
||||||
|
|
||||||
const [extendedForecast, hourlyForecast] = await Promise.all([
|
const hourlyForecast = await getHourlyForecast(() => this.stillWaiting());
|
||||||
getExtendedForecast(() => this.stillWaiting()),
|
if (hourlyForecast === undefined) {
|
||||||
getHourlyForecast(() => this.stillWaiting()),
|
|
||||||
]);
|
|
||||||
if (extendedForecast === undefined || hourlyForecast === undefined) {
|
|
||||||
this.setStatus(STATUS.failed);
|
this.setStatus(STATUS.failed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -36,10 +32,7 @@ class MarineForecast extends WeatherDisplay {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data = {
|
this.data = hourlyForecast;
|
||||||
extendedForecast,
|
|
||||||
hourlyForecast,
|
|
||||||
};
|
|
||||||
this.screenIndex = 0;
|
this.screenIndex = 0;
|
||||||
this.setStatus(STATUS.loaded);
|
this.setStatus(STATUS.loaded);
|
||||||
}
|
}
|
||||||
@@ -54,11 +47,12 @@ class MarineForecast extends WeatherDisplay {
|
|||||||
// create each day template
|
// create each day template
|
||||||
const days = forecast.map((Day) => {
|
const days = forecast.map((Day) => {
|
||||||
const fill = {};
|
const fill = {};
|
||||||
|
const waveHeight = Math.round(Day.waveHeight * 3.281);
|
||||||
fill.date = Day.dayName;
|
fill.date = Day.dayName;
|
||||||
fill['wind-dir'] = 'NW';
|
fill['wind-dir'] = Day.windDirection;
|
||||||
fill['wind-speed'] = '10 - 15kts';
|
fill['wind-speed'] = '10 - 15kts';
|
||||||
fill['wave-height'] = '1\'';
|
fill['wave-height'] = `${waveHeight}'`;
|
||||||
fill['wave-desc'] = '';
|
fill['wave-desc'] = waveDesc(waveHeight);
|
||||||
|
|
||||||
const { low } = Day;
|
const { low } = Day;
|
||||||
if (low !== undefined) {
|
if (low !== undefined) {
|
||||||
@@ -135,5 +129,11 @@ const waveImage = (conditions) => {
|
|||||||
return canvas.toDataURL();
|
return canvas.toDataURL();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const waveDesc = (waveHeight) => {
|
||||||
|
if (waveHeight > 7) return 'ROUGH';
|
||||||
|
if (waveHeight > 4) return 'CHOPPY';
|
||||||
|
return 'LIGHT';
|
||||||
|
};
|
||||||
|
|
||||||
// register display
|
// register display
|
||||||
registerDisplay(new MarineForecast(11, 'marine-forecast'));
|
registerDisplay(new MarineForecast(11, 'marine-forecast'));
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<script type="module" src="scripts/modules/regionalforecast.mjs"></script>
|
<script type="module" src="scripts/modules/regionalforecast.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/travelforecast.mjs"></script>
|
<script type="module" src="scripts/modules/travelforecast.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/progress.mjs"></script>
|
<script type="module" src="scripts/modules/progress.mjs"></script>
|
||||||
<script type="module" src="scripts/modules/radar.mjs"></script>
|
<script type="module" src="scripts/modules/marineforecast.mjs"></script>
|
||||||
<script type="module" src="scripts/index.mjs"></script>
|
<script type="module" src="scripts/index.mjs"></script>
|
||||||
|
|
||||||
<!-- data -->
|
<!-- data -->
|
||||||
@@ -107,6 +107,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="almanac-html" class="weather-display">
|
<div id="almanac-html" class="weather-display">
|
||||||
<%- include('partials/almanac.ejs') %>
|
<%- include('partials/almanac.ejs') %>
|
||||||
|
</div>
|
||||||
|
<div id="marine-forecast-html" class="weather-display">
|
||||||
|
<%- include('partials/marine-forecast.ejs') %>
|
||||||
</div>
|
</div>
|
||||||
<div id="extended-forecast-html" class="weather-display">
|
<div id="extended-forecast-html" class="weather-display">
|
||||||
<%- include('partials/extended-forecast.ejs') %>
|
<%- include('partials/extended-forecast.ejs') %>
|
||||||
|
|||||||
@@ -51,5 +51,9 @@
|
|||||||
"editor.defaultFormatter": "j69.ejs-beautify"
|
"editor.defaultFormatter": "j69.ejs-beautify"
|
||||||
},
|
},
|
||||||
"files.exclude": {},
|
"files.exclude": {},
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user