Here's a handy JavaScript code to convert degrees to cardinal directions:
function windDir ($winddir)
// Take wind direction value, return the
// text label based upon 16 point compass -- function by beeker425
// see http://www.weather-watch.com/smf/index.php/topic,20097.0.html
{
var $windlabel = new Array("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
return $windlabel[Math.floor(((parseInt($winddir) + 11) / 22.5) % 16 )];
}
use it by var windDirection = windDir(windDegrees);
and the windDirection variable will contain the text of the cardinal wind direction based on the number in windDegrees.
Best regards,
Ken