From 1572de55e8fad9f13ec35f5f10bfd8d3bb8e92bc Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 21 Jul 2020 22:11:02 +0200 Subject: [PATCH] adding icon mapping --- src/server/WeatherServer.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/server/WeatherServer.go b/src/server/WeatherServer.go index 8439771..768fd4f 100644 --- a/src/server/WeatherServer.go +++ b/src/server/WeatherServer.go @@ -169,6 +169,22 @@ func getOptionalArgs(req *http.Request) (language string, units config.Units) { } func convert(weatherData client.WeatherResponse) Weather { + iconMapping := map[string]string{ + "01d": "★", + "01n": "★", + "02d": "☁☀", + "02n": "☁☀", + "03d": "☁", + "03n": "☁", + "10d": "☔", + "10n": "☔", + "11d": "⚕", + "11n": "⚕", + "13d": "❄", + "13n": "❄", + "50d": "☷", + "50n": "☷", + } return Weather{ TemperatureCurrent: weatherData.Main.Temperature, TemperatureMin: weatherData.Main.TemperatureMin, @@ -177,7 +193,7 @@ func convert(weatherData client.WeatherResponse) Weather { Pressure: weatherData.Main.Pressure, Humidity: weatherData.Main.Humidity, Description: weatherData.Weather[0].Description, - Icon: weatherData.Weather[0].Icon, + Icon: iconMapping[weatherData.Weather[0].Icon], WindSpeeed: weatherData.Wind.Speed, WindDegree: weatherData.Wind.Degree, Clouds: weatherData.Clouds.All,