From 4acb2b62ca1e6937eabea04ea0d245224dec6177 Mon Sep 17 00:00:00 2001 From: yarnom Date: Fri, 22 Aug 2025 13:53:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=AD=A3=E9=A3=8E?= =?UTF-8?q?=E9=80=9F=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/forecast/open_meteo.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/forecast/open_meteo.go b/internal/forecast/open_meteo.go index 0a9547d..7086f5f 100644 --- a/internal/forecast/open_meteo.go +++ b/internal/forecast/open_meteo.go @@ -88,10 +88,12 @@ func RunOpenMeteoFetch(ctx context.Context) error { v.rh = data.Hourly.Humidity[i] } if i < len(data.Hourly.WindSpeed) { - v.ws = data.Hourly.WindSpeed[i] + // 将 km/h 转换为 m/s: m/s = km/h ÷ 3.6 + v.ws = data.Hourly.WindSpeed[i] / 3.6 } if i < len(data.Hourly.WindGusts) { - v.gust = data.Hourly.WindGusts[i] + // 将 km/h 转换为 m/s: m/s = km/h ÷ 3.6 + v.gust = data.Hourly.WindGusts[i] / 3.6 } if i < len(data.Hourly.WindDir) { v.wdir = data.Hourly.WindDir[i] @@ -154,6 +156,8 @@ func buildOpenMeteoURL(lat, lon sql.NullFloat64) string { q.Set("longitude", fmt.Sprintf("%f", lon.Float64)) q.Set("hourly", "rain,temperature_2m,relative_humidity_2m,wind_speed_10m,wind_gusts_10m,wind_direction_10m,precipitation_probability,surface_pressure") q.Set("timezone", "Asia/Shanghai") + // 可以添加单位参数,但我们已经在代码中处理了单位转换,所以保持默认单位即可 + // 默认单位:风速 km/h,温度 °C,降水量 mm,气压 hPa return "https://api.open-meteo.com/v1/forecast?" + q.Encode() }