Skip to content

Commit

Permalink
Support for hourly weathercode
Browse files Browse the repository at this point in the history
  • Loading branch information
rocksdanister committed Oct 5, 2023
1 parent aff5107 commit af51632
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Drizzle.Models/Weather/DailyWeather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 3 additions & 0 deletions src/Drizzle.Models/WeatherModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public partial class WeatherModel : ObservableObject
[ObservableProperty]
private float temperature;

[ObservableProperty]
private int[] hourlyWeatherCode;

[ObservableProperty]
private float[] hourlyTemp;

Expand Down
1 change: 1 addition & 0 deletions src/Drizzle.UI.UWP/Factories/WeatherViewModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/Drizzle.Weather/OpenMeteoWeatherClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public async Task<ForecastWeather> 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(),
Expand Down

0 comments on commit af51632

Please sign in to comment.