Last active
March 3, 2016 17:29
-
-
Save ajzeigert/d01db17e8821190d5840 to your computer and use it in GitHub Desktop.
Function that converts degrees to cardinal and intercardinal directions
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
// I used this for aspect specifically | |
function getDirection(d){ | |
if (d < 22.5 ) { | |
return 'N'; | |
} else if ( d < 67.5 ) { | |
return 'NE'; | |
} else if ( d < 112.5 ) { | |
return 'E'; | |
} else if ( d < 157.5 ) { | |
return 'SE'; | |
} else if ( d < 202.5 ) { | |
return 'S'; | |
} else if ( d < 247.5 ) { | |
return 'SW'; | |
} else if ( d < 292.5 ) { | |
return 'W'; | |
} else if ( d < 337.5 ) { | |
return 'NW'; | |
} else { | |
return 'N'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment