diff options
author | Frankie B <git@diskfloppy.me> | 2023-06-17 13:58:08 +0100 |
---|---|---|
committer | Frankie B <git@diskfloppy.me> | 2023-06-17 13:58:08 +0100 |
commit | 01c617250ca321fcb59aea416add079b8a556a6d (patch) | |
tree | 012a7b6661beb44ba832e4466c80c079de845ae8 /resources/views/components/weather.blade.php | |
parent | e6230427c09a0031eb07ac9e6bdee95ece4b60d9 (diff) |
fix: correct degreesToCompassDirection function
Diffstat (limited to 'resources/views/components/weather.blade.php')
-rw-r--r-- | resources/views/components/weather.blade.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/resources/views/components/weather.blade.php b/resources/views/components/weather.blade.php index b29ccc9..134ea11 100644 --- a/resources/views/components/weather.blade.php +++ b/resources/views/components/weather.blade.php @@ -1,9 +1,10 @@ @php function degreesToCompassDirection($degrees) { - $cardinalDirections = array('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N'); - $degreesPerDirection = 360 / count($cardinalDirections); - $index = round($degrees / $degreesPerDirection); - return $cardinalDirections[$index]; + $cardinalDirections = [ + 'N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', + 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N' + ]; + return $cardinalDirections[round($degrees*16/360)]; } $data = json_decode(file_get_contents('http://weather.diskfloppy.me/data/weatherData.json')); |