Converting wind direction in angles to text words

后端 未结 15 786
执笔经年
执笔经年 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:47

    I believe it is easier to:

    1. Shift the direction by 11.25
    2. Add an "N" at the end of the direction list to handle the 'over 360',

    DirTable = ["N","NNE","NE","ENE","E","ESE", "SE","SSE","S","SSW","SW","WSW", "W","WNW","NW","NNW",**"N"**]; 
    
    wind_direction= DirTable[Math.floor((d+11.25)/22.5)];
    

提交回复
热议问题