Windrichtung als Text ausgeben

Dieses PHP-Script gibt die Windrichtung als Text aus. Der Eingabewert entspricht einer Windrichtung in Grad (0-360). Der Wert „VRB“ stammt aus dem METAR-Format und steht für variable/sich verändernde Windrichtungen.

<?php
/*
    This Software returns text by given wind angle value.

    Copyright (C) 2020 Guido Richter / tintenkobold.de

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License [http://www.gnu.org/licenses/] for more details.
*/

function windangle_to_text($angle)
{
    if($angle=='VRB')			    { $text = 'Variabel'; }
    elseif($angle>=348.75 OR $angle<11.25)  { $text = 'N'; }
    elseif($angle>=11.25 AND $angle<33.75)  { $text = 'NNE'; }
    elseif($angle>=33.75 AND $angle<56.25)  { $text = 'NE'; }
    elseif($angle>=56.25 AND $angle<78.75)  { $text = 'ENE'; }
    elseif($angle>=78.75 AND $angle<101.25) { $text = 'E'; }
    elseif($angle>=101.25 AND $angle<123.75){ $text = 'ESE'; }
    elseif($angle>=123.75 AND $angle<146.25){ $text = 'SE'; }
    elseif($angle>=146.25 AND $angle<168.75){ $text = 'ESE'; }
    elseif($angle>=168.75 AND $angle<191.25){ $text = 'S'; }
    elseif($angle>=191.25 AND $angle<213.75){ $text = 'SSW'; }
    elseif($angle>=213.75 AND $angle<236.25){ $text = 'SW'; }
    elseif($angle>=236.25 AND $angle<258.75){ $text = 'WSW'; }
    elseif($angle>=258.75 AND $angle<281.25){ $text = 'W'; }
    elseif($angle>=281.25 AND $angle<303.75){ $text = 'WNW'; }
    elseif($angle>=303.75 AND $angle<326.25){ $text = 'NW'; }
    elseif($angle>=326.25 AND $angle<348.75){ $text = 'NNW'; }
    return $text;
}

?>

Schreibe einen Kommentar