feat: uuroverzicht per dag (temperatuur, regen, wind)
Tik op een dag in de verwachtingsstrook voor een uuroverzicht van
temperatuur, regen en wind (richting + snelheid), om de 2 uur, 12
punten per dag. Sluit na 20 seconden vanzelf of bij een tik op de
overlay zelf.
Backend: Open-Meteo levert hourly-data in dezelfde call als daily
(geen extra verzoek, dezelfde 60min-cache). Nieuwe HourlyForecastMapper
groepeert per kalenderdatum en bemonstert om het andere uur, robuust
voor de zomertijddag (23/25 uur). OpenMeteoClient::dailyForecast()
hernoemd naar forecast(), geeft nu {daily, hourly} terug. Elke dag in
de forecast-array krijgt een hourly-lijst.
Frontend: temperatuurlijn hergebruikt sparklinePath (nu ook als
sparklinePoints voor exacte uitlijning met de 12-koloms grid), regen
als kleine staafjes, windpijl (nieuw icoon) wijst waarheen de wind
waait. 20s-balk via CSS transition met reflow-restart. Servicewerker
naar v5.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+37
-8
@@ -69,17 +69,46 @@ final class FixtureSource implements WeatherSource
|
||||
|
||||
public function forecast(float $lat, float $lon, string $timezone): array
|
||||
{
|
||||
$tmin = [11.0, 10.1, 11.3, 12.0, 9.4, 8.1];
|
||||
$tmax = [17.9, 18.3, 20.1, 17.4, 15.2, 16.0];
|
||||
$precipDay = [0.0, 0.4, 0.0, 8.2, 3.1, 0.2];
|
||||
|
||||
$dates = [];
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
$dates[] = $this->now->modify("+$i days")->format('Y-m-d');
|
||||
$hourlyTime = [];
|
||||
$hourlyTemp = [];
|
||||
$hourlyPrecip = [];
|
||||
$hourlyWind = [];
|
||||
$hourlyDir = [];
|
||||
for ($d = 0; $d < 6; $d++) {
|
||||
$day = $this->now->modify("+$d days");
|
||||
$dates[] = $day->format('Y-m-d');
|
||||
for ($h = 0; $h < 24; $h++) {
|
||||
$hourlyTime[] = $day->setTime($h, 0)->format('Y-m-d\TH:i');
|
||||
$t = $tmin[$d] + ($tmax[$d] - $tmin[$d]) * (0.5 + 0.5 * sin((($h - 9) / 24) * 2 * M_PI));
|
||||
$hourlyTemp[] = round($t, 1);
|
||||
$p = ($precipDay[$d] > 0 && $h >= 14 && $h <= 16) ? round($precipDay[$d] / 3, 1) : 0.0;
|
||||
$hourlyPrecip[] = $p;
|
||||
$hourlyWind[] = round(3 + 6 * (0.5 + 0.5 * sin((($h + $d * 3) / 24) * 2 * M_PI)), 1);
|
||||
$hourlyDir[] = ($d * 40 + $h * 7) % 360;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'time' => $dates,
|
||||
'weather_code' => [3, 2, 0, 61, 80, 95],
|
||||
'temperature_2m_max' => [17.9, 18.3, 20.1, 17.4, 15.2, 16.0],
|
||||
'temperature_2m_min' => [11.0, 10.1, 11.3, 12.0, 9.4, 8.1],
|
||||
'precipitation_sum' => [0.0, 0.4, 0.0, 8.2, 3.1, 0.2],
|
||||
'precipitation_probability_max' => [10, 20, 5, 80, 60, 15],
|
||||
'daily' => [
|
||||
'time' => $dates,
|
||||
'weather_code' => [3, 2, 0, 61, 80, 95],
|
||||
'temperature_2m_max' => $tmax,
|
||||
'temperature_2m_min' => $tmin,
|
||||
'precipitation_sum' => $precipDay,
|
||||
'precipitation_probability_max' => [10, 20, 5, 80, 60, 15],
|
||||
],
|
||||
'hourly' => [
|
||||
'time' => $hourlyTime,
|
||||
'temperature_2m' => $hourlyTemp,
|
||||
'precipitation' => $hourlyPrecip,
|
||||
'wind_speed_10m' => $hourlyWind,
|
||||
'wind_direction_10m' => $hourlyDir,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user