fix wrong weather evaluation

master
root 2 years ago
parent d0261bb713
commit 3a92b4d3ae

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

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

Loading…
Cancel
Save