Last active
August 29, 2015 14:12
-
-
Save nguyenDalex/c3b4fdeb517703f389b5 to your computer and use it in GitHub Desktop.
forecast io Cardinal Direction from windbearing javascript funciton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCardinalDirection(input) { | |
var directions = ["N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"]; | |
var index = Math.floor( ((input-22.5)%360) / 45 ); | |
return directions[index+1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, thanks!