pre-load wfo point info for regional and travel cities

This commit is contained in:
Matt Walsh 2022-11-22 14:17:04 -06:00
parent 33570a8030
commit 2675ff8f16
14 changed files with 2945 additions and 18 deletions

18
.vscode/launch.json vendored
View file

@ -25,6 +25,24 @@
],
"type": "pwa-node"
},
{
"name": "Data:regionalcities",
"program": "${workspaceFolder}/datagenerators/regionalcities.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"name": "Data:travelcities",
"program": "${workspaceFolder}/datagenerators/travelcities.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"type": "node",
"request": "launch",

22
datagenerators/chunk.js Normal file
View file

@ -0,0 +1,22 @@
// turn a long array into a set of smaller chunks
const chunk = (data, chunkSize = 10) => {
const chunks = [];
let thisChunk = [];
data.forEach((d) => {
if (thisChunk.length >= chunkSize) {
chunks.push(thisChunk);
thisChunk = [];
}
thisChunk.push(d);
});
// final chunk
if (thisChunk.length > 0) chunks.push(thisChunk);
return chunks;
};
module.exports = chunk;

View file

@ -8,17 +8,17 @@ module.exports = (url) => new Promise((resolve, reject) => {
https.get(url, {
headers,
}, res => {
}, (res) => {
if (res.statusCode === 200) {
const buffers = [];
res.on('data', data => buffers.push(data));
res.on('data', (data) => buffers.push(data));
res.on('end', () => resolve(Buffer.concat(buffers).toString()));
} else {
console.log(res);
reject(new Error(`Unable to get: ${url}`));
}
}).on('error', e=> {
}).on('error', (e) => {
console.log(e);
reject(e);
});
});
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,242 @@
[
{
"Name": "Atlanta",
"Latitude": 33.749,
"Longitude": -84.388,
"point": {
"x": 50,
"y": 86,
"wfo": "FFC"
}
},
{
"Name": "Boston",
"Latitude": 42.3584,
"Longitude": -71.0598,
"point": {
"x": 71,
"y": 90,
"wfo": "BOX"
}
},
{
"Name": "Chicago",
"Latitude": 41.9796,
"Longitude": -87.9045,
"point": {
"x": 65,
"y": 76,
"wfo": "LOT"
}
},
{
"Name": "Cleveland",
"Latitude": 41.4995,
"Longitude": -81.6954,
"point": {
"x": 82,
"y": 64,
"wfo": "CLE"
}
},
{
"Name": "Dallas",
"Latitude": 32.8959,
"Longitude": -97.0372,
"point": {
"x": 79,
"y": 108,
"wfo": "FWD"
}
},
{
"Name": "Denver",
"Latitude": 39.7391,
"Longitude": -104.9847,
"point": {
"x": 62,
"y": 60,
"wfo": "BOU"
}
},
{
"Name": "Detroit",
"Latitude": 42.3314,
"Longitude": -83.0457,
"point": {
"x": 65,
"y": 33,
"wfo": "DTX"
}
},
{
"Name": "Hartford",
"Latitude": 41.7637,
"Longitude": -72.6851,
"point": {
"x": 21,
"y": 54,
"wfo": "BOX"
}
},
{
"Name": "Houston",
"Latitude": 29.7633,
"Longitude": -95.3633,
"point": {
"x": 65,
"y": 97,
"wfo": "HGX"
}
},
{
"Name": "Indianapolis",
"Latitude": 39.7684,
"Longitude": -86.158,
"point": {
"x": 57,
"y": 68,
"wfo": "IND"
}
},
{
"Name": "Los Angeles",
"Latitude": 34.0522,
"Longitude": -118.2437,
"point": {
"x": 154,
"y": 44,
"wfo": "LOX"
}
},
{
"Name": "Miami",
"Latitude": 25.7743,
"Longitude": -80.1937,
"point": {
"x": 109,
"y": 50,
"wfo": "MFL"
}
},
{
"Name": "Minneapolis",
"Latitude": 44.98,
"Longitude": -93.2638,
"point": {
"x": 107,
"y": 71,
"wfo": "MPX"
}
},
{
"Name": "New York",
"Latitude": 40.7142,
"Longitude": -74.0059,
"point": {
"x": 32,
"y": 34,
"wfo": "OKX"
}
},
{
"Name": "Norfolk",
"Latitude": 36.8468,
"Longitude": -76.2852,
"point": {
"x": 89,
"y": 51,
"wfo": "AKQ"
}
},
{
"Name": "Orlando",
"Latitude": 28.5383,
"Longitude": -81.3792,
"point": {
"x": 26,
"y": 68,
"wfo": "MLB"
}
},
{
"Name": "Philadelphia",
"Latitude": 39.9523,
"Longitude": -75.1638,
"point": {
"x": 49,
"y": 75,
"wfo": "PHI"
}
},
{
"Name": "Pittsburgh",
"Latitude": 40.4406,
"Longitude": -79.9959,
"point": {
"x": 77,
"y": 65,
"wfo": "PBZ"
}
},
{
"Name": "St. Louis",
"Latitude": 38.6273,
"Longitude": -90.1979,
"point": {
"x": 94,
"y": 73,
"wfo": "LSX"
}
},
{
"Name": "San Francisco",
"Latitude": 37.7749,
"Longitude": -122.4194,
"point": {
"x": 85,
"y": 105,
"wfo": "MTR"
}
},
{
"Name": "Seattle",
"Latitude": 47.6062,
"Longitude": -122.3321,
"point": {
"x": 124,
"y": 67,
"wfo": "SEW"
}
},
{
"Name": "Syracuse",
"Latitude": 43.0481,
"Longitude": -76.1474,
"point": {
"x": 51,
"y": 98,
"wfo": "BGM"
}
},
{
"Name": "Tampa",
"Latitude": 27.9475,
"Longitude": -82.4584,
"point": {
"x": 70,
"y": 96,
"wfo": "TBW"
}
},
{
"Name": "Washington DC",
"Latitude": 38.8951,
"Longitude": -77.0364,
"point": {
"x": 97,
"y": 71,
"wfo": "LWX"
}
}
]

View file

@ -0,0 +1,582 @@
[
{
"city": "Atlanta",
"lat": 33.749,
"lon": -84.388
},
{
"city": "Boston",
"lat": 42.3584,
"lon": -71.0598
},
{
"city": "Chicago",
"lat": 41.9796,
"lon": -87.9045
},
{
"city": "Cleveland",
"lat": 41.4995,
"lon": -81.6954
},
{
"city": "Dallas",
"lat": 32.8959,
"lon": -97.0372
},
{
"city": "Denver",
"lat": 39.7391,
"lon": -104.9847
},
{
"city": "Detroit",
"lat": 42.3314,
"lon": -83.0457
},
{
"city": "Hartford",
"lat": 41.7637,
"lon": -72.6851
},
{
"city": "Houston",
"lat": 29.7633,
"lon": -95.3633
},
{
"city": "Indianapolis",
"lat": 39.7684,
"lon": -86.158
},
{
"city": "Los Angeles",
"lat": 34.0522,
"lon": -118.2437
},
{
"city": "Miami",
"lat": 25.7743,
"lon": -80.1937
},
{
"city": "Minneapolis",
"lat": 44.98,
"lon": -93.2638
},
{
"city": "New York",
"lat": 40.78,
"lon": -73.88
},
{
"city": "Norfolk",
"lat": 36.8468,
"lon": -76.2852
},
{
"city": "Orlando",
"lat": 28.5383,
"lon": -81.3792
},
{
"city": "Philadelphia",
"lat": 39.9523,
"lon": -75.1638
},
{
"city": "Pittsburgh",
"lat": 40.4406,
"lon": -79.9959
},
{
"city": "St. Louis",
"lat": 38.6273,
"lon": -90.1979
},
{
"city": "San Francisco",
"lat": 37.6148,
"lon": -122.3918
},
{
"city": "Seattle",
"lat": 47.6062,
"lon": -122.3321
},
{
"city": "Syracuse",
"lat": 43.0481,
"lon": -76.1474
},
{
"city": "Tampa",
"lat": 27.9756,
"lon": -82.5329
},
{
"city": "Washington DC",
"lat": 38.8951,
"lon": -77.0364
},
{
"city": "Albany",
"lat": 42.6526,
"lon": -73.7562
},
{
"city": "Albuquerque",
"lat": 35.0845,
"lon": -106.6511
},
{
"city": "Amarillo",
"lat": 35.222,
"lon": -101.8313
},
{
"city": "Anchorage",
"lat": 61.2181,
"lon": -149.9003
},
{
"city": "Austin",
"lat": 30.2671,
"lon": -97.7431
},
{
"city": "Baker",
"lat": 44.7502,
"lon": -117.6677
},
{
"city": "Baltimore",
"lat": 39.2904,
"lon": -76.6122
},
{
"city": "Bangor",
"lat": 44.8012,
"lon": -68.7778
},
{
"city": "Birmingham",
"lat": 33.5207,
"lon": -86.8025
},
{
"city": "Bismarck",
"lat": 46.8083,
"lon": -100.7837
},
{
"city": "Boise",
"lat": 43.6135,
"lon": -116.2034
},
{
"city": "Buffalo",
"lat": 42.8864,
"lon": -78.8784
},
{
"city": "Carlsbad",
"lat": 32.4207,
"lon": -104.2288
},
{
"city": "Charleston",
"lat": 32.7766,
"lon": -79.9309
},
{
"city": "Charleston",
"lat": 38.3498,
"lon": -81.6326
},
{
"city": "Charlotte",
"lat": 35.2271,
"lon": -80.8431
},
{
"city": "Cheyenne",
"lat": 41.14,
"lon": -104.8202
},
{
"city": "Cincinnati",
"lat": 39.162,
"lon": -84.4569
},
{
"city": "Columbia",
"lat": 34.0007,
"lon": -81.0348
},
{
"city": "Columbus",
"lat": 39.9612,
"lon": -82.9988
},
{
"city": "Des Moines",
"lat": 41.6005,
"lon": -93.6091
},
{
"city": "Dubuque",
"lat": 42.5006,
"lon": -90.6646
},
{
"city": "Duluth",
"lat": 46.7833,
"lon": -92.1066
},
{
"city": "Eastport",
"lat": 44.9062,
"lon": -66.99
},
{
"city": "El Centro",
"lat": 32.792,
"lon": -115.563
},
{
"city": "El Paso",
"lat": 31.7587,
"lon": -106.4869
},
{
"city": "Eugene",
"lat": 44.0521,
"lon": -123.0867
},
{
"city": "Fargo",
"lat": 46.8772,
"lon": -96.7898
},
{
"city": "Flagstaff",
"lat": 35.1981,
"lon": -111.6513
},
{
"city": "Fresno",
"lat": 36.7477,
"lon": -119.7724
},
{
"city": "Grand Junction",
"lat": 39.0639,
"lon": -108.5506
},
{
"city": "Grand Rapids",
"lat": 42.9634,
"lon": -85.6681
},
{
"city": "Havre",
"lat": 48.55,
"lon": -109.6841
},
{
"city": "Helena",
"lat": 46.5927,
"lon": -112.0361
},
{
"city": "Honolulu",
"lat": 21.3069,
"lon": -157.8583
},
{
"city": "Hot Springs",
"lat": 34.5037,
"lon": -93.0552
},
{
"city": "Idaho Falls",
"lat": 43.4666,
"lon": -112.0341
},
{
"city": "Jackson",
"lat": 32.2988,
"lon": -90.1848
},
{
"city": "Jacksonville",
"lat": 30.3322,
"lon": -81.6556
},
{
"city": "Juneau",
"lat": 58.3019,
"lon": -134.4197
},
{
"city": "Kansas City",
"lat": 39.1142,
"lon": -94.6275
},
{
"city": "Key West",
"lat": 24.5557,
"lon": -81.7826
},
{
"city": "Klamath Falls",
"lat": 42.2249,
"lon": -121.7817
},
{
"city": "Knoxville",
"lat": 35.9606,
"lon": -83.9207
},
{
"city": "Las Vegas",
"lat": 36.175,
"lon": -115.1372
},
{
"city": "Lewiston",
"lat": 46.4165,
"lon": -117.0177
},
{
"city": "Lincoln",
"lat": 40.8,
"lon": -96.667
},
{
"city": "Long Beach",
"lat": 33.767,
"lon": -118.1892
},
{
"city": "Louisville",
"lat": 38.2542,
"lon": -85.7594
},
{
"city": "Manchester",
"lat": 42.9956,
"lon": -71.4548
},
{
"city": "Memphis",
"lat": 35.1495,
"lon": -90.049
},
{
"city": "Milwaukee",
"lat": 43.0389,
"lon": -87.9065
},
{
"city": "Mobile",
"lat": 30.6944,
"lon": -88.043
},
{
"city": "Montgomery",
"lat": 32.3668,
"lon": -86.3
},
{
"city": "Montpelier",
"lat": 44.2601,
"lon": -72.5754
},
{
"city": "Nashville",
"lat": 36.1659,
"lon": -86.7844
},
{
"city": "Newark",
"lat": 40.7357,
"lon": -74.1724
},
{
"city": "New Haven",
"lat": 41.3081,
"lon": -72.9282
},
{
"city": "New Orleans",
"lat": 29.9546,
"lon": -90.0751
},
{
"city": "Nome",
"lat": 64.5011,
"lon": -165.4064
},
{
"city": "Oklahoma City",
"lat": 35.4676,
"lon": -97.5164
},
{
"city": "Omaha",
"lat": 41.2586,
"lon": -95.9378
},
{
"city": "Phoenix",
"lat": 33.4484,
"lon": -112.074
},
{
"city": "Pierre",
"lat": 44.3683,
"lon": -100.351
},
{
"city": "Portland",
"lat": 43.6615,
"lon": -70.2553
},
{
"city": "Portland",
"lat": 45.5234,
"lon": -122.6762
},
{
"city": "Providence",
"lat": 41.824,
"lon": -71.4128
},
{
"city": "Raleigh",
"lat": 35.7721,
"lon": -78.6386
},
{
"city": "Reno",
"lat": 39.4986,
"lon": -119.7681
},
{
"city": "Richfield",
"lat": 38.7725,
"lon": -112.0841
},
{
"city": "Richmond",
"lat": 37.5538,
"lon": -77.4603
},
{
"city": "Roanoke",
"lat": 37.271,
"lon": -79.9414
},
{
"city": "Sacramento",
"lat": 38.5816,
"lon": -121.4944
},
{
"city": "Salt Lake City",
"lat": 40.7608,
"lon": -111.891
},
{
"city": "San Antonio",
"lat": 29.4241,
"lon": -98.4936
},
{
"city": "San Diego",
"lat": 32.7153,
"lon": -117.1573
},
{
"city": "San Jose",
"lat": 37.3394,
"lon": -121.895
},
{
"city": "Santa Fe",
"lat": 35.687,
"lon": -105.9378
},
{
"city": "Savannah",
"lat": 32.0835,
"lon": -81.0998
},
{
"city": "Shreveport",
"lat": 32.5251,
"lon": -93.7502
},
{
"city": "Sioux Falls",
"lat": 43.55,
"lon": -96.7003
},
{
"city": "Sitka",
"lat": 57.0531,
"lon": -135.33
},
{
"city": "Spokane",
"lat": 47.6597,
"lon": -117.4291
},
{
"city": "Springfield",
"lat": 39.8017,
"lon": -89.6437
},
{
"city": "Springfield",
"lat": 42.1015,
"lon": -72.5898
},
{
"city": "Springfield",
"lat": 37.2153,
"lon": -93.2982
},
{
"city": "Toledo",
"lat": 41.6639,
"lon": -83.5552
},
{
"city": "Tulsa",
"lat": 36.154,
"lon": -95.9928
},
{
"city": "Virginia Beach",
"lat": 36.8529,
"lon": -75.978
},
{
"city": "Wichita",
"lat": 37.6922,
"lon": -97.3375
},
{
"city": "Wilmington",
"lat": 34.2257,
"lon": -77.9447
},
{
"city": "Tuscan",
"lat": 32.2216,
"lon": -110.9698
}
]

View file

@ -0,0 +1,41 @@
// look up points for each regional city
const fs = require('fs/promises');
const chunk = require('./chunk');
const https = require('./https');
(async () => {
// source data
const regionalCities = JSON.parse(await fs.readFile('./datagenerators/regionalcities-raw.json'));
const result = [];
const dataChunks = chunk(regionalCities, 5);
// for loop intentional for use of await
// this keeps the api from getting overwhelmed
for (let i = 0; i < dataChunks.length; i += 1) {
const cityChunk = dataChunks[i];
// eslint-disable-next-line no-await-in-loop
const chunkResult = await Promise.all(cityChunk.map(async (city) => {
try {
const data = await https(`https://api.weather.gov/points/${city.lat},${city.lon}`);
const point = JSON.parse(data);
return {
...city,
point: {
x: point.properties.gridX,
y: point.properties.gridY,
wfo: point.properties.gridId,
},
};
} catch (e) {
console.error(e);
return city;
}
}));
result.push(...chunkResult);
}
await fs.writeFile('./datagenerators/output/regionalcities.json', JSON.stringify(result, null, ' '));
})();

View file

@ -1,9 +1,9 @@
// list all stations in a single file
// only find stations with 4 letter codes
const https = require('./https');
const fs = require('fs');
const path = require('path');
const https = require('./https');
// immediately invoked function so we can access async/await
const start = async () => {
@ -11,7 +11,7 @@ const start = async () => {
const states = ['AK', 'NC', 'VA', 'TX', 'GA', 'PR'];
// const states = require('./stations-states.js');
let output = {};
const output = {};
// loop through states
await Promise.all(states.map(async (state) => {
try {
@ -19,9 +19,9 @@ const start = async () => {
const stationsRaw = await https(`https://api.weather.gov/stations?state=${state}`);
const stationsAll = JSON.parse(stationsRaw).features;
// filter stations for 4 letter identifiers
const stations = stationsAll.filter(station => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
const stations = stationsAll.filter((station) => station.properties.stationIdentifier.match(/^[A-Z]{4}$/));
// add each resulting station to the output
stations.forEach(station => {
stations.forEach((station) => {
const id = station.properties.stationIdentifier;
if (output[id]) {
console.log(`Duplicate station: ${state}-${id}`);
@ -30,7 +30,7 @@ const start = async () => {
output[id] = {
id,
city: station.properties.name,
state: state,
state,
lat: station.geometry.coordinates[1],
lon: station.geometry.coordinates[0],
};
@ -44,11 +44,9 @@ 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
(async () => {
await start();
})();

View file

@ -0,0 +1,122 @@
[
{
"Name": "Atlanta",
"Latitude": 33.749,
"Longitude": -84.388
},
{
"Name": "Boston",
"Latitude": 42.3584,
"Longitude": -71.0598
},
{
"Name": "Chicago",
"Latitude": 41.9796,
"Longitude": -87.9045
},
{
"Name": "Cleveland",
"Latitude": 41.4995,
"Longitude": -81.6954
},
{
"Name": "Dallas",
"Latitude": 32.8959,
"Longitude": -97.0372
},
{
"Name": "Denver",
"Latitude": 39.7391,
"Longitude": -104.9847
},
{
"Name": "Detroit",
"Latitude": 42.3314,
"Longitude": -83.0457
},
{
"Name": "Hartford",
"Latitude": 41.7637,
"Longitude": -72.6851
},
{
"Name": "Houston",
"Latitude": 29.7633,
"Longitude": -95.3633
},
{
"Name": "Indianapolis",
"Latitude": 39.7684,
"Longitude": -86.158
},
{
"Name": "Los Angeles",
"Latitude": 34.0522,
"Longitude": -118.2437
},
{
"Name": "Miami",
"Latitude": 25.7743,
"Longitude": -80.1937
},
{
"Name": "Minneapolis",
"Latitude": 44.98,
"Longitude": -93.2638
},
{
"Name": "New York",
"Latitude": 40.7142,
"Longitude": -74.0059
},
{
"Name": "Norfolk",
"Latitude": 36.8468,
"Longitude": -76.2852
},
{
"Name": "Orlando",
"Latitude": 28.5383,
"Longitude": -81.3792
},
{
"Name": "Philadelphia",
"Latitude": 39.9523,
"Longitude": -75.1638
},
{
"Name": "Pittsburgh",
"Latitude": 40.4406,
"Longitude": -79.9959
},
{
"Name": "St. Louis",
"Latitude": 38.6273,
"Longitude": -90.1979
},
{
"Name": "San Francisco",
"Latitude": 37.7749,
"Longitude": -122.4194
},
{
"Name": "Seattle",
"Latitude": 47.6062,
"Longitude": -122.3321
},
{
"Name": "Syracuse",
"Latitude": 43.0481,
"Longitude": -76.1474
},
{
"Name": "Tampa",
"Latitude": 27.9475,
"Longitude": -82.4584
},
{
"Name": "Washington DC",
"Latitude": 38.8951,
"Longitude": -77.0364
}
]

View file

@ -0,0 +1,41 @@
// look up points for each travel city
const fs = require('fs/promises');
const chunk = require('./chunk');
const https = require('./https');
(async () => {
// source data
const travelCities = JSON.parse(await fs.readFile('./datagenerators/travelcities-raw.json'));
const result = [];
const dataChunks = chunk(travelCities, 5);
// for loop intentional for use of await
// this keeps the api from getting overwhelmed
for (let i = 0; i < dataChunks.length; i += 1) {
const cityChunk = dataChunks[i];
// eslint-disable-next-line no-await-in-loop
const chunkResult = await Promise.all(cityChunk.map(async (city) => {
try {
const data = await https(`https://api.weather.gov/points/${city.Latitude},${city.Longitude}`);
const point = JSON.parse(data);
return {
...city,
point: {
x: point.properties.gridX,
y: point.properties.gridY,
wfo: point.properties.gridId,
},
};
} catch (e) {
console.error(e);
return city;
}
}));
result.push(...chunkResult);
}
await fs.writeFile('./datagenerators/output/travelcities.json', JSON.stringify(result, null, ' '));
})();

File diff suppressed because it is too large Load diff

View file

@ -4,120 +4,240 @@ const TravelCities = [
Name: 'Atlanta',
Latitude: 33.749,
Longitude: -84.388,
point: {
x: 50,
y: 86,
wfo: 'FFC',
},
},
{
Name: 'Boston',
Latitude: 42.3584,
Longitude: -71.0598,
point: {
x: 71,
y: 90,
wfo: 'BOX',
},
},
{
Name: 'Chicago',
Latitude: 41.9796,
Longitude: -87.9045,
point: {
x: 65,
y: 76,
wfo: 'LOT',
},
},
{
Name: 'Cleveland',
Latitude: 41.4995,
Longitude: -81.6954,
point: {
x: 82,
y: 64,
wfo: 'CLE',
},
},
{
Name: 'Dallas',
Latitude: 32.8959,
Longitude: -97.0372,
point: {
x: 79,
y: 108,
wfo: 'FWD',
},
},
{
Name: 'Denver',
Latitude: 39.7391,
Longitude: -104.9847,
point: {
x: 62,
y: 60,
wfo: 'BOU',
},
},
{
Name: 'Detroit',
Latitude: 42.3314,
Longitude: -83.0457,
point: {
x: 65,
y: 33,
wfo: 'DTX',
},
},
{
Name: 'Hartford',
Latitude: 41.7637,
Longitude: -72.6851,
point: {
x: 21,
y: 54,
wfo: 'BOX',
},
},
{
Name: 'Houston',
Latitude: 29.7633,
Longitude: -95.3633,
point: {
x: 65,
y: 97,
wfo: 'HGX',
},
},
{
Name: 'Indianapolis',
Latitude: 39.7684,
Longitude: -86.158,
point: {
x: 57,
y: 68,
wfo: 'IND',
},
},
{
Name: 'Los Angeles',
Latitude: 34.0522,
Longitude: -118.2437,
point: {
x: 154,
y: 44,
wfo: 'LOX',
},
},
{
Name: 'Miami',
Latitude: 25.7743,
Longitude: -80.1937,
point: {
x: 109,
y: 50,
wfo: 'MFL',
},
},
{
Name: 'Minneapolis',
Latitude: 44.98,
Longitude: -93.2638,
point: {
x: 107,
y: 71,
wfo: 'MPX',
},
},
{
Name: 'New York',
Latitude: 40.7142,
Longitude: -74.0059,
point: {
x: 32,
y: 34,
wfo: 'OKX',
},
},
{
Name: 'Norfolk',
Latitude: 36.8468,
Longitude: -76.2852,
point: {
x: 89,
y: 51,
wfo: 'AKQ',
},
},
{
Name: 'Orlando',
Latitude: 28.5383,
Longitude: -81.3792,
point: {
x: 26,
y: 68,
wfo: 'MLB',
},
},
{
Name: 'Philadelphia',
Latitude: 39.9523,
Longitude: -75.1638,
point: {
x: 49,
y: 75,
wfo: 'PHI',
},
},
{
Name: 'Pittsburgh',
Latitude: 40.4406,
Longitude: -79.9959,
point: {
x: 77,
y: 65,
wfo: 'PBZ',
},
},
{
Name: 'St. Louis',
Latitude: 38.6273,
Longitude: -90.1979,
point: {
x: 94,
y: 73,
wfo: 'LSX',
},
},
{
Name: 'San Francisco',
Latitude: 37.7749,
Longitude: -122.4194,
point: {
x: 85,
y: 105,
wfo: 'MTR',
},
},
{
Name: 'Seattle',
Latitude: 47.6062,
Longitude: -122.3321,
point: {
x: 124,
y: 67,
wfo: 'SEW',
},
},
{
Name: 'Syracuse',
Latitude: 43.0481,
Longitude: -76.1474,
point: {
x: 51,
y: 98,
wfo: 'BGM',
},
},
{
Name: 'Tampa',
Latitude: 27.9475,
Longitude: -82.4584,
point: {
x: 70,
y: 96,
wfo: 'TBW',
},
},
{
Name: 'Washington DC',
Latitude: 38.8951,
Longitude: -77.0364,
point: {
x: 97,
y: 71,
wfo: 'LWX',
},
},
];

View file

@ -65,13 +65,12 @@ class RegionalForecast extends WeatherDisplay {
// get regional forecasts and observations (the two are intertwined due to the design of api.weather.gov)
const regionalDataAll = await Promise.all(regionalCities.map(async (city) => {
try {
// get the point first, then break down into forecast and observations
const point = await utils.weather.getPoint(city.lat, city.lon);
if (!city.point) throw new Error('No pre-loaded point');
// start off the observation task
const observationPromise = RegionalForecast.getRegionalObservation(point, city);
const observationPromise = RegionalForecast.getRegionalObservation(city.point, city);
const forecast = await utils.fetch.json(point.properties.forecast);
const forecast = await utils.fetch.json(`https://api.weather.gov/gridpoints/${city.point.wfo}/${city.point.x},${city.point.y}/forecast`);
// get XY on map for city
const cityXY = RegionalForecast.getXYForCity(city, minMaxLatLon.maxLat, minMaxLatLon.minLon, weatherParameters.state);
@ -142,7 +141,7 @@ class RegionalForecast extends WeatherDisplay {
static async getRegionalObservation(point, city) {
try {
// get stations
const stations = await utils.fetch.json(point.properties.observationStations);
const stations = await utils.fetch.json(`https://api.weather.gov/gridpoints/${city.point.wfo}/${city.point.x},${city.point.y}/stations`);
// get the first station
const station = stations.features[0].id;

View file

@ -29,8 +29,8 @@ class TravelForecast extends WeatherDisplay {
const forecastPromises = TravelCities.map(async (city) => {
try {
// get point then forecast
const point = await utils.weather.getPoint(city.Latitude, city.Longitude);
const forecast = await utils.fetch.json(point.properties.forecast);
if (!city.point) throw new Error('No pre-loaded point');
const forecast = await utils.fetch.json(`https://api.weather.gov/gridpoints/${city.point.wfo}/${city.point.x},${city.point.y}/forecast`);
// determine today or tomorrow (shift periods by 1 if tomorrow)
const todayShift = forecast.properties.periods[0].isDaytime ? 0 : 1;
// return a pared-down forecast