I noticed a post from Tom ...
// figure out a text value for compass direction
switch (TRUE) {
case (($winddir >= 349) and ($winddir <= 360)):
$winddir = 'N';
break;
case (($winddir >= 0) and ($winddir <= 11)):
$winddir = 'N';
snip....
I took a different approach. For a 16 point compass, I've been using for some time (when I started the Wx-Host weather icon generation stuff) the following routine...
Its basically just an array of the various values and a calculation based upon the wind direction provided in numerical format. Ie the WindDir element in clientraw.txt file (element #3)
$winddir = array ("N","NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW","SW", "WSW", "W", "WNN", "NW", "NNW");
$dir = $winddir[ (int) (gv($tg,3) / 22.5) ];
gv($tg,3) = Clientraw data ellement #3 = WindDir
Basically it takes the number and divides it by 22.5 to get the whole number that then corresponds with the wind lable. IF the number is non-zero, you end up with 0 = N.