mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 17:19:30 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bd21bcf1d | ||
|
|
ec65025ae2 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "6.5.1",
|
"version": "6.5.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "6.5.1",
|
"version": "6.5.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^17.0.1",
|
"dotenv": "^17.0.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "6.5.1",
|
"version": "6.5.2",
|
||||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||||
"main": "index.mjs",
|
"main": "index.mjs",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const buildForecast = (forecast, city, cityXY) => {
|
|||||||
const getRegionalObservation = async (point, city) => {
|
const getRegionalObservation = async (point, city) => {
|
||||||
try {
|
try {
|
||||||
// get stations using centralized safe handling
|
// get stations using centralized safe handling
|
||||||
const stations = await safeJson(`https://api.weather.gov/gridpoints/${point.wfo}/${point.x},${point.y}/stations?limit=1`);
|
const stations = await safeJson(`https://api.weather.gov/gridpoints/${point.wfo}/${point.x},${point.y}/stations?limit=10`);
|
||||||
|
|
||||||
if (!stations || !stations.features || stations.features.length === 0) {
|
if (!stations || !stations.features || stations.features.length === 0) {
|
||||||
if (debugFlag('verbose-failures')) {
|
if (debugFlag('verbose-failures')) {
|
||||||
@@ -32,9 +32,13 @@ const getRegionalObservation = async (point, city) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the first station
|
// get the first station with a 4-letter id (generally has appropriate data)
|
||||||
const station = stations.features[0].id;
|
const station4Letter = stations.features.find((station) => {
|
||||||
const stationId = stations.features[0].properties.stationIdentifier;
|
if (station.properties.stationIdentifier.length === 4) return station.properties;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
const station = station4Letter.id;
|
||||||
|
const stationId = station4Letter.properties.stationIdentifier;
|
||||||
// get the observation data using centralized safe handling
|
// get the observation data using centralized safe handling
|
||||||
const observation = await safeJson(`${station}/observations/latest`);
|
const observation = await safeJson(`${station}/observations/latest`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user