Closed anevaiopvn closed 1 year ago
see discussion here
They always show the worst case and I don't like it either. I think about evaluating the hourly codes between surise and sunset and upgrade them if e.g > 20% contain sun
Please try this. This checks the codes between sunrise and sunset and changes IDs if more than 20% sun. There is a switch in settings to switch on/off. After changing the switch click on refresh.
private List<WeekForecast> reanalyzeWeekIDs(List<WeekForecast> weekforecasts, List<HourlyForecast> hourlyforecasts) {
Map<Integer,Integer> mappingTable = new HashMap<>();
mappingTable.put(WeatherCategories.OVERCAST_CLOUDS.getNumVal(),WeatherCategories.SCATTERED_CLOUDS.getNumVal());
mappingTable.put(WeatherCategories.MIST.getNumVal(),WeatherCategories.SCATTERED_CLOUDS.getNumVal());
mappingTable.put(WeatherCategories.DRIZZLE_RAIN.getNumVal(),WeatherCategories.LIGHT_SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.FREEZING_DRIZZLE_RAIN.getNumVal(),WeatherCategories.LIGHT_SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.LIGHT_RAIN.getNumVal(),WeatherCategories.LIGHT_SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.LIGHT_FREEZING_RAIN.getNumVal(),WeatherCategories.LIGHT_SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.MODERATE_RAIN.getNumVal(),WeatherCategories.SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.HEAVY_RAIN.getNumVal(),WeatherCategories.SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.FREEZING_RAIN.getNumVal(),WeatherCategories.SHOWER_RAIN.getNumVal());
mappingTable.put(WeatherCategories.LIGHT_SNOW.getNumVal(),WeatherCategories.LIGHT_SHOWER_SNOW.getNumVal());
mappingTable.put(WeatherCategories.MODERATE_SNOW.getNumVal(),WeatherCategories.SHOWER_SNOW.getNumVal());
mappingTable.put(WeatherCategories.HEAVY_SNOW.getNumVal(),WeatherCategories.SHOWER_SNOW.getNumVal());
Map<Integer,Integer> sunTable = new HashMap<>();
sunTable.put(WeatherCategories.CLEAR_SKY.getNumVal(), 0);
sunTable.put(WeatherCategories.FEW_CLOUDS.getNumVal(), 0);
sunTable.put(WeatherCategories.SCATTERED_CLOUDS.getNumVal(), 0);
for (WeekForecast weekForecast: weekforecasts){
Integer ID = weekForecast.getWeatherID();
if (mappingTable.containsKey(ID)){
int totalCount = 0;
int sunCount = 0;
long sunrise = weekForecast.getTimeSunrise()*1000L;
long sunset = weekForecast.getTimeSunset()*1000L;
for (HourlyForecast hourlyForecast: hourlyforecasts){
if(hourlyForecast.getForecastTime() >= sunrise && hourlyForecast.getForecastTime() <= sunset){
totalCount++;
if(sunTable.containsKey(hourlyForecast.getWeatherID())) sunCount++;
}
}
if (totalCount>0 && (float)sunCount/totalCount>0.2f) weekForecast.setWeatherID(mappingTable.get(ID));
}
}
return weekforecasts;
}
Yeah, that's much better in my opinion, thank you!
However I do wonder if you should change the behavior from [sunrise till sunset] to a fixed time. People in the more polar parts of the globe have only so much sunlight which means that setting is basically broken for them. Maybe use something like 7 am to 7pm or 6am to 9pm or something more general that works for most people. Or maybe even 5 am to 12 pm which would cover almost the whole day but only leave out the couple of midnight hours. I know that's a bit arbitrary but it would make the most sense for most people I would think.
EDIT: and it's really not only the people who live in the polar parts of the Earth. I believe almost no one actually lives with the Sun as their clock really.
I will maybe add a setting in future
It seems to me that currently the week section inside the app shows the most cloudy weather of the day as the icon for the day. For example, if on Thursday there is one hour of clouds say at 2 am, and the rest of the day is sunshine, the icon for Thursday would show Clouds as the icon for the whole day. This makes that icon basically unreliable.
Would it be possible to change the behavior so that the icon for the whole day would be maybe some kind of average for the day (or possibly even the daytime hours)?