environmentData.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package model
  2. const EnvironmentDataKey = "environment_data_%d"
  3. const (
  4. ModelInfoDefault = iota
  5. ModelInfoAirQuality //空气质量
  6. ModelInfoPM25 //pm2.5
  7. ModelInfoPM10 //pm10
  8. ModelInfoTemprature //温度
  9. ModelInfoHumidity //湿度
  10. ModelInfowindSpeed //风速
  11. ModelInfoPressure //气压
  12. ModelInfoNoise //噪音
  13. ModelInfoLightIntensity //光照强度
  14. ModelInfoWindDirection //风向
  15. ModelInfoRainfall //降雨量
  16. ModelInfoUltravioletRays //紫外线
  17. ModelInfoAll = 20 //综合,所有类型
  18. ModelInfoAQI = 21 //空气质量AQI
  19. )
  20. func CalculateDirection(windDirection float32) string {
  21. result := "-"
  22. if windDirection > 337.5 || windDirection <= 22.5 {
  23. result = "北"
  24. } else if windDirection > 22.5 || windDirection <= 67.5 {
  25. result = "东北"
  26. } else if windDirection > 67.5 || windDirection <= 112.5 {
  27. result = "东"
  28. } else if windDirection > 112.5 || windDirection <= 157.5 {
  29. result = "东南"
  30. } else if windDirection > 157.5 || windDirection <= 202.5 {
  31. result = "南"
  32. } else if windDirection > 202.5 || windDirection <= 247.5 {
  33. result = "西南"
  34. } else if windDirection > 247.5 || windDirection <= 292.5 {
  35. result = "西"
  36. } else if windDirection > 292.5 || windDirection <= 337.5 {
  37. result = "西北"
  38. }
  39. return result
  40. }