Skip to content

Instantly share code, notes, and snippets.

@nguyenDalex
Last active August 29, 2015 14:12
Show Gist options
  • Save nguyenDalex/c3b4fdeb517703f389b5 to your computer and use it in GitHub Desktop.
Save nguyenDalex/c3b4fdeb517703f389b5 to your computer and use it in GitHub Desktop.
forecast io Cardinal Direction from windbearing javascript funciton
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];
}
@fgilio
Copy link

fgilio commented Jan 30, 2015

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment