Converting wind direction in angles to text words

后端 未结 15 765
执笔经年
执笔经年 2021-01-30 13:16

I have wind direction data coming from a weather vane, and the data is represented in 0 to 359 degrees.

I want to convert this into text format (compass rose) with 16 di

15条回答
  •  孤城傲影
    2021-01-30 13:56

    I would probably just do simple division of degrees to get a position in an array or an enum value or something that would give you the text you need. Just round down on all your division. 360/16 = 22.5, so you would want to divide by 22.5 to get the position.

    String[] a = [N,NNW,NW,WNW,...,NNE]

提交回复
热议问题