Skip to content

Commit

Permalink
Fixes capitalization to match types
Browse files Browse the repository at this point in the history
Fixes the merge conflict with select station list and time zone code
  • Loading branch information
eireland committed Jan 26, 2024
1 parent ef06c13 commit eaeda88
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 43 deletions.
75 changes: 36 additions & 39 deletions src/components/location-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
8 changes: 4 additions & 4 deletions src/utils/noaaDataTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
}),
Expand All @@ -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}),
Expand Down

0 comments on commit eaeda88

Please sign in to comment.