filter stations that do not have usable data
This commit is contained in:
parent
fff5f0f7b6
commit
4c1481abaf
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,9 @@ const https = require('./https');
|
|||
const states = require('./stations-states');
|
||||
const chunk = require('./chunk');
|
||||
|
||||
// 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'];
|
||||
|
||||
// immediately invoked function so we can access async/await
|
||||
const start = async () => {
|
||||
// chunk the list of states
|
||||
|
@ -30,7 +33,9 @@ const start = async () => {
|
|||
const stationsRaw = await https(next);
|
||||
stations = JSON.parse(stationsRaw);
|
||||
// filter stations for 4 letter identifiers
|
||||
const stationsFiltered = stations.features.filter((station) => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
|
||||
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;
|
||||
|
@ -48,6 +53,7 @@ const start = async () => {
|
|||
});
|
||||
next = stations?.pagination?.next;
|
||||
// write the output
|
||||
// write the output
|
||||
fs.writeFileSync(path.join(__dirname, 'output/stations.json'), JSON.stringify(output, null, 2));
|
||||
}
|
||||
while (next && stations.features.length > 0);
|
||||
|
@ -59,9 +65,6 @@ const start = async () => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// write the output
|
||||
fs.writeFileSync(path.join(__dirname, 'output/stations.js'), JSON.stringify(output, null, 2));
|
||||
};
|
||||
|
||||
// immediately invoked function allows access to async
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -131,6 +131,8 @@ const autocompleteOnSelect = async (suggestion, elem) => {
|
|||
|
||||
const loc = data.locations[0];
|
||||
if (loc) {
|
||||
localStorage.removeItem('latLonFromGPS');
|
||||
document.getElementById('btnGetGps').classList.remove('active');
|
||||
doRedirectToGeometry(loc.feature.geometry);
|
||||
} else {
|
||||
console.error('An unexpected error occurred. Please try a different search string.');
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue