filter stations that do not have usable data

This commit is contained in:
Matt Walsh
2022-12-13 16:31:18 -06:00
parent fff5f0f7b6
commit 4c1481abaf
5 changed files with 15767 additions and 18822 deletions

View File

@@ -11,6 +11,9 @@ import {
celsiusToFahrenheit, kphToMph, pascalToInHg, metersToFeet, kilometersToMiles,
} from './utils/units.mjs';
// some stations prefixed do not provide all the necessary data
const skipStations = ['U', 'C', 'H', 'W', 'Y', 'T', 'S', 'M', 'O', 'L', 'A', 'F', 'B', 'N', 'V', 'R', 'D', 'E', 'I', 'G', 'J'];
class CurrentWeather extends WeatherDisplay {
constructor(navId, elemId) {
super(navId, elemId, 'Current Conditions', true);
@@ -23,14 +26,17 @@ class CurrentWeather extends WeatherDisplay {
const superResult = super.getData(_weatherParameters);
const weatherParameters = _weatherParameters ?? this.weatherParameters;
// filter for 4-letter observation stations, only those contain sky conditions and thus an icon
const filteredStations = weatherParameters.stations.filter((station) => station?.properties?.stationIdentifier?.length === 4 && !skipStations.includes(station.properties.stationIdentifier.slice(0, 1)));
// Load the observations
let observations; let
station;
// station number counter
let stationNum = 0;
while (!observations && stationNum < weatherParameters.stations.length) {
while (!observations && stationNum < filteredStations.length) {
// get the station
station = weatherParameters.stations[stationNum];
station = filteredStations[stationNum];
stationNum += 1;
try {
// station observations