fix: 修改导出的风向

This commit is contained in:
yarnom 2025-08-27 14:15:37 +08:00
parent eeeffa3e95
commit 1ad2eb6e60

View File

@ -384,8 +384,17 @@ func (e *Exporter) fetchCaiyunRealtimeWind(ctx context.Context, lat, lon float64
if strings.ToLower(data.Status) != "ok" || strings.ToLower(data.Result.Realtime.Status) != "ok" {
return 0, 0, false
}
// 使用 SI 单位,风速直接为 m/s
return data.Result.Realtime.Wind.Speed, data.Result.Realtime.Wind.Direction, true
// 使用 SI 单位,风速为 m/s风向为弧度这里转换为度[0,360)
spd := data.Result.Realtime.Wind.Speed
dirRad := data.Result.Realtime.Wind.Direction
dirDeg := dirRad * 180.0 / math.Pi
for dirDeg < 0 {
dirDeg += 360
}
for dirDeg >= 360 {
dirDeg -= 360
}
return spd, dirDeg, true
}
func ensureFileWithHeader(path string) bool {