mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-16 08:39:29 -07:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f17f69f60e | ||
|
|
fa16095355 | ||
|
|
cc3dbeb043 | ||
|
|
8ee1e954eb | ||
|
|
bfc4bddfef | ||
|
|
567325e3c5 | ||
|
|
4903b95fec | ||
|
|
b43fb32820 | ||
|
|
0d0c4ec452 | ||
|
|
49d18c2fbe | ||
|
|
1732a3381f | ||
|
|
093b6ac239 | ||
|
|
12d068d740 | ||
|
|
517c560ef6 | ||
|
|
3eb571bed4 | ||
|
|
52ca161bdb | ||
|
|
ee5690dcad | ||
|
|
c05b827593 | ||
|
|
bef42a3da2 | ||
|
|
13ff0317e6 | ||
|
|
5cc85840a9 | ||
|
|
190e50e2f3 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -11,4 +11,4 @@ Please do not report issues with api.weather.gov being down. It's a new service
|
||||
|
||||
Please include:
|
||||
* Web browser and OS
|
||||
* Location for which you are viewing a forecast
|
||||
* Forecast Information text block from the very bottom of the web page
|
||||
|
||||
12
.vscode/launch.json
vendored
12
.vscode/launch.json
vendored
@@ -26,6 +26,18 @@
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"args": [
|
||||
"--use-cache"
|
||||
],
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
"name": "Data:stations-api",
|
||||
"program": "${workspaceFolder}/datagenerators/stations.mjs",
|
||||
"request": "launch",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM node:24-alpine
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --omit=dev --legacy-peer-deps
|
||||
RUN npm ci --legacy-peer-deps
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
25
README.md
25
README.md
@@ -32,6 +32,18 @@ From a learning standpoint, this codebase make use of a lot of different methods
|
||||
* Hand written CSS made easier to mange with SASS
|
||||
* A linting library to keep code style consistent
|
||||
|
||||
## Quck Start
|
||||
|
||||
Ensure you have Node installed.
|
||||
```bash
|
||||
git clone https://github.com/netbymatt/ws4kp.git
|
||||
cd ws4kp
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
Open your browser and navigate to https://localhost:8080
|
||||
|
||||
## Does WeatherStar 4000+ work outside of the USA?
|
||||
|
||||
This project is tightly coupled to [NOAA's Weather API](https://www.weather.gov/documentation/services-web-api), which is exclusive to the United States. Using NOAA's Weather API is a crucial requirement to provide an authentic WeatherStar 4000+ experience.
|
||||
@@ -57,14 +69,7 @@ WeatherStar 4000+ supports two deployment modes:
|
||||
* Browser-based caching
|
||||
* Used by: static file hosting and default `Dockerfile`
|
||||
|
||||
## Run Your WeatherStar
|
||||
|
||||
Ensure you have Node installed. Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/netbymatt/ws4kp.git
|
||||
cd ws4kp
|
||||
npm install
|
||||
```
|
||||
## Other methods to run Ws4kp
|
||||
|
||||
### Development Mode (individual JS files, easier debugging)
|
||||
```bash
|
||||
@@ -309,11 +314,13 @@ If you're unable to pre-set the play state before entering kiosk mode (such as w
|
||||
|
||||
## Community Notes
|
||||
|
||||
Thanks to the WeatherStar community for providing these discussions to further extend your retro forecasts!
|
||||
Thanks to the WeatherStar+ community for providing these discussions to further extend your retro forecasts!
|
||||
|
||||
* [Stream as FFMPEG](https://github.com/netbymatt/ws4kp/issues/37#issuecomment-2008491948)
|
||||
* [Weather like it's 1999](https://blog.scottlabs.io/2024/02/weather-like-its-1999/) Raspberry pi, streaming, music and CRT all combined into a complete solution.
|
||||
* [ws4channels](https://github.com/rice9797/ws4channels) A Dockerized Node.js application to stream WeatherStar 4000 data into Channels DVR using Puppeteer and FFmpeg.
|
||||
* [SSL Certificates](https://github.com/netbymatt/ws4kp/issues/135) Discussion about how to host with an SSL certificate (enables geolocation).
|
||||
* [Changing playlists](https://github.com/netbymatt/ws4kp/issues/138) Possible ways to automatically change the playlist on a schedule.
|
||||
|
||||
## Customization
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,8 @@
|
||||
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
|
||||
import * as url from 'node:url';
|
||||
|
||||
// Load station data
|
||||
const stationInfo = JSON.parse(readFileSync('./datagenerators/output/stations-raw.json', 'utf8'));
|
||||
// const regionalCities = JSON.parse(readFileSync('./datagenerators/output/regionalcities.json', 'utf8'));
|
||||
@@ -1109,139 +1111,184 @@ or where the fallback to the ICAO airport code occurred:
|
||||
jq -c '.[] | select(.name | test("^[A-Z]{3}$")) | {state, city, simple, name}'
|
||||
*/
|
||||
|
||||
const diffMode = process.argv.includes('--diff');
|
||||
const onlyProblems = process.argv.includes('--only-problems');
|
||||
const noProblems = process.argv.includes('--no-problems');
|
||||
const onlyDuplicates = process.argv.includes('--only-dupes');
|
||||
const noPriority = process.argv.includes('--no-priority');
|
||||
const noSimple = process.argv.includes('--no-simple');
|
||||
const noCoordinates = process.argv.includes('--no-coords');
|
||||
const writeFile = process.argv.includes('--write');
|
||||
const readArguments = () => ({
|
||||
diffMode: process.argv.includes('--diff'),
|
||||
onlyProblems: process.argv.includes('--only-problems'),
|
||||
noProblems: process.argv.includes('--no-problems'),
|
||||
onlyDuplicates: process.argv.includes('--only-dupes'),
|
||||
noPriority: process.argv.includes('--no-priority'),
|
||||
noSimple: process.argv.includes('--no-simple'),
|
||||
noCoordinates: process.argv.includes('--no-coords'),
|
||||
writeFile: process.argv.includes('--write'),
|
||||
});
|
||||
|
||||
// Process ALL stations at once to get the display name map
|
||||
let displayNameMap = processAllStations(stationInfo);
|
||||
const DEFAULT_OPTIONS = {
|
||||
diffMode: false,
|
||||
onlyProblems: false,
|
||||
noProblems: false,
|
||||
onlyDuplicates: false,
|
||||
noPriority: false,
|
||||
noSimple: false,
|
||||
noCoordinates: false,
|
||||
writeFile: false,
|
||||
};
|
||||
|
||||
// Apply priority-based deduplication
|
||||
displayNameMap = resolveDuplicatesByPriority(displayNameMap, stationInfo);
|
||||
const postProcessor = (_options) => {
|
||||
// combine default and provided options
|
||||
const options = { ...DEFAULT_OPTIONS, ..._options };
|
||||
|
||||
const results = [];
|
||||
// Process ALL stations at once to get the display name map
|
||||
let displayNameMap = processAllStations(stationInfo);
|
||||
|
||||
// Now iterate through stations and use the pre-computed display names
|
||||
const stations = Object.values(stationInfo);
|
||||
stations.forEach((station) => {
|
||||
const originalName = station.city;
|
||||
const processedName = processingUtils.finalCleanup(displayNameMap[station.id]); // Look up by station ID
|
||||
// Apply priority-based deduplication
|
||||
displayNameMap = resolveDuplicatesByPriority(displayNameMap, stationInfo);
|
||||
|
||||
// Get airport type and priority for this station
|
||||
const airportType = getAirportType(originalName, station.id); // Pass station ID for enhanced detection
|
||||
const priority = getAirportPriority(airportType);
|
||||
const results = [];
|
||||
|
||||
const potentialIssues = [];
|
||||
// Check if the processed name contains punctuation (a period at the end is OK)
|
||||
if (/[,;!?/:.]/.test(processedName) && !processedName.endsWith('.')) {
|
||||
potentialIssues.push('punctuation');
|
||||
}
|
||||
if (processedName.length > 12) {
|
||||
potentialIssues.push('long');
|
||||
}
|
||||
if (processedName.length > 20) {
|
||||
potentialIssues.push('reallyLong');
|
||||
}
|
||||
// check if it contains any digits
|
||||
if (/\d/.test(processedName)) {
|
||||
potentialIssues.push('digits');
|
||||
}
|
||||
// Now iterate through stations and use the pre-computed display names
|
||||
const stations = Object.values(stationInfo);
|
||||
stations.forEach((station) => {
|
||||
const originalName = station.city;
|
||||
const processedName = processingUtils.finalCleanup(displayNameMap[station.id]); // Look up by station ID
|
||||
|
||||
results.push({
|
||||
id: station.id,
|
||||
lat: station.lat,
|
||||
lon: station.lon,
|
||||
state: station.state,
|
||||
location: originalName, // original full location name
|
||||
city: processedName, // processed city name for display
|
||||
simple: originalName.match(/[^,/;\\-]*/)[0].substr(0, 12).trim(),
|
||||
type: airportType,
|
||||
priority,
|
||||
potentialIssues,
|
||||
// Get airport type and priority for this station
|
||||
const airportType = getAirportType(originalName, station.id); // Pass station ID for enhanced detection
|
||||
const priority = getAirportPriority(airportType);
|
||||
|
||||
const potentialIssues = [];
|
||||
// Check if the processed name contains punctuation (a period at the end is OK)
|
||||
if (/[,;!?/:.]/.test(processedName) && !processedName.endsWith('.')) {
|
||||
potentialIssues.push('punctuation');
|
||||
}
|
||||
if (processedName.length > 12) {
|
||||
potentialIssues.push('long');
|
||||
}
|
||||
if (processedName.length > 20) {
|
||||
potentialIssues.push('reallyLong');
|
||||
}
|
||||
// check if it contains any digits
|
||||
if (/\d/.test(processedName)) {
|
||||
potentialIssues.push('digits');
|
||||
}
|
||||
|
||||
results.push({
|
||||
id: station.id,
|
||||
lat: station.lat,
|
||||
lon: station.lon,
|
||||
state: station.state,
|
||||
location: originalName, // original full location name
|
||||
city: processedName, // processed city name for display
|
||||
simple: originalName.match(/[^,/;\\-]*/)[0].substr(0, 12).trim(),
|
||||
type: airportType,
|
||||
priority,
|
||||
potentialIssues,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Check for duplicates by state
|
||||
const cleanedMapByState = new Map();
|
||||
// Check for duplicates by state
|
||||
const cleanedMapByState = new Map();
|
||||
|
||||
results.forEach((result) => {
|
||||
const { state } = result;
|
||||
if (!cleanedMapByState.has(state)) {
|
||||
cleanedMapByState.set(state, new Map());
|
||||
}
|
||||
const stateMap = cleanedMapByState.get(state);
|
||||
if (stateMap.has(result.city)) {
|
||||
stateMap.get(result.city).push(result);
|
||||
} else {
|
||||
stateMap.set(result.city, [result]);
|
||||
}
|
||||
});
|
||||
|
||||
cleanedMapByState.forEach((stateMap, _state) => {
|
||||
stateMap.forEach((originals, _cleaned) => {
|
||||
if (originals.length > 1) {
|
||||
originals.forEach((original) => {
|
||||
if (!original.potentialIssues.includes('duplicate')) {
|
||||
original.potentialIssues.push('duplicate');
|
||||
}
|
||||
});
|
||||
results.forEach((result) => {
|
||||
const { state } = result;
|
||||
if (!cleanedMapByState.has(state)) {
|
||||
cleanedMapByState.set(state, new Map());
|
||||
}
|
||||
const stateMap = cleanedMapByState.get(state);
|
||||
if (stateMap.has(result.city)) {
|
||||
stateMap.get(result.city).push(result);
|
||||
} else {
|
||||
stateMap.set(result.city, [result]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Filter results if requested
|
||||
let finalResults = results;
|
||||
if (onlyProblems) {
|
||||
finalResults = results.filter((r) => r.potentialIssues.length > 0);
|
||||
}
|
||||
if (onlyDuplicates) {
|
||||
finalResults = finalResults.filter((r) => r.potentialIssues.includes('duplicate'));
|
||||
}
|
||||
cleanedMapByState.forEach((stateMap, _state) => {
|
||||
stateMap.forEach((originals, _cleaned) => {
|
||||
if (originals.length > 1) {
|
||||
originals.forEach((original) => {
|
||||
if (!original.potentialIssues.includes('duplicate')) {
|
||||
original.potentialIssues.push('duplicate');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const outputResult = finalResults.map((result) => {
|
||||
let outputItem = result;
|
||||
|
||||
// Don't include lat or long in diff mode
|
||||
if (noCoordinates || diffMode) {
|
||||
const {
|
||||
lat: _lat, lon: _lon, ...resultWithoutLocation
|
||||
} = result;
|
||||
outputItem = resultWithoutLocation;
|
||||
// Filter results if requested
|
||||
let finalResults = results;
|
||||
if (options.onlyProblems) {
|
||||
finalResults = results.filter((r) => r.potentialIssues.length > 0);
|
||||
}
|
||||
if (options.onlyDuplicates) {
|
||||
finalResults = finalResults.filter((r) => r.potentialIssues.includes('duplicate'));
|
||||
}
|
||||
|
||||
// Don't include potentialIssues when --no-problems is specified
|
||||
if (noProblems || diffMode) {
|
||||
const { potentialIssues: _potentialIssues, ...resultWithoutIssues } = outputItem;
|
||||
outputItem = resultWithoutIssues;
|
||||
}
|
||||
const outputResult = finalResults.map((result) => {
|
||||
let outputItem = result;
|
||||
|
||||
// Remove type and priority if --no-priority is specified
|
||||
if (noPriority || diffMode) {
|
||||
const { type: _type, priority: _priority, ...resultWithoutPriority } = outputItem;
|
||||
outputItem = resultWithoutPriority;
|
||||
}
|
||||
// Don't include lat or long in diff mode
|
||||
if (options.noCoordinates || options.diffMode) {
|
||||
const {
|
||||
lat: _lat, lon: _lon, ...resultWithoutLocation
|
||||
} = result;
|
||||
outputItem = resultWithoutLocation;
|
||||
}
|
||||
|
||||
// remove simple field if --no-simple is specified
|
||||
if (noSimple || diffMode) {
|
||||
const { simple: _simple, ...resultWithoutSimple } = outputItem;
|
||||
outputItem = resultWithoutSimple;
|
||||
}
|
||||
// Don't include potentialIssues when --no-problems is specified
|
||||
if (options.noProblems || options.diffMode) {
|
||||
const { potentialIssues: _potentialIssues, ...resultWithoutIssues } = outputItem;
|
||||
outputItem = resultWithoutIssues;
|
||||
}
|
||||
|
||||
return outputItem;
|
||||
});
|
||||
// Remove type and priority if --no-priority is specified
|
||||
if (options.noPriority || options.diffMode) {
|
||||
const { type: _type, priority: _priority, ...resultWithoutPriority } = outputItem;
|
||||
outputItem = resultWithoutPriority;
|
||||
}
|
||||
|
||||
// remove simple field if --no-simple is specified
|
||||
if (options.noSimple || options.diffMode) {
|
||||
const { simple: _simple, ...resultWithoutSimple } = outputItem;
|
||||
outputItem = resultWithoutSimple;
|
||||
}
|
||||
|
||||
return outputItem;
|
||||
});
|
||||
|
||||
if (writeFile) {
|
||||
const fileResults = results.map(({
|
||||
simple: _simple, type: _type, potentialIssues: _potentialIssues, ...rest
|
||||
simple: _simple, type: _type, potentialIssues: _potentialIssues, location: _location, ...rest
|
||||
}) => rest);
|
||||
|
||||
writeFileSync('./datagenerators/output/stations.json', compactStringifyToObject(fileResults));
|
||||
console.log(`Wrote ${fileResults.length} processed stations to datagenerators/output/stations.json`);
|
||||
} else {
|
||||
console.log(compactStringifyToArray(outputResult));
|
||||
if (options.writeFile) {
|
||||
writeFileSync('./datagenerators/output/stations.json', compactStringifyToObject(fileResults));
|
||||
console.log(`Wrote ${fileResults.length} processed stations to datagenerators/output/stations.json`);
|
||||
} else {
|
||||
console.log(compactStringifyToArray(outputResult));
|
||||
}
|
||||
|
||||
// array to output object
|
||||
const returnObject = {};
|
||||
fileResults.forEach((item) => {
|
||||
returnObject[item.id] = item;
|
||||
});
|
||||
|
||||
return returnObject;
|
||||
};
|
||||
|
||||
// determine if running from command line or module
|
||||
const commandLine = (() => {
|
||||
if (import.meta.url.startsWith('file:')) { // (A)
|
||||
const modulePath = url.fileURLToPath(import.meta.url);
|
||||
if (process.argv[1] === modulePath) { // (B)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
)();
|
||||
|
||||
// run post processor if called from command line
|
||||
if (commandLine) {
|
||||
postProcessor(readArguments());
|
||||
}
|
||||
|
||||
export default postProcessor;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-loop-func */
|
||||
// list all stations in a single file
|
||||
// only find stations with 4 letter codes
|
||||
|
||||
@@ -6,67 +7,91 @@ import https from './https.mjs';
|
||||
import states from './stations-states.mjs';
|
||||
import chunk from './chunk.mjs';
|
||||
import overrides from './stations-overrides.mjs';
|
||||
import postProcessor from './stations-postprocessor.mjs';
|
||||
|
||||
// check for cached flag
|
||||
const USE_CACHE = process.argv.includes('--use-cache');
|
||||
|
||||
// skip stations starting with these letters
|
||||
const skipStations = ['U', 'C', 'H', 'W', 'Y', 'T', 'S', 'M', 'O', 'L', 'A', 'F', 'B', 'N', 'V', 'R', 'D', 'E', 'I', 'G', 'J'];
|
||||
|
||||
// chunk the list of states
|
||||
const chunkStates = chunk(states, 1);
|
||||
const chunkStates = chunk(states, 3);
|
||||
|
||||
// store output
|
||||
const output = {};
|
||||
let completed = 0;
|
||||
|
||||
// process all chunks
|
||||
for (let i = 0; i < chunkStates.length; i += 1) {
|
||||
const stateChunk = chunkStates[i];
|
||||
// loop through states
|
||||
// get data from api if desired
|
||||
if (!USE_CACHE) {
|
||||
// process all chunks
|
||||
for (let i = 0; i < chunkStates.length; i += 1) {
|
||||
const stateChunk = chunkStates[i];
|
||||
// loop through states
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await Promise.allSettled(stateChunk.map(async (state) => {
|
||||
try {
|
||||
let stations;
|
||||
let next = `https://api.weather.gov/stations?state=${state}`;
|
||||
let round = 0;
|
||||
do {
|
||||
console.log(`Getting: ${state}-${round}`);
|
||||
// get list and parse the JSON
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const stationsRaw = await https(next);
|
||||
stations = JSON.parse(stationsRaw);
|
||||
// filter stations for 4 letter identifiers
|
||||
const stationsFiltered4 = stations.features.filter((station) => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
|
||||
// filter against starting letter
|
||||
const stationsFiltered = stationsFiltered4.filter((station) => !skipStations.includes(station.properties.stationIdentifier.slice(0, 1)));
|
||||
// add each resulting station to the output
|
||||
stationsFiltered.forEach((station) => {
|
||||
const id = station.properties.stationIdentifier;
|
||||
if (output[id]) {
|
||||
console.log(`Duplicate station: ${state}-${id}`);
|
||||
return;
|
||||
}
|
||||
// get any overrides if available
|
||||
const override = overrides[id] ?? {};
|
||||
output[id] = {
|
||||
id,
|
||||
city: station.properties.name,
|
||||
state,
|
||||
lat: station.geometry.coordinates[1],
|
||||
lon: station.geometry.coordinates[0],
|
||||
// finally add the overrides
|
||||
...override,
|
||||
};
|
||||
});
|
||||
next = stations?.pagination?.next;
|
||||
round += 1;
|
||||
// write the output
|
||||
writeFileSync('./datagenerators/output/stations-raw.json', JSON.stringify(output, null, 2));
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await Promise.allSettled(stateChunk.map(async (state) => {
|
||||
try {
|
||||
let stations;
|
||||
let next = `https://api.weather.gov/stations?state=${state}`;
|
||||
let round = 0;
|
||||
do {
|
||||
console.log(`Getting: ${state}-${round}`);
|
||||
// get list and parse the JSON
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const stationsRaw = await https(next);
|
||||
stations = JSON.parse(stationsRaw);
|
||||
// filter stations for 4 letter identifiers
|
||||
const stationsFiltered4 = stations.features.filter((station) => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
|
||||
// filter against starting letter
|
||||
const stationsFiltered = stationsFiltered4.filter((station) => !skipStations.includes(station.properties.stationIdentifier.slice(0, 1)));
|
||||
// add each resulting station to the output
|
||||
stationsFiltered.forEach((station) => {
|
||||
const id = station.properties.stationIdentifier;
|
||||
if (output[id]) {
|
||||
console.log(`Duplicate station: ${state}-${id}`);
|
||||
return;
|
||||
}
|
||||
output[id] = {
|
||||
id,
|
||||
city: station.properties.name,
|
||||
state,
|
||||
lat: station.geometry.coordinates[1],
|
||||
lon: station.geometry.coordinates[0],
|
||||
};
|
||||
});
|
||||
next = stations?.pagination?.next;
|
||||
round += 1;
|
||||
// write the output
|
||||
writeFileSync('./datagenerators/output/stations-raw.json', JSON.stringify(output, null, 2));
|
||||
}
|
||||
while (next && stations.features.length > 0);
|
||||
completed += 1;
|
||||
console.log(`Complete: ${state} ${completed}/${states.length}`);
|
||||
return true;
|
||||
} catch {
|
||||
console.error(`Unable to get state: ${state}`);
|
||||
return false;
|
||||
}
|
||||
while (next && stations.features.length > 0);
|
||||
console.log(`Complete: ${state}`);
|
||||
return true;
|
||||
} catch {
|
||||
console.error(`Unable to get state: ${state}`);
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// run the post processor
|
||||
// data is passed through the file stations-raw.json
|
||||
const postProcessed = postProcessor();
|
||||
|
||||
// apply any overrides
|
||||
Object.entries(overrides).forEach(([id, values]) => {
|
||||
// check for existing value
|
||||
if (postProcessed[id]) {
|
||||
// apply the overrides
|
||||
postProcessed[id] = {
|
||||
...postProcessed[id],
|
||||
...values,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// write final file to disk
|
||||
writeFileSync('./datagenerators/output/stations.json', JSON.stringify(postProcessed, null, 2));
|
||||
|
||||
@@ -97,23 +97,27 @@ const copyCss = () => src(cssSources)
|
||||
const htmlSources = [
|
||||
'views/*.ejs',
|
||||
];
|
||||
const compressHtml = async () => {
|
||||
const packageJson = await readFile('package.json');
|
||||
const { version } = JSON.parse(packageJson);
|
||||
|
||||
return src(htmlSources)
|
||||
.pipe(ejs({
|
||||
production: version,
|
||||
serverAvailable: false,
|
||||
version,
|
||||
OVERRIDES,
|
||||
query: {},
|
||||
}))
|
||||
.pipe(rename({ extname: '.html' }))
|
||||
.pipe(htmlmin({ collapseWhitespace: true }))
|
||||
.pipe(dest('./dist'));
|
||||
const packageJson = await readFile('package.json');
|
||||
let { version } = JSON.parse(packageJson);
|
||||
const previewVersion = async () => {
|
||||
// generate a relatively unique timestamp for cache invalidation of the preview site
|
||||
const now = new Date();
|
||||
const msNow = now.getTime() % 1_000_000;
|
||||
version = msNow.toString();
|
||||
};
|
||||
|
||||
const compressHtml = async () => src(htmlSources)
|
||||
.pipe(ejs({
|
||||
production: version,
|
||||
serverAvailable: false,
|
||||
version,
|
||||
OVERRIDES,
|
||||
query: {},
|
||||
}))
|
||||
.pipe(rename({ extname: '.html' }))
|
||||
.pipe(htmlmin({ collapseWhitespace: true }))
|
||||
.pipe(dest('./dist'));
|
||||
|
||||
const otherFiles = [
|
||||
'server/robots.txt',
|
||||
'server/manifest.json',
|
||||
@@ -205,7 +209,7 @@ const buildDist = series(clean, parallel(buildJs, compressJsVendor, copyCss, com
|
||||
// upload_images could be in parallel with upload, but _images logs a lot and has little changes
|
||||
// by running upload last the majority of the changes will be at the bottom of the log for easy viewing
|
||||
const publishFrontend = series(buildDist, uploadImages, upload, invalidate);
|
||||
const stageFrontend = series(buildDist, uploadImagesPreview, uploadPreview, invalidatePreview);
|
||||
const stageFrontend = series(previewVersion, buildDist, uploadImagesPreview, uploadPreview, invalidatePreview);
|
||||
|
||||
export default publishFrontend;
|
||||
|
||||
|
||||
3653
package-lock.json
generated
3653
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ws4kp",
|
||||
"version": "6.1.2",
|
||||
"version": "6.1.9",
|
||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||
"main": "index.mjs",
|
||||
"type": "module",
|
||||
@@ -56,6 +56,7 @@
|
||||
"dotenv": "^17.0.1",
|
||||
"ejs": "^3.1.5",
|
||||
"express": "^5.1.0",
|
||||
"metar-taf-parser": "^9.0.0"
|
||||
"metar-taf-parser": "^9.0.0",
|
||||
"npm": "^11.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
server/images/backgrounds/7-wide.png
Normal file
BIN
server/images/backgrounds/7-wide.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
server/images/backgrounds/7.png
Normal file
BIN
server/images/backgrounds/7.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
@@ -145,6 +145,8 @@ const init = async () => {
|
||||
document.querySelector('#spanStationId').innerHTML = '';
|
||||
document.querySelector('#spanRadarId').innerHTML = '';
|
||||
document.querySelector('#spanZoneId').innerHTML = '';
|
||||
document.querySelector('#spanOfficeId').innerHTML = '';
|
||||
document.querySelector('#spanGridPoint').innerHTML = '';
|
||||
|
||||
localStorage.removeItem('play');
|
||||
postMessage('navButton', 'play');
|
||||
|
||||
@@ -97,6 +97,12 @@ const drawScreen = async () => {
|
||||
if (elem.parentElement.id === 'progress-html') return;
|
||||
thisScreen?.classes?.forEach((cls) => elem.classList.add(cls));
|
||||
});
|
||||
// special case for red background on hazard scroll
|
||||
const mainScrollBg = document.getElementById('scroll-bg');
|
||||
mainScrollBg.className = '';
|
||||
if (thisScreen?.classes?.includes('hazard')) {
|
||||
mainScrollBg.classList.add('hazard');
|
||||
}
|
||||
|
||||
if (typeof thisScreen === 'string') {
|
||||
// only a string
|
||||
|
||||
@@ -137,10 +137,6 @@ const parse = (fullForecast, forecastUrl) => {
|
||||
}
|
||||
// get the object to modify/populate
|
||||
const fDay = forecast[destIndex];
|
||||
// high temperature will always be last in the source array so it will overwrite the low values assigned below
|
||||
fDay.icon = getLargeIcon(period.icon);
|
||||
fDay.text = shortenExtendedForecastText(period.shortForecast);
|
||||
fDay.dayName = dates[destIndex];
|
||||
|
||||
// preload the icon
|
||||
preloadImg(fDay.icon);
|
||||
@@ -148,6 +144,9 @@ const parse = (fullForecast, forecastUrl) => {
|
||||
if (period.isDaytime) {
|
||||
// day time is the high temperature
|
||||
fDay.high = period.temperature;
|
||||
fDay.icon = getLargeIcon(period.icon);
|
||||
fDay.text = shortenExtendedForecastText(period.shortForecast);
|
||||
fDay.dayName = dates[destIndex];
|
||||
// Wait for the corresponding night period to increment
|
||||
} else {
|
||||
// low temperature
|
||||
|
||||
@@ -71,6 +71,7 @@ class Hazards extends WeatherDisplay {
|
||||
// get the forecast using centralized safe handling
|
||||
const url = new URL('https://api.weather.gov/alerts/active');
|
||||
url.searchParams.append('point', `${this.weatherParameters.latitude},${this.weatherParameters.longitude}`);
|
||||
url.searchParams.append('status', 'actual');
|
||||
const alerts = await safeJson(url, { retryCount: 3, stillWaiting: () => this.stillWaiting() });
|
||||
|
||||
if (!alerts) {
|
||||
@@ -103,7 +104,10 @@ class Hazards extends WeatherDisplay {
|
||||
// show alert indicator
|
||||
if (unViewed > 0) alert.classList.add('show');
|
||||
// draw the canvas to calculate the new timings and activate hazards in the slide deck again
|
||||
this.drawLongCanvas();
|
||||
// unless this has been disabled
|
||||
if (this.isEnabled) {
|
||||
this.drawLongCanvas();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Unexpected Active Alerts error: ${error.message}`);
|
||||
if (this.isEnabled) this.setStatus(STATUS.failed);
|
||||
@@ -115,7 +119,7 @@ class Hazards extends WeatherDisplay {
|
||||
this.getDataCallback();
|
||||
|
||||
if (!superResult) {
|
||||
this.setStatus(STATUS.loaded);
|
||||
// Don't override status - super.getData() already set it to STATUS.disabled
|
||||
return;
|
||||
}
|
||||
this.drawLongCanvas();
|
||||
|
||||
@@ -111,7 +111,7 @@ const getWeather = async (latLon, haveDataCallback) => {
|
||||
weatherParameters.stations = stations.features;
|
||||
|
||||
// update the main process for display purposes
|
||||
populateWeatherParameters(weatherParameters);
|
||||
populateWeatherParameters(weatherParameters, point.properties);
|
||||
|
||||
// reset the scroll
|
||||
postMessage({ type: 'current-weather-scroll', method: 'reload' });
|
||||
@@ -753,12 +753,14 @@ const registerProgress = (_progress) => {
|
||||
progress = _progress;
|
||||
};
|
||||
|
||||
const populateWeatherParameters = (params) => {
|
||||
const populateWeatherParameters = (params, point) => {
|
||||
document.querySelector('#spanCity').innerHTML = `${params.city}, `;
|
||||
document.querySelector('#spanState').innerHTML = params.state;
|
||||
document.querySelector('#spanStationId').innerHTML = params.stationId;
|
||||
document.querySelector('#spanRadarId').innerHTML = params.radarId;
|
||||
document.querySelector('#spanZoneId').innerHTML = params.zoneId;
|
||||
document.querySelector('#spanOfficeId').innerHTML = point.cwa;
|
||||
document.querySelector('#spanGridPoint').innerHTML = `${point.gridX},${point.gridY}`;
|
||||
};
|
||||
|
||||
const latLonReceived = (data, haveDataCallback) => {
|
||||
|
||||
@@ -3,13 +3,32 @@ import { parseMetar } from '../../vendor/auto/metar-taf-parser.mjs';
|
||||
// eslint-disable-next-line import/extensions
|
||||
import en from '../../vendor/auto/locale/en.js';
|
||||
|
||||
// metar-taf-parser requires regex lookbehind
|
||||
// this does not work in iOS < 16.4
|
||||
// this is a detection algorithm for iOS versions
|
||||
const isIos = /iP(ad|od|hone)/i.test(window.navigator.userAgent);
|
||||
let iosVersionOk = false;
|
||||
if (isIos) {
|
||||
// regex match the version string
|
||||
const iosVersionRaw = /OS (\d+)_(\d+)/.exec(window.navigator.userAgent);
|
||||
// check for match
|
||||
if (iosVersionRaw) {
|
||||
// break into parts
|
||||
const iosVersionMajor = parseInt(iosVersionRaw[1], 10);
|
||||
const iosVersionMinor = parseInt(iosVersionRaw[2], 10);
|
||||
if (iosVersionMajor > 16) iosVersionOk = true;
|
||||
if (iosVersionMajor === 16 && iosVersionMinor >= 4) iosVersionOk = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Augment observation data by parsing METAR when API fields are missing
|
||||
* @param {Object} observation - The observation object from the API
|
||||
* @returns {Object} - Augmented observation with parsed METAR data filled in
|
||||
*/
|
||||
const augmentObservationWithMetar = (observation) => {
|
||||
if (!observation?.rawMessage) {
|
||||
// check for a metar message and for unusable ios versions
|
||||
if (!observation?.rawMessage || (isIos && !iosVersionOk)) {
|
||||
return observation;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,5 +1,9 @@
|
||||
@use 'shared/_colors' as c;
|
||||
@use 'shared/_utils' as u;
|
||||
@use 'shared/_colors'as c;
|
||||
@use 'shared/_utils'as u;
|
||||
|
||||
#hazards-html.weather-display {
|
||||
background-image: url('../images/backgrounds/7.png');
|
||||
}
|
||||
|
||||
.weather-display .main.hazards {
|
||||
&.main {
|
||||
@@ -7,6 +11,7 @@
|
||||
height: 480px;
|
||||
background-color: rgb(112, 35, 35);
|
||||
|
||||
|
||||
.hazard-lines {
|
||||
min-height: 400px;
|
||||
padding-top: 10px;
|
||||
@@ -26,3 +31,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wide.hazards #container {
|
||||
background: url(../images/backgrounds/7-wide.png);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
@use 'shared/_utils' as u;
|
||||
@use 'shared/_colors' as c;
|
||||
@use 'shared/_utils'as u;
|
||||
@use 'shared/_colors'as c;
|
||||
|
||||
@font-face {
|
||||
font-family: "Star4000";
|
||||
@@ -161,6 +161,7 @@ body {
|
||||
#divTwcMain {
|
||||
width: 640px;
|
||||
height: 480px;
|
||||
position: relative;
|
||||
|
||||
.wide & {
|
||||
width: 854px;
|
||||
@@ -813,4 +814,4 @@ body.kiosk #loading .instructions {
|
||||
>*:not(#divTwc) {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
@use 'shared/_colors' as c;
|
||||
@use 'shared/_utils' as u;
|
||||
@use 'shared/_colors'as c;
|
||||
@use 'shared/_utils'as u;
|
||||
|
||||
.weather-display {
|
||||
width: 640px;
|
||||
@@ -116,9 +116,11 @@
|
||||
.scroll {
|
||||
@include u.text-shadow(3px, 1.5px);
|
||||
width: 640px;
|
||||
height: 70px;
|
||||
height: 77px;
|
||||
overflow: hidden;
|
||||
margin-top: 3px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
|
||||
&.hazard {
|
||||
background-color: rgb(112, 35, 35);
|
||||
@@ -159,3 +161,18 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#scroll-bg {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
height: 77px;
|
||||
width: 640px;
|
||||
|
||||
&.hazard {
|
||||
background-color: rgb(112, 35, 35);
|
||||
}
|
||||
}
|
||||
|
||||
.wide #scroll-bg {
|
||||
width: 854px;
|
||||
}
|
||||
@@ -134,6 +134,7 @@
|
||||
<%- include('partials/hazards.ejs') %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="scroll-bg"></div>
|
||||
</div>
|
||||
<div id="divTwcBottom">
|
||||
<div id="divTwcBottomLeft">
|
||||
@@ -191,6 +192,8 @@
|
||||
Station Id: <span id="spanStationId"></span><br />
|
||||
Radar Id: <span id="spanRadarId"></span><br />
|
||||
Zone Id: <span id="spanZoneId"></span><br />
|
||||
Office Id: <span id="spanOfficeId"></span><br />
|
||||
Grid X,Y: <span id="spanGridPoint"></span><br />
|
||||
Music: <span id="musicTrack">Not playing</span><br />
|
||||
Ws4kp Version: <span><%- version %></span>
|
||||
</div>
|
||||
@@ -198,4 +201,4 @@
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user