From c28608bb39e27c681d927cfa11ceed88d6a88e1c Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Tue, 22 Nov 2022 14:17:04 -0600 Subject: [PATCH] pre-load wfo point info for regional and travel cities --- .vscode/launch.json | 18 + datagenerators/chunk.js | 22 + datagenerators/https.js | 8 +- datagenerators/output/regionalcities.json | 1162 ++++++++++++++++++++ datagenerators/output/travelcities.json | 242 ++++ datagenerators/regionalcities-raw.json | 582 ++++++++++ datagenerators/regionalcities.js | 41 + datagenerators/travelcities-raw.json | 122 ++ datagenerators/travelcities.js | 41 + server/scripts/data/regionalcities.js | 580 ++++++++++ server/scripts/data/travelcities.js | 120 ++ server/scripts/modules/regionalforecast.js | 9 +- server/scripts/modules/travelforecast.js | 4 +- 13 files changed, 2940 insertions(+), 11 deletions(-) create mode 100644 datagenerators/chunk.js create mode 100644 datagenerators/output/regionalcities.json create mode 100644 datagenerators/output/travelcities.json create mode 100644 datagenerators/regionalcities-raw.json create mode 100644 datagenerators/regionalcities.js create mode 100644 datagenerators/travelcities-raw.json create mode 100644 datagenerators/travelcities.js diff --git a/.vscode/launch.json b/.vscode/launch.json index acd1201..a314d6b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,6 +25,24 @@ ], "type": "pwa-node" }, + { + "name": "Data:regionalcities", + "program": "${workspaceFolder}/datagenerators/regionalcities.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, + { + "name": "Data:travelcities", + "program": "${workspaceFolder}/datagenerators/travelcities.js", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, { "type": "node", "request": "launch", diff --git a/datagenerators/chunk.js b/datagenerators/chunk.js new file mode 100644 index 0000000..2fe6478 --- /dev/null +++ b/datagenerators/chunk.js @@ -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; diff --git a/datagenerators/https.js b/datagenerators/https.js index f46fbf8..87a9a81 100644 --- a/datagenerators/https.js +++ b/datagenerators/https.js @@ -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); }); -}); \ No newline at end of file +}); diff --git a/datagenerators/output/regionalcities.json b/datagenerators/output/regionalcities.json new file mode 100644 index 0000000..93717b1 --- /dev/null +++ b/datagenerators/output/regionalcities.json @@ -0,0 +1,1162 @@ +[ + { + "city": "Atlanta", + "lat": 33.749, + "lon": -84.388, + "point": { + "x": 50, + "y": 86, + "wfo": "FFC" + } + }, + { + "city": "Boston", + "lat": 42.3584, + "lon": -71.0598, + "point": { + "x": 71, + "y": 90, + "wfo": "BOX" + } + }, + { + "city": "Chicago", + "lat": 41.9796, + "lon": -87.9045, + "point": { + "x": 65, + "y": 76, + "wfo": "LOT" + } + }, + { + "city": "Cleveland", + "lat": 41.4995, + "lon": -81.6954, + "point": { + "x": 82, + "y": 64, + "wfo": "CLE" + } + }, + { + "city": "Dallas", + "lat": 32.8959, + "lon": -97.0372, + "point": { + "x": 79, + "y": 108, + "wfo": "FWD" + } + }, + { + "city": "Denver", + "lat": 39.7391, + "lon": -104.9847, + "point": { + "x": 62, + "y": 60, + "wfo": "BOU" + } + }, + { + "city": "Detroit", + "lat": 42.3314, + "lon": -83.0457, + "point": { + "x": 65, + "y": 33, + "wfo": "DTX" + } + }, + { + "city": "Hartford", + "lat": 41.7637, + "lon": -72.6851, + "point": { + "x": 21, + "y": 54, + "wfo": "BOX" + } + }, + { + "city": "Houston", + "lat": 29.7633, + "lon": -95.3633, + "point": { + "x": 65, + "y": 97, + "wfo": "HGX" + } + }, + { + "city": "Indianapolis", + "lat": 39.7684, + "lon": -86.158, + "point": { + "x": 57, + "y": 68, + "wfo": "IND" + } + }, + { + "city": "Los Angeles", + "lat": 34.0522, + "lon": -118.2437, + "point": { + "x": 154, + "y": 44, + "wfo": "LOX" + } + }, + { + "city": "Miami", + "lat": 25.7743, + "lon": -80.1937, + "point": { + "x": 109, + "y": 50, + "wfo": "MFL" + } + }, + { + "city": "Minneapolis", + "lat": 44.98, + "lon": -93.2638, + "point": { + "x": 107, + "y": 71, + "wfo": "MPX" + } + }, + { + "city": "New York", + "lat": 40.78, + "lon": -73.88, + "point": { + "x": 36, + "y": 38, + "wfo": "OKX" + } + }, + { + "city": "Norfolk", + "lat": 36.8468, + "lon": -76.2852, + "point": { + "x": 89, + "y": 51, + "wfo": "AKQ" + } + }, + { + "city": "Orlando", + "lat": 28.5383, + "lon": -81.3792, + "point": { + "x": 26, + "y": 68, + "wfo": "MLB" + } + }, + { + "city": "Philadelphia", + "lat": 39.9523, + "lon": -75.1638, + "point": { + "x": 49, + "y": 75, + "wfo": "PHI" + } + }, + { + "city": "Pittsburgh", + "lat": 40.4406, + "lon": -79.9959, + "point": { + "x": 77, + "y": 65, + "wfo": "PBZ" + } + }, + { + "city": "St. Louis", + "lat": 38.6273, + "lon": -90.1979, + "point": { + "x": 94, + "y": 73, + "wfo": "LSX" + } + }, + { + "city": "San Francisco", + "lat": 37.6148, + "lon": -122.3918, + "point": { + "x": 84, + "y": 98, + "wfo": "MTR" + } + }, + { + "city": "Seattle", + "lat": 47.6062, + "lon": -122.3321, + "point": { + "x": 124, + "y": 67, + "wfo": "SEW" + } + }, + { + "city": "Syracuse", + "lat": 43.0481, + "lon": -76.1474, + "point": { + "x": 51, + "y": 98, + "wfo": "BGM" + } + }, + { + "city": "Tampa", + "lat": 27.9756, + "lon": -82.5329, + "point": { + "x": 67, + "y": 97, + "wfo": "TBW" + } + }, + { + "city": "Washington DC", + "lat": 38.8951, + "lon": -77.0364, + "point": { + "x": 97, + "y": 71, + "wfo": "LWX" + } + }, + { + "city": "Albany", + "lat": 42.6526, + "lon": -73.7562, + "point": { + "x": 58, + "y": 58, + "wfo": "ALY" + } + }, + { + "city": "Albuquerque", + "lat": 35.0845, + "lon": -106.6511, + "point": { + "x": 97, + "y": 118, + "wfo": "ABQ" + } + }, + { + "city": "Amarillo", + "lat": 35.222, + "lon": -101.8313, + "point": { + "x": 47, + "y": 25, + "wfo": "AMA" + } + }, + { + "city": "Anchorage", + "lat": 61.2181, + "lon": -149.9003, + "point": { + "x": 125, + "y": 236, + "wfo": "AER" + } + }, + { + "city": "Austin", + "lat": 30.2671, + "lon": -97.7431, + "point": { + "x": 155, + "y": 90, + "wfo": "EWX" + } + }, + { + "city": "Baker", + "lat": 44.7502, + "lon": -117.6677, + "point": { + "x": 93, + "y": 145, + "wfo": "BOI" + } + }, + { + "city": "Baltimore", + "lat": 39.2904, + "lon": -76.6122, + "point": { + "x": 109, + "y": 91, + "wfo": "LWX" + } + }, + { + "city": "Bangor", + "lat": 44.8012, + "lon": -68.7778, + "point": { + "x": 72, + "y": 62, + "wfo": "CAR" + } + }, + { + "city": "Birmingham", + "lat": 33.5207, + "lon": -86.8025, + "point": { + "x": 58, + "y": 83, + "wfo": "BMX" + } + }, + { + "city": "Bismarck", + "lat": 46.8083, + "lon": -100.7837, + "point": { + "x": 109, + "y": 46, + "wfo": "BIS" + } + }, + { + "city": "Boise", + "lat": 43.6135, + "lon": -116.2034, + "point": { + "x": 132, + "y": 85, + "wfo": "BOI" + } + }, + { + "city": "Buffalo", + "lat": 42.8864, + "lon": -78.8784, + "point": { + "x": 35, + "y": 46, + "wfo": "BUF" + } + }, + { + "city": "Carlsbad", + "lat": 32.4207, + "lon": -104.2288, + "point": { + "x": 44, + "y": 156, + "wfo": "MAF" + } + }, + { + "city": "Charleston", + "lat": 32.7766, + "lon": -79.9309, + "point": { + "x": 86, + "y": 76, + "wfo": "CHS" + } + }, + { + "city": "Charleston", + "lat": 38.3498, + "lon": -81.6326, + "point": { + "x": 62, + "y": 66, + "wfo": "RLX" + } + }, + { + "city": "Charlotte", + "lat": 35.2271, + "lon": -80.8431, + "point": { + "x": 118, + "y": 64, + "wfo": "GSP" + } + }, + { + "city": "Cheyenne", + "lat": 41.14, + "lon": -104.8202, + "point": { + "x": 109, + "y": 13, + "wfo": "CYS" + } + }, + { + "city": "Cincinnati", + "lat": 39.162, + "lon": -84.4569, + "point": { + "x": 36, + "y": 40, + "wfo": "ILN" + } + }, + { + "city": "Columbia", + "lat": 34.0007, + "lon": -81.0348, + "point": { + "x": 65, + "y": 61, + "wfo": "CAE" + } + }, + { + "city": "Columbus", + "lat": 39.9612, + "lon": -82.9988, + "point": { + "x": 84, + "y": 80, + "wfo": "ILN" + } + }, + { + "city": "Des Moines", + "lat": 41.6005, + "lon": -93.6091, + "point": { + "x": 73, + "y": 49, + "wfo": "DMX" + } + }, + { + "city": "Dubuque", + "lat": 42.5006, + "lon": -90.6646, + "point": { + "x": 62, + "y": 110, + "wfo": "DVN" + } + }, + { + "city": "Duluth", + "lat": 46.7833, + "lon": -92.1066, + "point": { + "x": 91, + "y": 69, + "wfo": "DLH" + } + }, + { + "city": "Eastport", + "lat": 44.9062, + "lon": -66.99, + "point": { + "x": 129, + "y": 79, + "wfo": "CAR" + } + }, + { + "city": "El Centro", + "lat": 32.792, + "lon": -115.563, + "point": { + "x": 26, + "y": 46, + "wfo": "PSR" + } + }, + { + "city": "El Paso", + "lat": 31.7587, + "lon": -106.4869, + "point": { + "x": 99, + "y": 55, + "wfo": "EPZ" + } + }, + { + "city": "Eugene", + "lat": 44.0521, + "lon": -123.0867, + "point": { + "x": 84, + "y": 38, + "wfo": "PQR" + } + }, + { + "city": "Fargo", + "lat": 46.8772, + "lon": -96.7898, + "point": { + "x": 99, + "y": 56, + "wfo": "FGF" + } + }, + { + "city": "Flagstaff", + "lat": 35.1981, + "lon": -111.6513, + "point": { + "x": 73, + "y": 88, + "wfo": "FGZ" + } + }, + { + "city": "Fresno", + "lat": 36.7477, + "lon": -119.7724, + "point": { + "x": 53, + "y": 100, + "wfo": "HNX" + } + }, + { + "city": "Grand Junction", + "lat": 39.0639, + "lon": -108.5506, + "point": { + "x": 94, + "y": 101, + "wfo": "GJT" + } + }, + { + "city": "Grand Rapids", + "lat": 42.9634, + "lon": -85.6681, + "point": { + "x": 40, + "y": 46, + "wfo": "GRR" + } + }, + { + "city": "Havre", + "lat": 48.55, + "lon": -109.6841, + "point": { + "x": 154, + "y": 187, + "wfo": "TFX" + } + }, + { + "city": "Helena", + "lat": 46.5927, + "lon": -112.0361, + "point": { + "x": 68, + "y": 103, + "wfo": "TFX" + } + }, + { + "city": "Honolulu", + "lat": 21.3069, + "lon": -157.8583, + "point": { + "x": 153, + "y": 144, + "wfo": "HFO" + } + }, + { + "city": "Hot Springs", + "lat": 34.5037, + "lon": -93.0552, + "point": { + "x": 53, + "y": 60, + "wfo": "LZK" + } + }, + { + "city": "Idaho Falls", + "lat": 43.4666, + "lon": -112.0341, + "point": { + "x": 115, + "y": 72, + "wfo": "PIH" + } + }, + { + "city": "Jackson", + "lat": 32.2988, + "lon": -90.1848, + "point": { + "x": 75, + "y": 62, + "wfo": "JAN" + } + }, + { + "city": "Jacksonville", + "lat": 30.3322, + "lon": -81.6556, + "point": { + "x": 65, + "y": 64, + "wfo": "JAX" + } + }, + { + "city": "Juneau", + "lat": 58.3019, + "lon": -134.4197, + "point": { + "x": 194, + "y": 163, + "wfo": "AJK" + } + }, + { + "city": "Kansas City", + "lat": 39.1142, + "lon": -94.6275, + "point": { + "x": 41, + "y": 50, + "wfo": "EAX" + } + }, + { + "city": "Key West", + "lat": 24.5557, + "lon": -81.7826, + "point": { + "x": 61, + "y": 47, + "wfo": "KEY" + } + }, + { + "city": "Klamath Falls", + "lat": 42.2249, + "lon": -121.7817, + "point": { + "x": 141, + "y": 61, + "wfo": "MFR" + } + }, + { + "city": "Knoxville", + "lat": 35.9606, + "lon": -83.9207, + "point": { + "x": 71, + "y": 51, + "wfo": "MRX" + } + }, + { + "city": "Las Vegas", + "lat": 36.175, + "lon": -115.1372, + "point": { + "x": 122, + "y": 97, + "wfo": "VEF" + } + }, + { + "city": "Lewiston", + "lat": 46.4165, + "lon": -117.0177, + "point": { + "x": 144, + "y": 30, + "wfo": "OTX" + } + }, + { + "city": "Lincoln", + "lat": 40.8, + "lon": -96.667, + "point": { + "x": 56, + "y": 38, + "wfo": "OAX" + } + }, + { + "city": "Long Beach", + "lat": 33.767, + "lon": -118.1892, + "point": { + "x": 154, + "y": 31, + "wfo": "LOX" + } + }, + { + "city": "Louisville", + "lat": 38.2542, + "lon": -85.7594, + "point": { + "x": 49, + "y": 77, + "wfo": "LMK" + } + }, + { + "city": "Manchester", + "lat": 42.9956, + "lon": -71.4548, + "point": { + "x": 41, + "y": 20, + "wfo": "GYX" + } + }, + { + "city": "Memphis", + "lat": 35.1495, + "lon": -90.049, + "point": { + "x": 41, + "y": 66, + "wfo": "MEG" + } + }, + { + "city": "Milwaukee", + "lat": 43.0389, + "lon": -87.9065, + "point": { + "x": 87, + "y": 64, + "wfo": "MKX" + } + }, + { + "city": "Mobile", + "lat": 30.6944, + "lon": -88.043, + "point": { + "x": 51, + "y": 66, + "wfo": "MOB" + } + }, + { + "city": "Montgomery", + "lat": 32.3668, + "lon": -86.3, + "point": { + "x": 80, + "y": 34, + "wfo": "BMX" + } + }, + { + "city": "Montpelier", + "lat": 44.2601, + "lon": -72.5754, + "point": { + "x": 110, + "y": 49, + "wfo": "BTV" + } + }, + { + "city": "Nashville", + "lat": 36.1659, + "lon": -86.7844, + "point": { + "x": 49, + "y": 56, + "wfo": "OHX" + } + }, + { + "city": "Newark", + "lat": 40.7357, + "lon": -74.1724, + "point": { + "x": 26, + "y": 34, + "wfo": "OKX" + } + }, + { + "city": "New Haven", + "lat": 41.3081, + "lon": -72.9282, + "point": { + "x": 65, + "y": 67, + "wfo": "OKX" + } + }, + { + "city": "New Orleans", + "lat": 29.9546, + "lon": -90.0751, + "point": { + "x": 68, + "y": 88, + "wfo": "LIX" + } + }, + { + "city": "Nome", + "lat": 64.5011, + "lon": -165.4064, + "point": { + "x": 217, + "y": 139, + "wfo": "AFG" + } + }, + { + "city": "Oklahoma City", + "lat": 35.4676, + "lon": -97.5164, + "point": { + "x": 97, + "y": 93, + "wfo": "OUN" + } + }, + { + "city": "Omaha", + "lat": 41.2586, + "lon": -95.9378, + "point": { + "x": 82, + "y": 59, + "wfo": "OAX" + } + }, + { + "city": "Phoenix", + "lat": 33.4484, + "lon": -112.074, + "point": { + "x": 158, + "y": 57, + "wfo": "PSR" + } + }, + { + "city": "Pierre", + "lat": 44.3683, + "lon": -100.351, + "point": { + "x": 54, + "y": 43, + "wfo": "ABR" + } + }, + { + "city": "Portland", + "lat": 43.6615, + "lon": -70.2553, + "point": { + "x": 75, + "y": 58, + "wfo": "GYX" + } + }, + { + "city": "Portland", + "lat": 45.5234, + "lon": -122.6762, + "point": { + "x": 112, + "y": 103, + "wfo": "PQR" + } + }, + { + "city": "Providence", + "lat": 41.824, + "lon": -71.4128, + "point": { + "x": 64, + "y": 64, + "wfo": "BOX" + } + }, + { + "city": "Raleigh", + "lat": 35.7721, + "lon": -78.6386, + "point": { + "x": 74, + "y": 56, + "wfo": "RAH" + } + }, + { + "city": "Reno", + "lat": 39.4986, + "lon": -119.7681, + "point": { + "x": 45, + "y": 104, + "wfo": "REV" + } + }, + { + "city": "Richfield", + "lat": 38.7725, + "lon": -112.0841, + "point": { + "x": 81, + "y": 86, + "wfo": "SLC" + } + }, + { + "city": "Richmond", + "lat": 37.5538, + "lon": -77.4603, + "point": { + "x": 44, + "y": 76, + "wfo": "AKQ" + } + }, + { + "city": "Roanoke", + "lat": 37.271, + "lon": -79.9414, + "point": { + "x": 73, + "y": 68, + "wfo": "RNK" + } + }, + { + "city": "Sacramento", + "lat": 38.5816, + "lon": -121.4944, + "point": { + "x": 40, + "y": 67, + "wfo": "STO" + } + }, + { + "city": "Salt Lake City", + "lat": 40.7608, + "lon": -111.891, + "point": { + "x": 99, + "y": 174, + "wfo": "SLC" + } + }, + { + "city": "San Antonio", + "lat": 29.4241, + "lon": -98.4936, + "point": { + "x": 125, + "y": 53, + "wfo": "EWX" + } + }, + { + "city": "San Diego", + "lat": 32.7153, + "lon": -117.1573, + "point": { + "x": 56, + "y": 13, + "wfo": "SGX" + } + }, + { + "city": "San Jose", + "lat": 37.3394, + "lon": -121.895, + "point": { + "x": 99, + "y": 82, + "wfo": "MTR" + } + }, + { + "city": "Santa Fe", + "lat": 35.687, + "lon": -105.9378, + "point": { + "x": 125, + "y": 143, + "wfo": "ABQ" + } + }, + { + "city": "Savannah", + "lat": 32.0835, + "lon": -81.0998, + "point": { + "x": 46, + "y": 40, + "wfo": "CHS" + } + }, + { + "city": "Shreveport", + "lat": 32.5251, + "lon": -93.7502, + "point": { + "x": 76, + "y": 69, + "wfo": "SHV" + } + }, + { + "city": "Sioux Falls", + "lat": 43.55, + "lon": -96.7003, + "point": { + "x": 99, + "y": 65, + "wfo": "FSD" + } + }, + { + "city": "Sitka", + "lat": 57.0531, + "lon": -135.33, + "point": { + "x": 188, + "y": 112, + "wfo": "AJK" + } + }, + { + "city": "Spokane", + "lat": 47.6597, + "lon": -117.4291, + "point": { + "x": 140, + "y": 90, + "wfo": "OTX" + } + }, + { + "city": "Springfield", + "lat": 39.8017, + "lon": -89.6437, + "point": { + "x": 47, + "y": 55, + "wfo": "ILX" + } + }, + { + "city": "Springfield", + "lat": 42.1015, + "lon": -72.5898, + "point": { + "x": 22, + "y": 69, + "wfo": "BOX" + } + }, + { + "city": "Springfield", + "lat": 37.2153, + "lon": -93.2982, + "point": { + "x": 66, + "y": 34, + "wfo": "SGF" + } + }, + { + "city": "Toledo", + "lat": 41.6639, + "lon": -83.5552, + "point": { + "x": 18, + "y": 66, + "wfo": "CLE" + } + }, + { + "city": "Tulsa", + "lat": 36.154, + "lon": -95.9928, + "point": { + "x": 40, + "y": 104, + "wfo": "TSA" + } + }, + { + "city": "Virginia Beach", + "lat": 36.8529, + "lon": -75.978, + "point": { + "x": 100, + "y": 52, + "wfo": "AKQ" + } + }, + { + "city": "Wichita", + "lat": 37.6922, + "lon": -97.3375, + "point": { + "x": 61, + "y": 33, + "wfo": "ICT" + } + }, + { + "city": "Wilmington", + "lat": 34.2257, + "lon": -77.9447, + "point": { + "x": 88, + "y": 67, + "wfo": "ILM" + } + }, + { + "city": "Tuscan", + "lat": 32.2216, + "lon": -110.9698, + "point": { + "x": 90, + "y": 48, + "wfo": "TWC" + } + } +] \ No newline at end of file diff --git a/datagenerators/output/travelcities.json b/datagenerators/output/travelcities.json new file mode 100644 index 0000000..ba6f654 --- /dev/null +++ b/datagenerators/output/travelcities.json @@ -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" + } + } +] \ No newline at end of file diff --git a/datagenerators/regionalcities-raw.json b/datagenerators/regionalcities-raw.json new file mode 100644 index 0000000..6963742 --- /dev/null +++ b/datagenerators/regionalcities-raw.json @@ -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 + } +] \ No newline at end of file diff --git a/datagenerators/regionalcities.js b/datagenerators/regionalcities.js new file mode 100644 index 0000000..b8d6a37 --- /dev/null +++ b/datagenerators/regionalcities.js @@ -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, ' ')); +})(); diff --git a/datagenerators/travelcities-raw.json b/datagenerators/travelcities-raw.json new file mode 100644 index 0000000..30bdcc0 --- /dev/null +++ b/datagenerators/travelcities-raw.json @@ -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 + } +] \ No newline at end of file diff --git a/datagenerators/travelcities.js b/datagenerators/travelcities.js new file mode 100644 index 0000000..6e39119 --- /dev/null +++ b/datagenerators/travelcities.js @@ -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, ' ')); +})(); diff --git a/server/scripts/data/regionalcities.js b/server/scripts/data/regionalcities.js index b88cd7e..9ba6632 100644 --- a/server/scripts/data/regionalcities.js +++ b/server/scripts/data/regionalcities.js @@ -4,580 +4,1160 @@ const RegionalCities = [ city: 'Atlanta', lat: 33.749, lon: -84.388, + point: { + x: 50, + y: 86, + wfo: 'FFC', + }, }, { city: 'Boston', lat: 42.3584, lon: -71.0598, + point: { + x: 71, + y: 90, + wfo: 'BOX', + }, }, { city: 'Chicago', lat: 41.9796, lon: -87.9045, + point: { + x: 65, + y: 76, + wfo: 'LOT', + }, }, { city: 'Cleveland', lat: 41.4995, lon: -81.6954, + point: { + x: 82, + y: 64, + wfo: 'CLE', + }, }, { city: 'Dallas', lat: 32.8959, lon: -97.0372, + point: { + x: 79, + y: 108, + wfo: 'FWD', + }, }, { city: 'Denver', lat: 39.7391, lon: -104.9847, + point: { + x: 62, + y: 60, + wfo: 'BOU', + }, }, { city: 'Detroit', lat: 42.3314, lon: -83.0457, + point: { + x: 65, + y: 33, + wfo: 'DTX', + }, }, { city: 'Hartford', lat: 41.7637, lon: -72.6851, + point: { + x: 21, + y: 54, + wfo: 'BOX', + }, }, { city: 'Houston', lat: 29.7633, lon: -95.3633, + point: { + x: 65, + y: 97, + wfo: 'HGX', + }, }, { city: 'Indianapolis', lat: 39.7684, lon: -86.158, + point: { + x: 57, + y: 68, + wfo: 'IND', + }, }, { city: 'Los Angeles', lat: 34.0522, lon: -118.2437, + point: { + x: 154, + y: 44, + wfo: 'LOX', + }, }, { city: 'Miami', lat: 25.7743, lon: -80.1937, + point: { + x: 109, + y: 50, + wfo: 'MFL', + }, }, { city: 'Minneapolis', lat: 44.98, lon: -93.2638, + point: { + x: 107, + y: 71, + wfo: 'MPX', + }, }, { city: 'New York', lat: 40.78, lon: -73.88, + point: { + x: 36, + y: 38, + wfo: 'OKX', + }, }, { city: 'Norfolk', lat: 36.8468, lon: -76.2852, + point: { + x: 89, + y: 51, + wfo: 'AKQ', + }, }, { city: 'Orlando', lat: 28.5383, lon: -81.3792, + point: { + x: 26, + y: 68, + wfo: 'MLB', + }, }, { city: 'Philadelphia', lat: 39.9523, lon: -75.1638, + point: { + x: 49, + y: 75, + wfo: 'PHI', + }, }, { city: 'Pittsburgh', lat: 40.4406, lon: -79.9959, + point: { + x: 77, + y: 65, + wfo: 'PBZ', + }, }, { city: 'St. Louis', lat: 38.6273, lon: -90.1979, + point: { + x: 94, + y: 73, + wfo: 'LSX', + }, }, { city: 'San Francisco', lat: 37.6148, lon: -122.3918, + point: { + x: 84, + y: 98, + wfo: 'MTR', + }, }, { city: 'Seattle', lat: 47.6062, lon: -122.3321, + point: { + x: 124, + y: 67, + wfo: 'SEW', + }, }, { city: 'Syracuse', lat: 43.0481, lon: -76.1474, + point: { + x: 51, + y: 98, + wfo: 'BGM', + }, }, { city: 'Tampa', lat: 27.9756, lon: -82.5329, + point: { + x: 67, + y: 97, + wfo: 'TBW', + }, }, { city: 'Washington DC', lat: 38.8951, lon: -77.0364, + point: { + x: 97, + y: 71, + wfo: 'LWX', + }, }, { city: 'Albany', lat: 42.6526, lon: -73.7562, + point: { + x: 58, + y: 58, + wfo: 'ALY', + }, }, { city: 'Albuquerque', lat: 35.0845, lon: -106.6511, + point: { + x: 97, + y: 118, + wfo: 'ABQ', + }, }, { city: 'Amarillo', lat: 35.222, lon: -101.8313, + point: { + x: 47, + y: 25, + wfo: 'AMA', + }, }, { city: 'Anchorage', lat: 61.2181, lon: -149.9003, + point: { + x: 125, + y: 236, + wfo: 'AER', + }, }, { city: 'Austin', lat: 30.2671, lon: -97.7431, + point: { + x: 155, + y: 90, + wfo: 'EWX', + }, }, { city: 'Baker', lat: 44.7502, lon: -117.6677, + point: { + x: 93, + y: 145, + wfo: 'BOI', + }, }, { city: 'Baltimore', lat: 39.2904, lon: -76.6122, + point: { + x: 109, + y: 91, + wfo: 'LWX', + }, }, { city: 'Bangor', lat: 44.8012, lon: -68.7778, + point: { + x: 72, + y: 62, + wfo: 'CAR', + }, }, { city: 'Birmingham', lat: 33.5207, lon: -86.8025, + point: { + x: 58, + y: 83, + wfo: 'BMX', + }, }, { city: 'Bismarck', lat: 46.8083, lon: -100.7837, + point: { + x: 109, + y: 46, + wfo: 'BIS', + }, }, { city: 'Boise', lat: 43.6135, lon: -116.2034, + point: { + x: 132, + y: 85, + wfo: 'BOI', + }, }, { city: 'Buffalo', lat: 42.8864, lon: -78.8784, + point: { + x: 35, + y: 46, + wfo: 'BUF', + }, }, { city: 'Carlsbad', lat: 32.4207, lon: -104.2288, + point: { + x: 44, + y: 156, + wfo: 'MAF', + }, }, { city: 'Charleston', lat: 32.7766, lon: -79.9309, + point: { + x: 86, + y: 76, + wfo: 'CHS', + }, }, { city: 'Charleston', lat: 38.3498, lon: -81.6326, + point: { + x: 62, + y: 66, + wfo: 'RLX', + }, }, { city: 'Charlotte', lat: 35.2271, lon: -80.8431, + point: { + x: 118, + y: 64, + wfo: 'GSP', + }, }, { city: 'Cheyenne', lat: 41.14, lon: -104.8202, + point: { + x: 109, + y: 13, + wfo: 'CYS', + }, }, { city: 'Cincinnati', lat: 39.162, lon: -84.4569, + point: { + x: 36, + y: 40, + wfo: 'ILN', + }, }, { city: 'Columbia', lat: 34.0007, lon: -81.0348, + point: { + x: 65, + y: 61, + wfo: 'CAE', + }, }, { city: 'Columbus', lat: 39.9612, lon: -82.9988, + point: { + x: 84, + y: 80, + wfo: 'ILN', + }, }, { city: 'Des Moines', lat: 41.6005, lon: -93.6091, + point: { + x: 73, + y: 49, + wfo: 'DMX', + }, }, { city: 'Dubuque', lat: 42.5006, lon: -90.6646, + point: { + x: 62, + y: 110, + wfo: 'DVN', + }, }, { city: 'Duluth', lat: 46.7833, lon: -92.1066, + point: { + x: 91, + y: 69, + wfo: 'DLH', + }, }, { city: 'Eastport', lat: 44.9062, lon: -66.99, + point: { + x: 129, + y: 79, + wfo: 'CAR', + }, }, { city: 'El Centro', lat: 32.792, lon: -115.563, + point: { + x: 26, + y: 46, + wfo: 'PSR', + }, }, { city: 'El Paso', lat: 31.7587, lon: -106.4869, + point: { + x: 99, + y: 55, + wfo: 'EPZ', + }, }, { city: 'Eugene', lat: 44.0521, lon: -123.0867, + point: { + x: 84, + y: 38, + wfo: 'PQR', + }, }, { city: 'Fargo', lat: 46.8772, lon: -96.7898, + point: { + x: 99, + y: 56, + wfo: 'FGF', + }, }, { city: 'Flagstaff', lat: 35.1981, lon: -111.6513, + point: { + x: 73, + y: 88, + wfo: 'FGZ', + }, }, { city: 'Fresno', lat: 36.7477, lon: -119.7724, + point: { + x: 53, + y: 100, + wfo: 'HNX', + }, }, { city: 'Grand Junction', lat: 39.0639, lon: -108.5506, + point: { + x: 94, + y: 101, + wfo: 'GJT', + }, }, { city: 'Grand Rapids', lat: 42.9634, lon: -85.6681, + point: { + x: 40, + y: 46, + wfo: 'GRR', + }, }, { city: 'Havre', lat: 48.55, lon: -109.6841, + point: { + x: 154, + y: 187, + wfo: 'TFX', + }, }, { city: 'Helena', lat: 46.5927, lon: -112.0361, + point: { + x: 68, + y: 103, + wfo: 'TFX', + }, }, { city: 'Honolulu', lat: 21.3069, lon: -157.8583, + point: { + x: 153, + y: 144, + wfo: 'HFO', + }, }, { city: 'Hot Springs', lat: 34.5037, lon: -93.0552, + point: { + x: 53, + y: 60, + wfo: 'LZK', + }, }, { city: 'Idaho Falls', lat: 43.4666, lon: -112.0341, + point: { + x: 115, + y: 72, + wfo: 'PIH', + }, }, { city: 'Jackson', lat: 32.2988, lon: -90.1848, + point: { + x: 75, + y: 62, + wfo: 'JAN', + }, }, { city: 'Jacksonville', lat: 30.3322, lon: -81.6556, + point: { + x: 65, + y: 64, + wfo: 'JAX', + }, }, { city: 'Juneau', lat: 58.3019, lon: -134.4197, + point: { + x: 194, + y: 163, + wfo: 'AJK', + }, }, { city: 'Kansas City', lat: 39.1142, lon: -94.6275, + point: { + x: 41, + y: 50, + wfo: 'EAX', + }, }, { city: 'Key West', lat: 24.5557, lon: -81.7826, + point: { + x: 61, + y: 47, + wfo: 'KEY', + }, }, { city: 'Klamath Falls', lat: 42.2249, lon: -121.7817, + point: { + x: 141, + y: 61, + wfo: 'MFR', + }, }, { city: 'Knoxville', lat: 35.9606, lon: -83.9207, + point: { + x: 71, + y: 51, + wfo: 'MRX', + }, }, { city: 'Las Vegas', lat: 36.175, lon: -115.1372, + point: { + x: 122, + y: 97, + wfo: 'VEF', + }, }, { city: 'Lewiston', lat: 46.4165, lon: -117.0177, + point: { + x: 144, + y: 30, + wfo: 'OTX', + }, }, { city: 'Lincoln', lat: 40.8, lon: -96.667, + point: { + x: 56, + y: 38, + wfo: 'OAX', + }, }, { city: 'Long Beach', lat: 33.767, lon: -118.1892, + point: { + x: 154, + y: 31, + wfo: 'LOX', + }, }, { city: 'Louisville', lat: 38.2542, lon: -85.7594, + point: { + x: 49, + y: 77, + wfo: 'LMK', + }, }, { city: 'Manchester', lat: 42.9956, lon: -71.4548, + point: { + x: 41, + y: 20, + wfo: 'GYX', + }, }, { city: 'Memphis', lat: 35.1495, lon: -90.049, + point: { + x: 41, + y: 66, + wfo: 'MEG', + }, }, { city: 'Milwaukee', lat: 43.0389, lon: -87.9065, + point: { + x: 87, + y: 64, + wfo: 'MKX', + }, }, { city: 'Mobile', lat: 30.6944, lon: -88.043, + point: { + x: 51, + y: 66, + wfo: 'MOB', + }, }, { city: 'Montgomery', lat: 32.3668, lon: -86.3, + point: { + x: 80, + y: 34, + wfo: 'BMX', + }, }, { city: 'Montpelier', lat: 44.2601, lon: -72.5754, + point: { + x: 110, + y: 49, + wfo: 'BTV', + }, }, { city: 'Nashville', lat: 36.1659, lon: -86.7844, + point: { + x: 49, + y: 56, + wfo: 'OHX', + }, }, { city: 'Newark', lat: 40.7357, lon: -74.1724, + point: { + x: 26, + y: 34, + wfo: 'OKX', + }, }, { city: 'New Haven', lat: 41.3081, lon: -72.9282, + point: { + x: 65, + y: 67, + wfo: 'OKX', + }, }, { city: 'New Orleans', lat: 29.9546, lon: -90.0751, + point: { + x: 68, + y: 88, + wfo: 'LIX', + }, }, { city: 'Nome', lat: 64.5011, lon: -165.4064, + point: { + x: 217, + y: 139, + wfo: 'AFG', + }, }, { city: 'Oklahoma City', lat: 35.4676, lon: -97.5164, + point: { + x: 97, + y: 93, + wfo: 'OUN', + }, }, { city: 'Omaha', lat: 41.2586, lon: -95.9378, + point: { + x: 82, + y: 59, + wfo: 'OAX', + }, }, { city: 'Phoenix', lat: 33.4484, lon: -112.074, + point: { + x: 158, + y: 57, + wfo: 'PSR', + }, }, { city: 'Pierre', lat: 44.3683, lon: -100.351, + point: { + x: 54, + y: 43, + wfo: 'ABR', + }, }, { city: 'Portland', lat: 43.6615, lon: -70.2553, + point: { + x: 75, + y: 58, + wfo: 'GYX', + }, }, { city: 'Portland', lat: 45.5234, lon: -122.6762, + point: { + x: 112, + y: 103, + wfo: 'PQR', + }, }, { city: 'Providence', lat: 41.824, lon: -71.4128, + point: { + x: 64, + y: 64, + wfo: 'BOX', + }, }, { city: 'Raleigh', lat: 35.7721, lon: -78.6386, + point: { + x: 74, + y: 56, + wfo: 'RAH', + }, }, { city: 'Reno', lat: 39.4986, lon: -119.7681, + point: { + x: 45, + y: 104, + wfo: 'REV', + }, }, { city: 'Richfield', lat: 38.7725, lon: -112.0841, + point: { + x: 81, + y: 86, + wfo: 'SLC', + }, }, { city: 'Richmond', lat: 37.5538, lon: -77.4603, + point: { + x: 44, + y: 76, + wfo: 'AKQ', + }, }, { city: 'Roanoke', lat: 37.271, lon: -79.9414, + point: { + x: 73, + y: 68, + wfo: 'RNK', + }, }, { city: 'Sacramento', lat: 38.5816, lon: -121.4944, + point: { + x: 40, + y: 67, + wfo: 'STO', + }, }, { city: 'Salt Lake City', lat: 40.7608, lon: -111.891, + point: { + x: 99, + y: 174, + wfo: 'SLC', + }, }, { city: 'San Antonio', lat: 29.4241, lon: -98.4936, + point: { + x: 125, + y: 53, + wfo: 'EWX', + }, }, { city: 'San Diego', lat: 32.7153, lon: -117.1573, + point: { + x: 56, + y: 13, + wfo: 'SGX', + }, }, { city: 'San Jose', lat: 37.3394, lon: -121.895, + point: { + x: 99, + y: 82, + wfo: 'MTR', + }, }, { city: 'Santa Fe', lat: 35.687, lon: -105.9378, + point: { + x: 125, + y: 143, + wfo: 'ABQ', + }, }, { city: 'Savannah', lat: 32.0835, lon: -81.0998, + point: { + x: 46, + y: 40, + wfo: 'CHS', + }, }, { city: 'Shreveport', lat: 32.5251, lon: -93.7502, + point: { + x: 76, + y: 69, + wfo: 'SHV', + }, }, { city: 'Sioux Falls', lat: 43.55, lon: -96.7003, + point: { + x: 99, + y: 65, + wfo: 'FSD', + }, }, { city: 'Sitka', lat: 57.0531, lon: -135.33, + point: { + x: 188, + y: 112, + wfo: 'AJK', + }, }, { city: 'Spokane', lat: 47.6597, lon: -117.4291, + point: { + x: 140, + y: 90, + wfo: 'OTX', + }, }, { city: 'Springfield', lat: 39.8017, lon: -89.6437, + point: { + x: 47, + y: 55, + wfo: 'ILX', + }, }, { city: 'Springfield', lat: 42.1015, lon: -72.5898, + point: { + x: 22, + y: 69, + wfo: 'BOX', + }, }, { city: 'Springfield', lat: 37.2153, lon: -93.2982, + point: { + x: 66, + y: 34, + wfo: 'SGF', + }, }, { city: 'Toledo', lat: 41.6639, lon: -83.5552, + point: { + x: 18, + y: 66, + wfo: 'CLE', + }, }, { city: 'Tulsa', lat: 36.154, lon: -95.9928, + point: { + x: 40, + y: 104, + wfo: 'TSA', + }, }, { city: 'Virginia Beach', lat: 36.8529, lon: -75.978, + point: { + x: 100, + y: 52, + wfo: 'AKQ', + }, }, { city: 'Wichita', lat: 37.6922, lon: -97.3375, + point: { + x: 61, + y: 33, + wfo: 'ICT', + }, }, { city: 'Wilmington', lat: 34.2257, lon: -77.9447, + point: { + x: 88, + y: 67, + wfo: 'ILM', + }, }, { city: 'Tuscan', lat: 32.2216, lon: -110.9698, + point: { + x: 90, + y: 48, + wfo: 'TWC', + }, }, ]; diff --git a/server/scripts/data/travelcities.js b/server/scripts/data/travelcities.js index 9755291..d9b0735 100644 --- a/server/scripts/data/travelcities.js +++ b/server/scripts/data/travelcities.js @@ -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', + }, }, ]; diff --git a/server/scripts/modules/regionalforecast.js b/server/scripts/modules/regionalforecast.js index 04d2722..2329a20 100644 --- a/server/scripts/modules/regionalforecast.js +++ b/server/scripts/modules/regionalforecast.js @@ -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; diff --git a/server/scripts/modules/travelforecast.js b/server/scripts/modules/travelforecast.js index dafe2d2..d39116a 100644 --- a/server/scripts/modules/travelforecast.js +++ b/server/scripts/modules/travelforecast.js @@ -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