From eaeda88bfce390b07a5105dd9cc0f9d79180d3a4 Mon Sep 17 00:00:00 2001 From: eireland Date: Fri, 26 Jan 2024 09:50:04 -0800 Subject: [PATCH] Fixes capitalization to match types Fixes the merge conflict with select station list and time zone code --- src/components/location-picker.tsx | 75 ++++++++++++++---------------- src/utils/noaaDataTypes.ts | 8 ++-- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/src/components/location-picker.tsx b/src/components/location-picker.tsx index e7826f6..9a86307 100644 --- a/src/components/location-picker.tsx +++ b/src/components/location-picker.tsx @@ -68,49 +68,46 @@ export const LocationPicker = () => { }, [isEditing]); useEffect(() => { -<<<<<<< HEAD const _startDate = startDate ? startDate : new Date( -5364662060); // 1/1/1750 const _endDate = endDate ? endDate : new Date(Date.now()); - if (location) { - findNearestActiveStations(location.latitude, location.longitude, _startDate, _endDate) - .then((stationList: IStation[]) => { - if (stationList) { - setStationPossibilities(stationList); - (isEditing && stationList.length > 0) && setShowSelectionList(true); - } + if (location) { + findNearestActiveStations(location.latitude, location.longitude, _startDate, _endDate) + .then((stationList: IStation[]) => { + if (stationList) { + setStationPossibilities(stationList); + (isEditing && stationList.length > 0) && setShowSelectionList(true); + } + setState((draft) => { + draft.weatherStation = stationList[0].station; + draft.weatherStationDistance = stationList[0].distance; + }); + }); + const fetchTimezone = async (lat: number, long: number) => { + let url = `${timezoneServiceURL}?lat=${lat}&lng=${long}&username=${geonamesUser}`; + let res = await fetch(url); + if (res) { + if (res.ok) { + const timezoneData = await res.json(); + const { gmtOffset } = timezoneData as { gmtOffset: keyof typeof kOffsetMap }; setState((draft) => { - draft.weatherStation = stationList[0].station; - draft.weatherStationDistance = stationList[0].distance; - }); - }); - const fetchTimezone = async (lat: number, long: number) => { - let url = `${timezoneServiceURL}?lat=${lat}&lng=${long}&username=${geonamesUser}`; - let res = await fetch(url); - if (res) { - if (res.ok) { - const timezoneData = await res.json(); - const { gmtOffset } = timezoneData as { gmtOffset: keyof typeof kOffsetMap }; - setState((draft) => { - draft.timezone = { - gmtOffset, - name: kOffsetMap[gmtOffset] - }; - }); - } else { - console.warn(res.statusText); - } - } else { - console.warn(`Failed to fetch timezone data for ${location}`); - } + draft.timezone = { + gmtOffset, + name: kOffsetMap[gmtOffset] }; - fetchTimezone(location.latitude, location.longitude); - } - }); - } else { - setState((draft) => { - draft.timezone = undefined; - }); - } + }); + } else { + console.warn(res.statusText); + } + } else { + console.warn(`Failed to fetch timezone data for ${location}`); + } + }; + fetchTimezone(location.latitude, location.longitude); + } else { + setState((draft) => { + draft.timezone = undefined; + }); + } // eslint-disable-next-line react-hooks/exhaustive-deps },[endDate, isEditing, location, startDate]); diff --git a/src/utils/noaaDataTypes.ts b/src/utils/noaaDataTypes.ts index e86c284..f8eabb6 100644 --- a/src/utils/noaaDataTypes.ts +++ b/src/utils/noaaDataTypes.ts @@ -136,7 +136,7 @@ const dataTypes = [ ["daily-summaries", "global-summary-of-the-month"]), new NoaaType("SNOW", "snow", kUnitTypePrecip, "Snowfall", ["daily-summaries", "global-summary-of-the-month"]), - new NoaaType("AWND", "avgWind", kUnitTypeSpeed, "Average windspeed", + new NoaaType("AWND", "avgWind", kUnitTypeSpeed, "Average wind speed", ["daily-summaries", "global-summary-of-the-month"], { "GHCND" (v: number) {return v/10;}, "GSOM" (v) {return v/10;} }), @@ -145,13 +145,13 @@ const dataTypes = [ new NoaaType("SLP", "pressure", kUnitTypePressure, "Barometric Pressure at sea level", ["global-hourly"], {"global-hourly": extractHourlyPressure}), - new NoaaType("TMP", "temp", kUnitTypeTemp, "Air Temperature", + new NoaaType("TMP", "temp", kUnitTypeTemp, "Air temperature", ["global-hourly"], {"global-hourly": extractHourlyTemp}), new NoaaType("VIS", "vis", kUnitTypeDistance, "Visibility", ["global-hourly"], {"global-hourly": extractHourlyVisibility}), - new NoaaType("WND", "WDir", kUnitTypeAngle, "Wind Direction", + new NoaaType("WND", "WDir", kUnitTypeAngle, "Wind direction", ["global-hourly"], {"global-hourly": extractHourlyWindDirection}), - new NoaaType("WND", "wSpeed", kUnitTypeSpeed, "Wind Speed", + new NoaaType("WND", "wSpeed", kUnitTypeSpeed, "Wind speed", ["global-hourly"], {"global-hourly": extractHourlyWindspeed}), new NoaaType("AA1", "precip", kUnitTypePrecip, "Precipitation in last hour", ["global-hourly"], {"global-hourly": extractHourlyPrecipitation}),