prepare for using properties.weather for better hourly icons
This commit is contained in:
parent
e031830654
commit
dc58647302
|
@ -1,3 +1,4 @@
|
||||||
[1016/115344.136:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
[1016/115344.136:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
||||||
[1020/120229.281:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
[1020/120229.281:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
||||||
[1020/192548.246:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
[1020/192548.246:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
||||||
|
[1026/100236.922:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
|
||||||
|
|
|
@ -50,12 +50,12 @@ class Hourly extends WeatherDisplay {
|
||||||
const windSpeed = this.expand(data.windSpeed.values);
|
const windSpeed = this.expand(data.windSpeed.values);
|
||||||
const windDirection = this.expand(data.windDirection.values);
|
const windDirection = this.expand(data.windDirection.values);
|
||||||
const skyCover = this.expand(data.skyCover.values); // cloud icon
|
const skyCover = this.expand(data.skyCover.values); // cloud icon
|
||||||
const visibility = this.expand(data.visibility.values); // fog icon
|
const weather = this.expand(data.weather.values); // fog icon
|
||||||
const iceAccumulation = this.expand(data.iceAccumulation.values); // ice icon
|
const iceAccumulation = this.expand(data.iceAccumulation.values); // ice icon
|
||||||
const probabilityOfPrecipitation = this.expand(data.probabilityOfPrecipitation.values); // rain icon
|
const probabilityOfPrecipitation = this.expand(data.probabilityOfPrecipitation.values); // rain icon
|
||||||
const snowfallAmount = this.expand(data.snowfallAmount.values); // snow icon
|
const snowfallAmount = this.expand(data.snowfallAmount.values); // snow icon
|
||||||
|
|
||||||
const icons = await this.determineIcon(skyCover, visibility, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed);
|
const icons = await this.determineIcon(skyCover, weather, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed);
|
||||||
|
|
||||||
return temperature.map((val, idx) => {
|
return temperature.map((val, idx) => {
|
||||||
if (navigation.units === UNITS.metric) return {
|
if (navigation.units === UNITS.metric) return {
|
||||||
|
@ -78,7 +78,7 @@ class Hourly extends WeatherDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
// given forecast paramaters determine a suitable icon
|
// given forecast paramaters determine a suitable icon
|
||||||
async determineIcon(skyCover, visibility, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed) {
|
async determineIcon(skyCover, weather, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed) {
|
||||||
const startOfHour = luxon.DateTime.local().startOf('hour');
|
const startOfHour = luxon.DateTime.local().startOf('hour');
|
||||||
const sunTimes = (await navigation.getSun()).sun;
|
const sunTimes = (await navigation.getSun()).sun;
|
||||||
const overnight = luxon.Interval.fromDateTimes(luxon.DateTime.fromJSDate(sunTimes[0].sunset), luxon.DateTime.fromJSDate(sunTimes[1].sunrise));
|
const overnight = luxon.Interval.fromDateTimes(luxon.DateTime.fromJSDate(sunTimes[0].sunset), luxon.DateTime.fromJSDate(sunTimes[1].sunrise));
|
||||||
|
@ -86,7 +86,7 @@ class Hourly extends WeatherDisplay {
|
||||||
return skyCover.map((val, idx) => {
|
return skyCover.map((val, idx) => {
|
||||||
const hour = startOfHour.plus({hours: idx});
|
const hour = startOfHour.plus({hours: idx});
|
||||||
const isNight = overnight.contains(hour) || (hour > tomorrowOvernight);
|
const isNight = overnight.contains(hour) || (hour > tomorrowOvernight);
|
||||||
return icons.getHourlyIcon(skyCover[idx], visibility[idx], iceAccumulation[idx], probabilityOfPrecipitation[idx], snowfallAmount[idx], windSpeed[idx], isNight);
|
return icons.getHourlyIcon(skyCover[idx], weather[idx], iceAccumulation[idx], probabilityOfPrecipitation[idx], snowfallAmount[idx], windSpeed[idx], isNight);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ const icons = (() => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getHourlyIcon = (skyCover, visibility, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed, isNight = false) => {
|
const getHourlyIcon = (skyCover, weather, iceAccumulation, probabilityOfPrecipitation, snowfallAmount, windSpeed, isNight = false) => {
|
||||||
// internal function to add path to returned icon
|
// internal function to add path to returned icon
|
||||||
const addPath = (icon) => `images/r/${icon}`;
|
const addPath = (icon) => `images/r/${icon}`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue