better stations list
This commit is contained in:
parent
e81fd75e67
commit
c8c04288b9
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
|
@ -4,6 +4,7 @@
|
|||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "Frontend",
|
||||
"request": "launch",
|
||||
|
@ -15,6 +16,15 @@
|
|||
"**/*.min.js",
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data:stations",
|
||||
"program": "${workspaceFolder}/datagenerators/stations.js",
|
||||
"request": "launch",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "pwa-node"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
|
|
24
datagenerators/https.js
Normal file
24
datagenerators/https.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
// async https wrapper
|
||||
|
||||
const https = require('https');
|
||||
|
||||
module.exports = (url) => new Promise((resolve, reject) => {
|
||||
const headers = {};
|
||||
headers['user-agent'] = '(WeatherStar 4000+ data generator, ws4000@netbymatt.com)';
|
||||
|
||||
https.get(url, {
|
||||
headers,
|
||||
}, res => {
|
||||
if (res.statusCode === 200) {
|
||||
const buffers = [];
|
||||
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=> {
|
||||
console.log(e);
|
||||
reject(e);
|
||||
});
|
||||
});
|
19547
datagenerators/output/stations - Copy.js
Normal file
19547
datagenerators/output/stations - Copy.js
Normal file
File diff suppressed because it is too large
Load diff
3334
datagenerators/output/stations.js
Normal file
3334
datagenerators/output/stations.js
Normal file
File diff suppressed because it is too large
Load diff
53
datagenerators/stations-states.js
Normal file
53
datagenerators/stations-states.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
module.exports = [
|
||||
'AZ',
|
||||
'AL',
|
||||
'AK',
|
||||
'AR',
|
||||
'CA',
|
||||
'CO',
|
||||
'CT',
|
||||
'DE',
|
||||
'FL',
|
||||
'GA',
|
||||
'HI',
|
||||
'ID',
|
||||
'IL',
|
||||
'IN',
|
||||
'IA',
|
||||
'KS',
|
||||
'KY',
|
||||
'LA',
|
||||
'ME',
|
||||
'MD',
|
||||
'MA',
|
||||
'MI',
|
||||
'MN',
|
||||
'MS',
|
||||
'MO',
|
||||
'MT',
|
||||
'NE',
|
||||
'NV',
|
||||
'NH',
|
||||
'NJ',
|
||||
'NM',
|
||||
'NY',
|
||||
'NC',
|
||||
'ND',
|
||||
'OH',
|
||||
'OK',
|
||||
'OR',
|
||||
'PA',
|
||||
'RI',
|
||||
'SC',
|
||||
'SD',
|
||||
'TN',
|
||||
'TX',
|
||||
'UT',
|
||||
'VT',
|
||||
'VA',
|
||||
'WA',
|
||||
'WV',
|
||||
'WI',
|
||||
'WY',
|
||||
'PR',
|
||||
];
|
54
datagenerators/stations.js
Normal file
54
datagenerators/stations.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
// 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');
|
||||
|
||||
// immediately invoked function so we can access async/await
|
||||
const start = async () => {
|
||||
// load the list of states
|
||||
const states = ['AK', 'NC', 'VA', 'TX', 'GA', 'PR'];
|
||||
// const states = require('./stations-states.js');
|
||||
|
||||
let output = {};
|
||||
// loop through states
|
||||
await Promise.all(states.map(async (state) => {
|
||||
try {
|
||||
// get list and parse the JSON
|
||||
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}$/));
|
||||
// add each resulting station to the output
|
||||
stations.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: state,
|
||||
lat: station.geometry.coordinates[1],
|
||||
lon: station.geometry.coordinates[0],
|
||||
};
|
||||
});
|
||||
console.log(`Complete: ${state}`);
|
||||
} catch (e) {
|
||||
console.error(`Unable to get state: ${state}`);
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
|
||||
// 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();
|
||||
})();
|
||||
|
|
@ -1,584 +1,584 @@
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
const _RegionalCities = [
|
||||
{
|
||||
Name: 'Atlanta',
|
||||
Latitude: 33.749,
|
||||
Longitude: -84.388,
|
||||
city: 'Atlanta',
|
||||
lat: 33.749,
|
||||
lon: -84.388,
|
||||
},
|
||||
{
|
||||
Name: 'Boston',
|
||||
Latitude: 42.3584,
|
||||
Longitude: -71.0598,
|
||||
city: 'Boston',
|
||||
lat: 42.3584,
|
||||
lon: -71.0598,
|
||||
},
|
||||
{
|
||||
Name: 'Chicago',
|
||||
Latitude: 41.9796,
|
||||
Longitude: -87.9045,
|
||||
city: 'Chicago',
|
||||
lat: 41.9796,
|
||||
lon: -87.9045,
|
||||
},
|
||||
{
|
||||
Name: 'Cleveland',
|
||||
Latitude: 41.4995,
|
||||
Longitude: -81.6954,
|
||||
city: 'Cleveland',
|
||||
lat: 41.4995,
|
||||
lon: -81.6954,
|
||||
},
|
||||
{
|
||||
Name: 'Dallas',
|
||||
Latitude: 32.8959,
|
||||
Longitude: -97.0372,
|
||||
city: 'Dallas',
|
||||
lat: 32.8959,
|
||||
lon: -97.0372,
|
||||
},
|
||||
{
|
||||
Name: 'Denver',
|
||||
Latitude: 39.7391,
|
||||
Longitude: -104.9847,
|
||||
city: 'Denver',
|
||||
lat: 39.7391,
|
||||
lon: -104.9847,
|
||||
},
|
||||
{
|
||||
Name: 'Detroit',
|
||||
Latitude: 42.3314,
|
||||
Longitude: -83.0457,
|
||||
city: 'Detroit',
|
||||
lat: 42.3314,
|
||||
lon: -83.0457,
|
||||
},
|
||||
{
|
||||
Name: 'Hartford',
|
||||
Latitude: 41.7637,
|
||||
Longitude: -72.6851,
|
||||
city: 'Hartford',
|
||||
lat: 41.7637,
|
||||
lon: -72.6851,
|
||||
},
|
||||
{
|
||||
Name: 'Houston',
|
||||
Latitude: 29.7633,
|
||||
Longitude: -95.3633,
|
||||
city: 'Houston',
|
||||
lat: 29.7633,
|
||||
lon: -95.3633,
|
||||
},
|
||||
{
|
||||
Name: 'Indianapolis',
|
||||
Latitude: 39.7684,
|
||||
Longitude: -86.158,
|
||||
city: 'Indianapolis',
|
||||
lat: 39.7684,
|
||||
lon: -86.158,
|
||||
},
|
||||
{
|
||||
Name: 'Los Angeles',
|
||||
Latitude: 34.0522,
|
||||
Longitude: -118.2437,
|
||||
city: 'Los Angeles',
|
||||
lat: 34.0522,
|
||||
lon: -118.2437,
|
||||
},
|
||||
{
|
||||
Name: 'Miami',
|
||||
Latitude: 25.7743,
|
||||
Longitude: -80.1937,
|
||||
city: 'Miami',
|
||||
lat: 25.7743,
|
||||
lon: -80.1937,
|
||||
},
|
||||
{
|
||||
Name: 'Minneapolis',
|
||||
Latitude: 44.98,
|
||||
Longitude: -93.2638,
|
||||
city: 'Minneapolis',
|
||||
lat: 44.98,
|
||||
lon: -93.2638,
|
||||
},
|
||||
{
|
||||
Name: 'New York',
|
||||
Latitude: 40.78,
|
||||
Longitude: -73.88,
|
||||
city: 'New York',
|
||||
lat: 40.78,
|
||||
lon: -73.88,
|
||||
},
|
||||
{
|
||||
Name: 'Norfolk',
|
||||
Latitude: 36.8468,
|
||||
Longitude: -76.2852,
|
||||
city: 'Norfolk',
|
||||
lat: 36.8468,
|
||||
lon: -76.2852,
|
||||
},
|
||||
{
|
||||
Name: 'Orlando',
|
||||
Latitude: 28.5383,
|
||||
Longitude: -81.3792,
|
||||
city: 'Orlando',
|
||||
lat: 28.5383,
|
||||
lon: -81.3792,
|
||||
},
|
||||
{
|
||||
Name: 'Philadelphia',
|
||||
Latitude: 39.9523,
|
||||
Longitude: -75.1638,
|
||||
city: 'Philadelphia',
|
||||
lat: 39.9523,
|
||||
lon: -75.1638,
|
||||
},
|
||||
{
|
||||
Name: 'Pittsburgh',
|
||||
Latitude: 40.4406,
|
||||
Longitude: -79.9959,
|
||||
city: 'Pittsburgh',
|
||||
lat: 40.4406,
|
||||
lon: -79.9959,
|
||||
},
|
||||
{
|
||||
Name: 'St. Louis',
|
||||
Latitude: 38.6273,
|
||||
Longitude: -90.1979,
|
||||
city: 'St. Louis',
|
||||
lat: 38.6273,
|
||||
lon: -90.1979,
|
||||
},
|
||||
{
|
||||
Name: 'San Francisco',
|
||||
Latitude: 37.6148,
|
||||
Longitude: -122.3918,
|
||||
city: 'San Francisco',
|
||||
lat: 37.6148,
|
||||
lon: -122.3918,
|
||||
},
|
||||
{
|
||||
Name: 'Seattle',
|
||||
Latitude: 47.6062,
|
||||
Longitude: -122.3321,
|
||||
city: 'Seattle',
|
||||
lat: 47.6062,
|
||||
lon: -122.3321,
|
||||
},
|
||||
{
|
||||
Name: 'Syracuse',
|
||||
Latitude: 43.0481,
|
||||
Longitude: -76.1474,
|
||||
city: 'Syracuse',
|
||||
lat: 43.0481,
|
||||
lon: -76.1474,
|
||||
},
|
||||
{
|
||||
Name: 'Tampa',
|
||||
Latitude: 27.9756,
|
||||
Longitude: -82.5329,
|
||||
city: 'Tampa',
|
||||
lat: 27.9756,
|
||||
lon: -82.5329,
|
||||
},
|
||||
{
|
||||
Name: 'Washington DC',
|
||||
Latitude: 38.8951,
|
||||
Longitude: -77.0364,
|
||||
city: 'Washington DC',
|
||||
lat: 38.8951,
|
||||
lon: -77.0364,
|
||||
},
|
||||
{
|
||||
Name: 'Albany',
|
||||
Latitude: 42.6526,
|
||||
Longitude: -73.7562,
|
||||
city: 'Albany',
|
||||
lat: 42.6526,
|
||||
lon: -73.7562,
|
||||
},
|
||||
{
|
||||
Name: 'Albuquerque',
|
||||
Latitude: 35.0845,
|
||||
Longitude: -106.6511,
|
||||
city: 'Albuquerque',
|
||||
lat: 35.0845,
|
||||
lon: -106.6511,
|
||||
},
|
||||
{
|
||||
Name: 'Amarillo',
|
||||
Latitude: 35.222,
|
||||
Longitude: -101.8313,
|
||||
city: 'Amarillo',
|
||||
lat: 35.222,
|
||||
lon: -101.8313,
|
||||
},
|
||||
{
|
||||
Name: 'Anchorage',
|
||||
Latitude: 61.2181,
|
||||
Longitude: -149.9003,
|
||||
city: 'Anchorage',
|
||||
lat: 61.2181,
|
||||
lon: -149.9003,
|
||||
},
|
||||
{
|
||||
Name: 'Austin',
|
||||
Latitude: 30.2671,
|
||||
Longitude: -97.7431,
|
||||
city: 'Austin',
|
||||
lat: 30.2671,
|
||||
lon: -97.7431,
|
||||
},
|
||||
{
|
||||
Name: 'Baker',
|
||||
Latitude: 44.7502,
|
||||
Longitude: -117.6677,
|
||||
city: 'Baker',
|
||||
lat: 44.7502,
|
||||
lon: -117.6677,
|
||||
},
|
||||
{
|
||||
Name: 'Baltimore',
|
||||
Latitude: 39.2904,
|
||||
Longitude: -76.6122,
|
||||
city: 'Baltimore',
|
||||
lat: 39.2904,
|
||||
lon: -76.6122,
|
||||
},
|
||||
{
|
||||
Name: 'Bangor',
|
||||
Latitude: 44.8012,
|
||||
Longitude: -68.7778,
|
||||
city: 'Bangor',
|
||||
lat: 44.8012,
|
||||
lon: -68.7778,
|
||||
},
|
||||
{
|
||||
Name: 'Birmingham',
|
||||
Latitude: 33.5207,
|
||||
Longitude: -86.8025,
|
||||
city: 'Birmingham',
|
||||
lat: 33.5207,
|
||||
lon: -86.8025,
|
||||
},
|
||||
{
|
||||
Name: 'Bismarck',
|
||||
Latitude: 46.8083,
|
||||
Longitude: -100.7837,
|
||||
city: 'Bismarck',
|
||||
lat: 46.8083,
|
||||
lon: -100.7837,
|
||||
},
|
||||
{
|
||||
Name: 'Boise',
|
||||
Latitude: 43.6135,
|
||||
Longitude: -116.2034,
|
||||
city: 'Boise',
|
||||
lat: 43.6135,
|
||||
lon: -116.2034,
|
||||
},
|
||||
{
|
||||
Name: 'Buffalo',
|
||||
Latitude: 42.8864,
|
||||
Longitude: -78.8784,
|
||||
city: 'Buffalo',
|
||||
lat: 42.8864,
|
||||
lon: -78.8784,
|
||||
},
|
||||
{
|
||||
Name: 'Carlsbad',
|
||||
Latitude: 32.4207,
|
||||
Longitude: -104.2288,
|
||||
city: 'Carlsbad',
|
||||
lat: 32.4207,
|
||||
lon: -104.2288,
|
||||
},
|
||||
{
|
||||
Name: 'Charleston',
|
||||
Latitude: 32.7766,
|
||||
Longitude: -79.9309,
|
||||
city: 'Charleston',
|
||||
lat: 32.7766,
|
||||
lon: -79.9309,
|
||||
},
|
||||
{
|
||||
Name: 'Charleston',
|
||||
Latitude: 38.3498,
|
||||
Longitude: -81.6326,
|
||||
city: 'Charleston',
|
||||
lat: 38.3498,
|
||||
lon: -81.6326,
|
||||
},
|
||||
{
|
||||
Name: 'Charlotte',
|
||||
Latitude: 35.2271,
|
||||
Longitude: -80.8431,
|
||||
city: 'Charlotte',
|
||||
lat: 35.2271,
|
||||
lon: -80.8431,
|
||||
},
|
||||
{
|
||||
Name: 'Cheyenne',
|
||||
Latitude: 41.14,
|
||||
Longitude: -104.8202,
|
||||
city: 'Cheyenne',
|
||||
lat: 41.14,
|
||||
lon: -104.8202,
|
||||
},
|
||||
{
|
||||
Name: 'Cincinnati',
|
||||
Latitude: 39.162,
|
||||
Longitude: -84.4569,
|
||||
city: 'Cincinnati',
|
||||
lat: 39.162,
|
||||
lon: -84.4569,
|
||||
},
|
||||
{
|
||||
Name: 'Columbia',
|
||||
Latitude: 34.0007,
|
||||
Longitude: -81.0348,
|
||||
city: 'Columbia',
|
||||
lat: 34.0007,
|
||||
lon: -81.0348,
|
||||
},
|
||||
{
|
||||
Name: 'Columbus',
|
||||
Latitude: 39.9612,
|
||||
Longitude: -82.9988,
|
||||
city: 'Columbus',
|
||||
lat: 39.9612,
|
||||
lon: -82.9988,
|
||||
},
|
||||
{
|
||||
Name: 'Des Moines',
|
||||
Latitude: 41.6005,
|
||||
Longitude: -93.6091,
|
||||
city: 'Des Moines',
|
||||
lat: 41.6005,
|
||||
lon: -93.6091,
|
||||
},
|
||||
{
|
||||
Name: 'Dubuque',
|
||||
Latitude: 42.5006,
|
||||
Longitude: -90.6646,
|
||||
city: 'Dubuque',
|
||||
lat: 42.5006,
|
||||
lon: -90.6646,
|
||||
},
|
||||
{
|
||||
Name: 'Duluth',
|
||||
Latitude: 46.7833,
|
||||
Longitude: -92.1066,
|
||||
city: 'Duluth',
|
||||
lat: 46.7833,
|
||||
lon: -92.1066,
|
||||
},
|
||||
{
|
||||
Name: 'Eastport',
|
||||
Latitude: 44.9062,
|
||||
Longitude: -66.99,
|
||||
city: 'Eastport',
|
||||
lat: 44.9062,
|
||||
lon: -66.99,
|
||||
},
|
||||
{
|
||||
Name: 'El Centro',
|
||||
Latitude: 32.792,
|
||||
Longitude: -115.563,
|
||||
city: 'El Centro',
|
||||
lat: 32.792,
|
||||
lon: -115.563,
|
||||
},
|
||||
{
|
||||
Name: 'El Paso',
|
||||
Latitude: 31.7587,
|
||||
Longitude: -106.4869,
|
||||
city: 'El Paso',
|
||||
lat: 31.7587,
|
||||
lon: -106.4869,
|
||||
},
|
||||
{
|
||||
Name: 'Eugene',
|
||||
Latitude: 44.0521,
|
||||
Longitude: -123.0867,
|
||||
city: 'Eugene',
|
||||
lat: 44.0521,
|
||||
lon: -123.0867,
|
||||
},
|
||||
{
|
||||
Name: 'Fargo',
|
||||
Latitude: 46.8772,
|
||||
Longitude: -96.7898,
|
||||
city: 'Fargo',
|
||||
lat: 46.8772,
|
||||
lon: -96.7898,
|
||||
},
|
||||
{
|
||||
Name: 'Flagstaff',
|
||||
Latitude: 35.1981,
|
||||
Longitude: -111.6513,
|
||||
city: 'Flagstaff',
|
||||
lat: 35.1981,
|
||||
lon: -111.6513,
|
||||
},
|
||||
{
|
||||
Name: 'Fresno',
|
||||
Latitude: 36.7477,
|
||||
Longitude: -119.7724,
|
||||
city: 'Fresno',
|
||||
lat: 36.7477,
|
||||
lon: -119.7724,
|
||||
},
|
||||
{
|
||||
Name: 'Grand Junction',
|
||||
Latitude: 39.0639,
|
||||
Longitude: -108.5506,
|
||||
city: 'Grand Junction',
|
||||
lat: 39.0639,
|
||||
lon: -108.5506,
|
||||
},
|
||||
{
|
||||
Name: 'Grand Rapids',
|
||||
Latitude: 42.9634,
|
||||
Longitude: -85.6681,
|
||||
city: 'Grand Rapids',
|
||||
lat: 42.9634,
|
||||
lon: -85.6681,
|
||||
},
|
||||
{
|
||||
Name: 'Havre',
|
||||
Latitude: 48.55,
|
||||
Longitude: -109.6841,
|
||||
city: 'Havre',
|
||||
lat: 48.55,
|
||||
lon: -109.6841,
|
||||
},
|
||||
{
|
||||
Name: 'Helena',
|
||||
Latitude: 46.5927,
|
||||
Longitude: -112.0361,
|
||||
city: 'Helena',
|
||||
lat: 46.5927,
|
||||
lon: -112.0361,
|
||||
},
|
||||
{
|
||||
Name: 'Honolulu',
|
||||
Latitude: 21.3069,
|
||||
Longitude: -157.8583,
|
||||
city: 'Honolulu',
|
||||
lat: 21.3069,
|
||||
lon: -157.8583,
|
||||
},
|
||||
{
|
||||
Name: 'Hot Springs',
|
||||
Latitude: 34.5037,
|
||||
Longitude: -93.0552,
|
||||
city: 'Hot Springs',
|
||||
lat: 34.5037,
|
||||
lon: -93.0552,
|
||||
},
|
||||
{
|
||||
Name: 'Idaho Falls',
|
||||
Latitude: 43.4666,
|
||||
Longitude: -112.0341,
|
||||
city: 'Idaho Falls',
|
||||
lat: 43.4666,
|
||||
lon: -112.0341,
|
||||
},
|
||||
{
|
||||
Name: 'Jackson',
|
||||
Latitude: 32.2988,
|
||||
Longitude: -90.1848,
|
||||
city: 'Jackson',
|
||||
lat: 32.2988,
|
||||
lon: -90.1848,
|
||||
},
|
||||
{
|
||||
Name: 'Jacksonville',
|
||||
Latitude: 30.3322,
|
||||
Longitude: -81.6556,
|
||||
city: 'Jacksonville',
|
||||
lat: 30.3322,
|
||||
lon: -81.6556,
|
||||
},
|
||||
{
|
||||
Name: 'Juneau',
|
||||
Latitude: 58.3019,
|
||||
Longitude: -134.4197,
|
||||
city: 'Juneau',
|
||||
lat: 58.3019,
|
||||
lon: -134.4197,
|
||||
},
|
||||
{
|
||||
Name: 'Kansas City',
|
||||
Latitude: 39.1142,
|
||||
Longitude: -94.6275,
|
||||
city: 'Kansas City',
|
||||
lat: 39.1142,
|
||||
lon: -94.6275,
|
||||
},
|
||||
{
|
||||
Name: 'Key West',
|
||||
Latitude: 24.5557,
|
||||
Longitude: -81.7826,
|
||||
city: 'Key West',
|
||||
lat: 24.5557,
|
||||
lon: -81.7826,
|
||||
},
|
||||
{
|
||||
Name: 'Klamath Falls',
|
||||
Latitude: 42.2249,
|
||||
Longitude: -121.7817,
|
||||
city: 'Klamath Falls',
|
||||
lat: 42.2249,
|
||||
lon: -121.7817,
|
||||
},
|
||||
{
|
||||
Name: 'Knoxville',
|
||||
Latitude: 35.9606,
|
||||
Longitude: -83.9207,
|
||||
city: 'Knoxville',
|
||||
lat: 35.9606,
|
||||
lon: -83.9207,
|
||||
},
|
||||
{
|
||||
Name: 'Las Vegas',
|
||||
Latitude: 36.175,
|
||||
Longitude: -115.1372,
|
||||
city: 'Las Vegas',
|
||||
lat: 36.175,
|
||||
lon: -115.1372,
|
||||
},
|
||||
{
|
||||
Name: 'Lewiston',
|
||||
Latitude: 46.4165,
|
||||
Longitude: -117.0177,
|
||||
city: 'Lewiston',
|
||||
lat: 46.4165,
|
||||
lon: -117.0177,
|
||||
},
|
||||
{
|
||||
Name: 'Lincoln',
|
||||
Latitude: 40.8,
|
||||
Longitude: -96.667,
|
||||
city: 'Lincoln',
|
||||
lat: 40.8,
|
||||
lon: -96.667,
|
||||
},
|
||||
{
|
||||
Name: 'Long Beach',
|
||||
Latitude: 33.767,
|
||||
Longitude: -118.1892,
|
||||
city: 'Long Beach',
|
||||
lat: 33.767,
|
||||
lon: -118.1892,
|
||||
},
|
||||
{
|
||||
Name: 'Louisville',
|
||||
Latitude: 38.2542,
|
||||
Longitude: -85.7594,
|
||||
city: 'Louisville',
|
||||
lat: 38.2542,
|
||||
lon: -85.7594,
|
||||
},
|
||||
{
|
||||
Name: 'Manchester',
|
||||
Latitude: 42.9956,
|
||||
Longitude: -71.4548,
|
||||
city: 'Manchester',
|
||||
lat: 42.9956,
|
||||
lon: -71.4548,
|
||||
},
|
||||
{
|
||||
Name: 'Memphis',
|
||||
Latitude: 35.1495,
|
||||
Longitude: -90.049,
|
||||
city: 'Memphis',
|
||||
lat: 35.1495,
|
||||
lon: -90.049,
|
||||
},
|
||||
{
|
||||
Name: 'Milwaukee',
|
||||
Latitude: 43.0389,
|
||||
Longitude: -87.9065,
|
||||
city: 'Milwaukee',
|
||||
lat: 43.0389,
|
||||
lon: -87.9065,
|
||||
},
|
||||
{
|
||||
Name: 'Mobile',
|
||||
Latitude: 30.6944,
|
||||
Longitude: -88.043,
|
||||
city: 'Mobile',
|
||||
lat: 30.6944,
|
||||
lon: -88.043,
|
||||
},
|
||||
{
|
||||
Name: 'Montgomery',
|
||||
Latitude: 32.3668,
|
||||
Longitude: -86.3,
|
||||
city: 'Montgomery',
|
||||
lat: 32.3668,
|
||||
lon: -86.3,
|
||||
},
|
||||
{
|
||||
Name: 'Montpelier',
|
||||
Latitude: 44.2601,
|
||||
Longitude: -72.5754,
|
||||
city: 'Montpelier',
|
||||
lat: 44.2601,
|
||||
lon: -72.5754,
|
||||
},
|
||||
{
|
||||
Name: 'Nashville',
|
||||
Latitude: 36.1659,
|
||||
Longitude: -86.7844,
|
||||
city: 'Nashville',
|
||||
lat: 36.1659,
|
||||
lon: -86.7844,
|
||||
},
|
||||
{
|
||||
Name: 'Newark',
|
||||
Latitude: 40.7357,
|
||||
Longitude: -74.1724,
|
||||
city: 'Newark',
|
||||
lat: 40.7357,
|
||||
lon: -74.1724,
|
||||
},
|
||||
{
|
||||
Name: 'New Haven',
|
||||
Latitude: 41.3081,
|
||||
Longitude: -72.9282,
|
||||
city: 'New Haven',
|
||||
lat: 41.3081,
|
||||
lon: -72.9282,
|
||||
},
|
||||
{
|
||||
Name: 'New Orleans',
|
||||
Latitude: 29.9546,
|
||||
Longitude: -90.0751,
|
||||
city: 'New Orleans',
|
||||
lat: 29.9546,
|
||||
lon: -90.0751,
|
||||
},
|
||||
{
|
||||
Name: 'Nome',
|
||||
Latitude: 64.5011,
|
||||
Longitude: -165.4064,
|
||||
city: 'Nome',
|
||||
lat: 64.5011,
|
||||
lon: -165.4064,
|
||||
},
|
||||
{
|
||||
Name: 'Oklahoma City',
|
||||
Latitude: 35.4676,
|
||||
Longitude: -97.5164,
|
||||
city: 'Oklahoma City',
|
||||
lat: 35.4676,
|
||||
lon: -97.5164,
|
||||
},
|
||||
{
|
||||
Name: 'Omaha',
|
||||
Latitude: 41.2586,
|
||||
Longitude: -95.9378,
|
||||
city: 'Omaha',
|
||||
lat: 41.2586,
|
||||
lon: -95.9378,
|
||||
},
|
||||
{
|
||||
Name: 'Phoenix',
|
||||
Latitude: 33.4484,
|
||||
Longitude: -112.074,
|
||||
city: 'Phoenix',
|
||||
lat: 33.4484,
|
||||
lon: -112.074,
|
||||
},
|
||||
{
|
||||
Name: 'Pierre',
|
||||
Latitude: 44.3683,
|
||||
Longitude: -100.351,
|
||||
city: 'Pierre',
|
||||
lat: 44.3683,
|
||||
lon: -100.351,
|
||||
},
|
||||
{
|
||||
Name: 'Portland',
|
||||
Latitude: 43.6615,
|
||||
Longitude: -70.2553,
|
||||
city: 'Portland',
|
||||
lat: 43.6615,
|
||||
lon: -70.2553,
|
||||
},
|
||||
{
|
||||
Name: 'Portland',
|
||||
Latitude: 45.5234,
|
||||
Longitude: -122.6762,
|
||||
city: 'Portland',
|
||||
lat: 45.5234,
|
||||
lon: -122.6762,
|
||||
},
|
||||
{
|
||||
Name: 'Providence',
|
||||
Latitude: 41.824,
|
||||
Longitude: -71.4128,
|
||||
city: 'Providence',
|
||||
lat: 41.824,
|
||||
lon: -71.4128,
|
||||
},
|
||||
{
|
||||
Name: 'Raleigh',
|
||||
Latitude: 35.7721,
|
||||
Longitude: -78.6386,
|
||||
city: 'Raleigh',
|
||||
lat: 35.7721,
|
||||
lon: -78.6386,
|
||||
},
|
||||
{
|
||||
Name: 'Reno',
|
||||
Latitude: 39.4986,
|
||||
Longitude: -119.7681,
|
||||
city: 'Reno',
|
||||
lat: 39.4986,
|
||||
lon: -119.7681,
|
||||
},
|
||||
{
|
||||
Name: 'Richfield',
|
||||
Latitude: 38.7725,
|
||||
Longitude: -112.0841,
|
||||
city: 'Richfield',
|
||||
lat: 38.7725,
|
||||
lon: -112.0841,
|
||||
},
|
||||
{
|
||||
Name: 'Richmond',
|
||||
Latitude: 37.5538,
|
||||
Longitude: -77.4603,
|
||||
city: 'Richmond',
|
||||
lat: 37.5538,
|
||||
lon: -77.4603,
|
||||
},
|
||||
{
|
||||
Name: 'Roanoke',
|
||||
Latitude: 37.271,
|
||||
Longitude: -79.9414,
|
||||
city: 'Roanoke',
|
||||
lat: 37.271,
|
||||
lon: -79.9414,
|
||||
},
|
||||
{
|
||||
Name: 'Sacramento',
|
||||
Latitude: 38.5816,
|
||||
Longitude: -121.4944,
|
||||
city: 'Sacramento',
|
||||
lat: 38.5816,
|
||||
lon: -121.4944,
|
||||
},
|
||||
{
|
||||
Name: 'Salt Lake City',
|
||||
Latitude: 40.7608,
|
||||
Longitude: -111.891,
|
||||
city: 'Salt Lake City',
|
||||
lat: 40.7608,
|
||||
lon: -111.891,
|
||||
},
|
||||
{
|
||||
Name: 'San Antonio',
|
||||
Latitude: 29.4241,
|
||||
Longitude: -98.4936,
|
||||
city: 'San Antonio',
|
||||
lat: 29.4241,
|
||||
lon: -98.4936,
|
||||
},
|
||||
{
|
||||
Name: 'San Diego',
|
||||
Latitude: 32.7153,
|
||||
Longitude: -117.1573,
|
||||
city: 'San Diego',
|
||||
lat: 32.7153,
|
||||
lon: -117.1573,
|
||||
},
|
||||
{
|
||||
Name: 'San Jose',
|
||||
Latitude: 37.3394,
|
||||
Longitude: -121.895,
|
||||
city: 'San Jose',
|
||||
lat: 37.3394,
|
||||
lon: -121.895,
|
||||
},
|
||||
{
|
||||
Name: 'Santa Fe',
|
||||
Latitude: 35.687,
|
||||
Longitude: -105.9378,
|
||||
city: 'Santa Fe',
|
||||
lat: 35.687,
|
||||
lon: -105.9378,
|
||||
},
|
||||
{
|
||||
Name: 'Savannah',
|
||||
Latitude: 32.0835,
|
||||
Longitude: -81.0998,
|
||||
city: 'Savannah',
|
||||
lat: 32.0835,
|
||||
lon: -81.0998,
|
||||
},
|
||||
{
|
||||
Name: 'Shreveport',
|
||||
Latitude: 32.5251,
|
||||
Longitude: -93.7502,
|
||||
city: 'Shreveport',
|
||||
lat: 32.5251,
|
||||
lon: -93.7502,
|
||||
},
|
||||
{
|
||||
Name: 'Sioux Falls',
|
||||
Latitude: 43.55,
|
||||
Longitude: -96.7003,
|
||||
city: 'Sioux Falls',
|
||||
lat: 43.55,
|
||||
lon: -96.7003,
|
||||
},
|
||||
{
|
||||
Name: 'Sitka',
|
||||
Latitude: 57.0531,
|
||||
Longitude: -135.33,
|
||||
city: 'Sitka',
|
||||
lat: 57.0531,
|
||||
lon: -135.33,
|
||||
},
|
||||
{
|
||||
Name: 'Spokane',
|
||||
Latitude: 47.6597,
|
||||
Longitude: -117.4291,
|
||||
city: 'Spokane',
|
||||
lat: 47.6597,
|
||||
lon: -117.4291,
|
||||
},
|
||||
{
|
||||
Name: 'Springfield',
|
||||
Latitude: 39.8017,
|
||||
Longitude: -89.6437,
|
||||
city: 'Springfield',
|
||||
lat: 39.8017,
|
||||
lon: -89.6437,
|
||||
},
|
||||
{
|
||||
Name: 'Springfield',
|
||||
Latitude: 42.1015,
|
||||
Longitude: -72.5898,
|
||||
city: 'Springfield',
|
||||
lat: 42.1015,
|
||||
lon: -72.5898,
|
||||
},
|
||||
{
|
||||
Name: 'Springfield',
|
||||
Latitude: 37.2153,
|
||||
Longitude: -93.2982,
|
||||
city: 'Springfield',
|
||||
lat: 37.2153,
|
||||
lon: -93.2982,
|
||||
},
|
||||
{
|
||||
Name: 'Toledo',
|
||||
Latitude: 41.6639,
|
||||
Longitude: -83.5552,
|
||||
city: 'Toledo',
|
||||
lat: 41.6639,
|
||||
lon: -83.5552,
|
||||
},
|
||||
{
|
||||
Name: 'Tulsa',
|
||||
Latitude: 36.154,
|
||||
Longitude: -95.9928,
|
||||
city: 'Tulsa',
|
||||
lat: 36.154,
|
||||
lon: -95.9928,
|
||||
},
|
||||
{
|
||||
Name: 'Virginia Beach',
|
||||
Latitude: 36.8529,
|
||||
Longitude: -75.978,
|
||||
city: 'Virginia Beach',
|
||||
lat: 36.8529,
|
||||
lon: -75.978,
|
||||
},
|
||||
{
|
||||
Name: 'Wichita',
|
||||
Latitude: 37.6922,
|
||||
Longitude: -97.3375,
|
||||
city: 'Wichita',
|
||||
lat: 37.6922,
|
||||
lon: -97.3375,
|
||||
},
|
||||
{
|
||||
Name: 'Wilmington',
|
||||
Latitude: 34.2257,
|
||||
Longitude: -77.9447,
|
||||
city: 'Wilmington',
|
||||
lat: 34.2257,
|
||||
lon: -77.9447,
|
||||
},
|
||||
{
|
||||
Name: 'Tuscan',
|
||||
Latitude: 32.2216,
|
||||
Longitude: -110.9698,
|
||||
city: 'Tuscan',
|
||||
lat: 32.2216,
|
||||
lon: -110.9698,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,7 @@ class LatestObservations extends WeatherDisplay {
|
|||
// calculate distance to each station
|
||||
const stationsByDistance = Object.keys(_StationInfo).map(key => {
|
||||
const station = _StationInfo[key];
|
||||
const distance = utils.calc.distance(station.Latitude, station.Longitude, weatherParameters.latitude, weatherParameters.longitude);
|
||||
const distance = utils.calc.distance(station.lat, station.lon, weatherParameters.latitude, weatherParameters.longitude);
|
||||
return Object.assign({}, station, {distance});
|
||||
});
|
||||
|
||||
|
@ -33,17 +33,17 @@ class LatestObservations extends WeatherDisplay {
|
|||
try {
|
||||
const data = await $.ajax({
|
||||
type: 'GET',
|
||||
url: `https://api.weather.gov/stations/${station.StationId}/observations/latest`,
|
||||
url: `https://api.weather.gov/stations/${station.id}/observations/latest`,
|
||||
dataType: 'json',
|
||||
crossDomain: true,
|
||||
});
|
||||
// format the return values
|
||||
return Object.assign({}, data.properties, {
|
||||
StationId: station.StationId,
|
||||
City: station.City,
|
||||
StationId: station.id,
|
||||
city: station.city,
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(`Unable to get latest observations for ${station.StationId}`);
|
||||
console.log(`Unable to get latest observations for ${station.id}`);
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
@ -95,7 +95,7 @@ class LatestObservations extends WeatherDisplay {
|
|||
WindSpeed = utils.units.kphToMph(WindSpeed);
|
||||
}
|
||||
|
||||
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 65, y, condition.City.substr(0, 14), 2);
|
||||
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 65, y, condition.city.substr(0, 14), 2);
|
||||
draw.text(this.context, 'Star4000', '24pt', '#FFFFFF', 345, y, this.shortenCurrentConditions(condition.textDescription).substr(0, 9), 2);
|
||||
|
||||
if (WindSpeed > 0) {
|
||||
|
|
|
@ -69,7 +69,7 @@ const navigation = (() => {
|
|||
let city = point.properties.relativeLocation.properties.city;
|
||||
|
||||
if (StationId in _StationInfo) {
|
||||
city = _StationInfo[StationId].City;
|
||||
city = _StationInfo[StationId].city;
|
||||
city = city.split('/')[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class RegionalForecast extends WeatherDisplay {
|
|||
if (weatherParameters.State === 'HI') targetDistance = 1;
|
||||
|
||||
// make station info into an array
|
||||
const stationInfoArray = Object.keys(_StationInfo).map(key => Object.assign({}, _StationInfo[key], {Name: _StationInfo[key].City, targetDistance}));
|
||||
const stationInfoArray = Object.keys(_StationInfo).map(key => Object.assign({}, _StationInfo[key], {targetDistance}));
|
||||
// combine regional cities with station info for additional stations
|
||||
// stations are intentionally after cities to allow cities priority when drawing the map
|
||||
const combinedCities = [..._RegionalCities, ...stationInfoArray];
|
||||
|
@ -52,13 +52,13 @@ class RegionalForecast extends WeatherDisplay {
|
|||
// Determine which cities are within the max/min latitude/longitude.
|
||||
const regionalCities = [];
|
||||
combinedCities.forEach(city => {
|
||||
if (city.Latitude > minMaxLatLon.minLat && city.Latitude < minMaxLatLon.maxLat &&
|
||||
city.Longitude > minMaxLatLon.minLon && city.Longitude < minMaxLatLon.maxLon - 1) {
|
||||
if (city.lat > minMaxLatLon.minLat && city.lat < minMaxLatLon.maxLat &&
|
||||
city.lon > minMaxLatLon.minLon && city.lon < minMaxLatLon.maxLon - 1) {
|
||||
// default to 1 for cities loaded from _RegionalCities, use value calculate above for remaining stations
|
||||
const targetDistance = city.targetDistance || 1;
|
||||
// Only add the city as long as it isn't within set distance degree of any other city already in the array.
|
||||
const okToAddCity = regionalCities.reduce((acc, testCity) => {
|
||||
const distance = utils.calc.distance(city.Longitude, city.Latitude, testCity.Longitude, testCity.Latitude);
|
||||
const distance = utils.calc.distance(city.lon, city.lat, testCity.lon, testCity.lat);
|
||||
return acc && distance >= targetDistance;
|
||||
}, true);
|
||||
if (okToAddCity) regionalCities.push(city);
|
||||
|
@ -69,7 +69,7 @@ class RegionalForecast extends WeatherDisplay {
|
|||
const regionalForecastPromises = regionalCities.map(async city => {
|
||||
try {
|
||||
// get the point first, then break down into forecast and observations
|
||||
const point = await utils.weather.getPoint(city.Latitude, city.Longitude);
|
||||
const point = await utils.weather.getPoint(city.lat, city.lon);
|
||||
|
||||
// start off the observation task
|
||||
const observationPromise = this.getRegionalObservation(point, city);
|
||||
|
@ -89,7 +89,7 @@ class RegionalForecast extends WeatherDisplay {
|
|||
const regionalObservation = {
|
||||
daytime: !!observation.icon.match(/\/day\//),
|
||||
temperature: utils.units.celsiusToFahrenheit(observation.temperature.value),
|
||||
name: city.Name,
|
||||
name: this.formatCity(city.city),
|
||||
icon: observation.icon,
|
||||
x: cityXY.x,
|
||||
y: cityXY.y,
|
||||
|
@ -140,7 +140,7 @@ class RegionalForecast extends WeatherDisplay {
|
|||
return {
|
||||
daytime: forecast.isDaytime,
|
||||
temperature: forecast.temperature||0,
|
||||
name: city.Name,
|
||||
name: city.city,
|
||||
icon: forecast.icon,
|
||||
x: cityXY.x,
|
||||
y: cityXY.y,
|
||||
|
@ -294,8 +294,8 @@ class RegionalForecast extends WeatherDisplay {
|
|||
getXYForCity (City, MaxLatitude, MinLongitude, state) {
|
||||
if (state === 'AK') this.getXYForCityAK(...arguments);
|
||||
if (state === 'HI') this.getXYForCityHI(...arguments);
|
||||
let x = (City.Longitude - MinLongitude) * 57;
|
||||
let y = (MaxLatitude - City.Latitude) * 70;
|
||||
let x = (City.lon - MinLongitude) * 57;
|
||||
let y = (MaxLatitude - City.lat) * 70;
|
||||
|
||||
if (y < 30) y = 30;
|
||||
if (y > 282) y = 282;
|
||||
|
@ -307,8 +307,8 @@ class RegionalForecast extends WeatherDisplay {
|
|||
}
|
||||
|
||||
getXYForCityAK (City, MaxLatitude, MinLongitude) {
|
||||
let x = (City.Longitude - MinLongitude) * 37;
|
||||
let y = (MaxLatitude - City.Latitude) * 70;
|
||||
let x = (City.lon - MinLongitude) * 37;
|
||||
let y = (MaxLatitude - City.lat) * 70;
|
||||
|
||||
if (y < 30) y = 30;
|
||||
if (y > 282) y = 282;
|
||||
|
@ -319,8 +319,8 @@ class RegionalForecast extends WeatherDisplay {
|
|||
}
|
||||
|
||||
getXYForCityHI (City, MaxLatitude, MinLongitude) {
|
||||
let x = (City.Longitude - MinLongitude) * 57;
|
||||
let y = (MaxLatitude - City.Latitude) * 70;
|
||||
let x = (City.lon - MinLongitude) * 57;
|
||||
let y = (MaxLatitude - City.lat) * 70;
|
||||
|
||||
if (y < 30) y = 30;
|
||||
if (y > 282) y = 282;
|
||||
|
@ -331,6 +331,11 @@ class RegionalForecast extends WeatherDisplay {
|
|||
return { x, y };
|
||||
}
|
||||
|
||||
// to fit on the map, remove anything after punctuation and then limit to 15 characters
|
||||
formatCity(city) {
|
||||
return city.match(/[^-;/\\,]*/)[0].substr(0,12)
|
||||
}
|
||||
|
||||
async drawCanvas() {
|
||||
super.drawCanvas();
|
||||
// break up data into useful values
|
||||
|
|
Loading…
Reference in a new issue