Created
May 9, 2017 18:17
-
-
Save dario61081/fa4cde146d143bb0ba6055b84c5eb33e to your computer and use it in GitHub Desktop.
Convertir grados en rosa de vientos
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
public String convertDegreeToCardinalDirection(int directionInDegrees){ | |
String cardinalDirection = null; | |
if( (directionInDegrees >= 348.75) && (directionInDegrees <= 360) || | |
(directionInDegrees >= 0) && (directionInDegrees <= 11.25) ){ | |
cardinalDirection = "N"; | |
} else if( (directionInDegrees >= 11.25 ) && (directionInDegrees <= 33.75)){ | |
cardinalDirection = "NNE"; | |
} else if( (directionInDegrees >= 33.75 ) &&(directionInDegrees <= 56.25)){ | |
cardinalDirection = "NE"; | |
} else if( (directionInDegrees >= 56.25 ) && (directionInDegrees <= 78.75)){ | |
cardinalDirection = "ENE"; | |
} else if( (directionInDegrees >= 78.75 ) && (directionInDegrees <= 101.25) ){ | |
cardinalDirection = "E"; | |
} else if( (directionInDegrees >= 101.25) && (directionInDegrees <= 123.75) ){ | |
cardinalDirection = "ESE"; | |
} else if( (directionInDegrees >= 123.75) && (directionInDegrees <= 146.25) ){ | |
cardinalDirection = "SE"; | |
} else if( (directionInDegrees >= 146.25) && (directionInDegrees <= 168.75) ){ | |
cardinalDirection = "SSE"; | |
} else if( (directionInDegrees >= 168.75) && (directionInDegrees <= 191.25) ){ | |
cardinalDirection = "S"; | |
} else if( (directionInDegrees >= 191.25) && (directionInDegrees <= 213.75) ){ | |
cardinalDirection = "SSW"; | |
} else if( (directionInDegrees >= 213.75) && (directionInDegrees <= 236.25) ){ | |
cardinalDirection = "SW"; | |
} else if( (directionInDegrees >= 236.25) && (directionInDegrees <= 258.75) ){ | |
cardinalDirection = "WSW"; | |
} else if( (directionInDegrees >= 258.75) && (directionInDegrees <= 281.25) ){ | |
cardinalDirection = "W"; | |
} else if( (directionInDegrees >= 281.25) && (directionInDegrees <= 303.75) ){ | |
cardinalDirection = "WNW"; | |
} else if( (directionInDegrees >= 303.75) && (directionInDegrees <= 326.25) ){ | |
cardinalDirection = "NW"; | |
} else if( (directionInDegrees >= 326.25) && (directionInDegrees <= 348.75) ){ | |
cardinalDirection = "NNW"; | |
} else { | |
cardinalDirection = "?"; | |
} | |
return cardinalDirection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment