fix wrong weather evaluation

master
root 2 years ago
parent d0261bb713
commit 3a92b4d3ae

@ -36,17 +36,18 @@
</td>
<td><?=e(round($line['rain'], 1))?>mm</td>
<td class="pictogram"><?=($line['icon'])?></td>
<?php
$classmap = [
'Y' => 'flying-weather',
'M' => 'maybe-flying-weather',
'N' => ''
];
?>
<td class="pictogram">
<?php $class = $line['riding'] === 'Y' ? 'flying-weather'
: $line['riding'] === 'M' ? 'maybe-flying-weather'
: '' ?>
<span class="<?=$class?>"><?=e($line['ridingIcon'])?></span>
<span class="<?=$classmap[$line['riding']]?>"><?=e($line['ridingIcon'])?></span>
</td>
<td class="pictogram">
<?php $class = $line['flying'] === 'Y' ? 'flying-weather'
: $line['flying'] === 'M' ? 'maybe-flying-weather'
: '' ?>
<span class="<?=$class?>"><?=e($line['flyingIcon'])?></span>
<span class="<?=$classmap[$line['flying']]?>"><?=e($line['flyingIcon'])?></span>
</td>
<td><?=e($line['wind'])?>m/s</td>
<td><?=e(round($line['temp'], 1))?>°C</td>

@ -76,16 +76,25 @@ foreach ($data->list as $line) {
$rain = ($rainArr['3h'] ?? 0) + ($snowArr['3h'] ?? 0);
$wind = $line->wind->speed;
$flying = $rain === 0 && $wind < 2.5 ? 'Y'
: $rain <= 0.3 && $wind < 3.1 ? 'M'
: 'N';
$flying = 'N';
if ($rain === 0 && $wind < 2.5) {
$flying = 'Y';
} elseif ($rain <= 0.3 && $wind < 3.1) {
$flying = 'M';
}
$flyingIcon = $flying === 'Y' ? "🛩"
: $flying === 'M' ? "🛩"
: '⏚';
$riding = $rain === 0 && $temp > 15 ? 'Y'
: $rain <= 0.3 && $temp > 10 ? 'M'
: 'N';
$riding = 'N';
if ($rain === 0 && $temp > 15) {
$riding = 'Y';
} elseif ($rain <= 0.3 && $temp > 10) {
$riding = 'M';
}
$ridingIcon = $riding === 'Y' ? "🏍"
: $riding === 'M' ? "🏍"
: "🚳";

Loading…
Cancel
Save