From af51632fe16fe9e9e00455b3f7c458da0593590b Mon Sep 17 00:00:00 2001 From: Dani John Date: Thu, 5 Oct 2023 20:50:53 +0530 Subject: [PATCH] Support for hourly weathercode --- src/Drizzle.Models/Weather/DailyWeather.cs | 2 ++ src/Drizzle.Models/WeatherModel.cs | 3 +++ src/Drizzle.UI.UWP/Factories/WeatherViewModelFactory.cs | 1 + src/Drizzle.Weather/OpenMeteoWeatherClient.cs | 1 + 4 files changed, 7 insertions(+) diff --git a/src/Drizzle.Models/Weather/DailyWeather.cs b/src/Drizzle.Models/Weather/DailyWeather.cs index 34d1936..06d91dc 100644 --- a/src/Drizzle.Models/Weather/DailyWeather.cs +++ b/src/Drizzle.Models/Weather/DailyWeather.cs @@ -38,6 +38,8 @@ public class DailyWeather public DateTime Sunset { get; set; } + public int[] HourlyWeatherCode { get; set; } + public float[] HourlyTemperature { get; set; } public float[] HourlyVisibility { get; set; } diff --git a/src/Drizzle.Models/WeatherModel.cs b/src/Drizzle.Models/WeatherModel.cs index 2aaa67f..bf91a22 100644 --- a/src/Drizzle.Models/WeatherModel.cs +++ b/src/Drizzle.Models/WeatherModel.cs @@ -22,6 +22,9 @@ public partial class WeatherModel : ObservableObject [ObservableProperty] private float temperature; + [ObservableProperty] + private int[] hourlyWeatherCode; + [ObservableProperty] private float[] hourlyTemp; diff --git a/src/Drizzle.UI.UWP/Factories/WeatherViewModelFactory.cs b/src/Drizzle.UI.UWP/Factories/WeatherViewModelFactory.cs index 58f64e0..147cdb0 100644 --- a/src/Drizzle.UI.UWP/Factories/WeatherViewModelFactory.cs +++ b/src/Drizzle.UI.UWP/Factories/WeatherViewModelFactory.cs @@ -52,6 +52,7 @@ public WeatherViewModel CreateWeatherViewModel( Pressure = weatherForecast.Daily[i].Pressure, PressureUnit = weatherForecast.Units.PressureUnit, DewPoint = weatherForecast.Daily[i].DewPoint, + HourlyWeatherCode = weatherForecast.Daily[i].HourlyWeatherCode, HourlyTemp = weatherForecast.Daily[i].HourlyTemperature, HourlyVisibility = weatherForecast.Daily[i].HourlyVisibility, HourlyHumidity = weatherForecast.Daily[i].HourlyHumidity, diff --git a/src/Drizzle.Weather/OpenMeteoWeatherClient.cs b/src/Drizzle.Weather/OpenMeteoWeatherClient.cs index b0b4d5b..15380ea 100644 --- a/src/Drizzle.Weather/OpenMeteoWeatherClient.cs +++ b/src/Drizzle.Weather/OpenMeteoWeatherClient.cs @@ -114,6 +114,7 @@ public async Task QueryForecastAsync(float latitude, float long DewPoint = dailyDewPoint[i], Pressure = dailyPressure[i], WindDirection = response.Daily.Winddirection_10m_dominant[i], + HourlyWeatherCode = response.Hourly.Weathercode.Select(x => x is null ? 0 : (int)x).Skip(i * 24).Take(24).ToArray(), HourlyTemperature = response.Hourly.Temperature_2m.Select(x => x is null ? 0 : (float)x).Skip(i * 24).Take(24).ToArray(), HourlyVisibility = response.Hourly.Visibility.Select(x => x is null ? 0 : (float)x/1000).Skip(i * 24).Take(24).ToArray(), HourlyHumidity = response.Hourly.Relativehumidity_2m.Select(x => x is null ? 0 : (float)x).Skip(i * 24).Take(24).ToArray(),