diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 6027f443a..3635136a8 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -2883,6 +2883,22 @@ videomenu.zappingmode Umschaltverhalten videomenu.zappingmode_mute Schwarzes Bild videomenu.zappingmode_hold Standbild weather.api_key Wetter API Schlüssel (OpenWeather) +weather.direction_e O +weather.direction_ene ONO +weather.direction_ese OSO +weather.direction_n N +weather.direction_ne NO +weather.direction_nne NNO +weather.direction_nnw NNW +weather.direction_nw NW +weather.direction_s S +weather.direction_se SO +weather.direction_sse SSO +weather.direction_ssw SSW +weather.direction_sw SW +weather.direction_w W +weather.direction_wnw WNW +weather.direction_wsw WSW weather.enabled Wetter-Unterstützung weather.location Wetter-Standort weather.postalcode Wetter-Standort per Postleitzahl diff --git a/data/locale/english.locale b/data/locale/english.locale index 6b3b96e6a..1be3edfa6 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -2883,6 +2883,22 @@ videomenu.zappingmode Zapping mode videomenu.zappingmode_mute Black screen videomenu.zappingmode_hold Hold screen weather.api_key Weather API key (OpenWeather) +weather.direction_e E +weather.direction_ene ENE +weather.direction_ese ESE +weather.direction_n N +weather.direction_ne NE +weather.direction_nne NNE +weather.direction_nnw NNW +weather.direction_nw NW +weather.direction_s S +weather.direction_se SE +weather.direction_sse SSE +weather.direction_ssw SSW +weather.direction_sw SW +weather.direction_w W +weather.direction_wnw WNW +weather.direction_wsw WSW weather.enabled Weather support weather.location Weather location weather.postalcode Weather location by postal code diff --git a/src/gui/weather.cpp b/src/gui/weather.cpp index 81d9d3709..bfb412f19 100644 --- a/src/gui/weather.cpp +++ b/src/gui/weather.cpp @@ -181,6 +181,34 @@ bool CWeather::GetWeatherDetails() return false; } +std::string CWeather::getDirectionString(int degree) +{ + std::string direction("n/a"); + + float step = 11.25; + float deg = degree; + + if (deg <= step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_N); } + else if (deg <= 3 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_NNE); } + else if (deg <= 5 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_NE); } + else if (deg <= 7 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_ENE); } + else if (deg <= 9 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_E); } + else if (deg <= 11 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_ESE); } + else if (deg <= 13 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_SE); } + else if (deg <= 15 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_SSE); } + else if (deg <= 17 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_S); } + else if (deg <= 19 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_SSW); } + else if (deg <= 21 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_SW); } + else if (deg <= 23 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_WSW); } + else if (deg <= 25 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_W); } + else if (deg <= 27 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_WNW); } + else if (deg <= 29 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_NW); } + else if (deg <= 31 * step) { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_NNW); } + else { direction = g_Locale->getText(LOCALE_WEATHER_DIRECTION_N); } + + return direction; +} + bool CWeather::FindCoords(std::string postalcode, std::string country) { std::string data = "http://api.openweathermap.org/geo/1.0/zip?zip=" + postalcode + "," + country + "&appid=" + key; diff --git a/src/gui/weather.h b/src/gui/weather.h index 3c6ca74ff..a81a931f2 100644 --- a/src/gui/weather.h +++ b/src/gui/weather.h @@ -83,6 +83,7 @@ class CWeather std::string key; bool GetWeatherDetails(); time_t last_time; + std::string getDirectionString(int degree); public: static CWeather *getInstance(); @@ -129,6 +130,10 @@ class CWeather { return to_string(current.windBearing); }; + std::string getCurrentWindDirection() + { + return getDirectionString(current.windBearing); + }; std::string getCurrentIcon() { return ICONSDIR"/weather/" + current.icon; @@ -173,6 +178,12 @@ class CWeather i = (int)v_forecast.size(); return to_string(v_forecast[i].windBearing); }; + std::string getForecastWindDirection(int i = 0) + { + if (i > (int)v_forecast.size()) + i = (int)v_forecast.size(); + return getDirectionString(v_forecast[i].windBearing); + }; std::string getForecastIcon(int i = 0) { if (i > (int)v_forecast.size()) diff --git a/src/system/locals.h b/src/system/locals.h index af3dc8a2a..93f7e3882 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -2910,6 +2910,22 @@ typedef enum LOCALE_VIDEOMENU_ZAPPINGMODE_MUTE, LOCALE_VIDEOMENU_ZAPPINGMODE_HOLD, LOCALE_WEATHER_API_KEY, + LOCALE_WEATHER_DIRECTION_E, + LOCALE_WEATHER_DIRECTION_ENE, + LOCALE_WEATHER_DIRECTION_ESE, + LOCALE_WEATHER_DIRECTION_N, + LOCALE_WEATHER_DIRECTION_NE, + LOCALE_WEATHER_DIRECTION_NNE, + LOCALE_WEATHER_DIRECTION_NNW, + LOCALE_WEATHER_DIRECTION_NW, + LOCALE_WEATHER_DIRECTION_S, + LOCALE_WEATHER_DIRECTION_SE, + LOCALE_WEATHER_DIRECTION_SSE, + LOCALE_WEATHER_DIRECTION_SSW, + LOCALE_WEATHER_DIRECTION_SW, + LOCALE_WEATHER_DIRECTION_W, + LOCALE_WEATHER_DIRECTION_WNW, + LOCALE_WEATHER_DIRECTION_WSW, LOCALE_WEATHER_ENABLED, LOCALE_WEATHER_LOCATION, LOCALE_WEATHER_POSTALCODE, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 15e110a96..31d4bb9ce 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -2910,6 +2910,22 @@ const char * locale_real_names[] = "videomenu.zappingmode_mute", "videomenu.zappingmode_hold", "weather.api_key", + "weather.direction_e", + "weather.direction_ene", + "weather.direction_ese", + "weather.direction_n", + "weather.direction_ne", + "weather.direction_nne", + "weather.direction_nnw", + "weather.direction_nw", + "weather.direction_s", + "weather.direction_se", + "weather.direction_sse", + "weather.direction_ssw", + "weather.direction_sw", + "weather.direction_w", + "weather.direction_wnw", + "weather.direction_wsw", "weather.enabled", "weather.location", "weather.postalcode",