Java: method to convert degrees into directions (16-wind compass rose)

I’m working on a weather app for Android. The data for wind direction that I get from the weather API is in form of degrees (0 to 360). I want to display wind direction in a user-friendly format such as N (North), NNE (North-northeast), NE (Northeast), ENE (East-Northeast), E (East), ESE (East-Southeast), SE (Southeast), SSE (South-Southeast), S (South), SSW (South-Southwest), SW (Southwest), WSW (West-Southwest), W (West), WNW (West-Northwest), NW (Northwest), and NNW (North-Northwest). I think this is more user-friendly, at least when compared to degrees format.

16-wind compass rose
The eight half-winds are the points obtained by bisecting the angles between the principal winds. The half-winds are north-northeast (NNE), east-northeast (ENE), east-southeast (ESE), south-southeast (SSE), south-southwest (SSW), west-southwest (WSW), west-northwest (WNW) and north-northwest (NNW). Notice that the name is constructed simply by combining the names of the principal winds to either side, with the cardinal wind coming first, the ordinal wind second. The eight principal winds and the eight half-winds together yield a 16-wind compass rose, with each compass point at a 22 1⁄2° angle from the next.

Points of the Compass

And here is the Java method that I prepared so I can convert direction data from degrees into directions (16-wind compass rose):

Related Posts:

Posts that may be related to "Java: method to convert degrees into directions (16-wind compass rose)":

Catzie

An odd human being who happens to have a variety of ever-changing interests, but right now they are programming, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert/drink flavors, obsessing about finding out how some things works, automation, anime, video games... Ran online dessert shops Cookies PH and Catzie's Cakery in her past life.

Leave a Reply

Your email address will not be published. Required fields are marked *