adding icon mapping

This commit is contained in:
Johannes Theiner 2020-07-21 22:11:02 +02:00
parent 4761167e1c
commit 1572de55e8
1 changed files with 17 additions and 1 deletions

View File

@ -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,