I have to write a little function to convert a direction from degrees to a compass -type heading. 0 = West. 90 = North. E.g.:
Something like this... it'll account for >360 degrees, too. No different that a bunch of IF statements, though...
<?php
$dir = 378;
switch($dir = $dir%360)
{
case 0 <= $dir && $dir < 90:
echo 'northeasterly';
break;
case 90 <= $dir && $dir < 180:
echo 'southeasterly';
break;
case 180 <= $dir && $dir < 270:
echo 'southwesterly';
break;
case 270 <= $dir && $dir < 360:
echo 'northwesterly';
break;
}
?>---John Holmes...
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

