switch weather api from Dark Sky to OpenWeather

Origin commit data
------------------
Branch: ni/coolstream
Commit: a18f855d68
Author: TangoCash <eric@loxat.de>
Date: 2022-01-14 (Fri, 14 Jan 2022)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2022-01-14 22:43:24 +01:00
committed by vanhofen
parent 26f60e3b84
commit b9c51793e3
31 changed files with 44 additions and 37 deletions

BIN
data/icons/weather/01d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
data/icons/weather/01n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

BIN
data/icons/weather/02d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
data/icons/weather/02n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B

BIN
data/icons/weather/03d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

BIN
data/icons/weather/03n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

BIN
data/icons/weather/04d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/icons/weather/04n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/icons/weather/09d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
data/icons/weather/09n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/icons/weather/10d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
data/icons/weather/10n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/icons/weather/11d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
data/icons/weather/11n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
data/icons/weather/13d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
data/icons/weather/13n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/icons/weather/50d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
data/icons/weather/50n.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,14 +1,22 @@
installdir = $(ICONSDIR)/weather installdir = $(ICONSDIR)/weather
install_DATA = \ install_DATA = \
clear-day.png \ 01d.png \
clear-night.png \ 01n.png \
cloudy.png \ 02d.png \
fog.png \ 02n.png \
partly-cloudy-day.png \ 03d.png \
partly-cloudy-night.png \ 03n.png \
rain.png \ 04d.png \
sleet.png \ 04n.png \
snow.png \ 09d.png \
unknown.png \ 09n.png \
wind.png 10d.png \
10n.png \
11d.png \
11n.png \
13d.png \
13n.png \
50d.png \
50n.png \
unknown.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 B

View File

@@ -1,7 +1,7 @@
/* /*
Copyright (C) 2017,2018,2019 TangoCash Copyright (C) 2017, 2018, 2019, 2020 TangoCash
“Powered by Dark Sky” https://darksky.net/poweredby/ “Powered by OpenWeather” https://openweathermap.org/api/one-call-api
License: GPLv2 License: GPLv2
@@ -97,7 +97,10 @@ bool CWeather::GetWeatherDetails()
if (!g_settings.weather_enabled) if (!g_settings.weather_enabled)
return false; return false;
std::string data = "https://api.darksky.net/forecast/" + key + "/" + coords + "?units=ca&lang=de&exclude=minutely,hourly,flags,alerts"; std::string lat = coords.substr(0,coords.find_first_of(','));
std::string lon = coords.substr(coords.find_first_of(',')+1);
std::string data = "https://api.openweathermap.org/data/2.5/onecall?lat=" + lat + "&lon=" + lon + "&units=metric&lang=de&exclude=minutely,hourly,flags,alerts&appid=" + key;
JSONCPP_STRING answer; JSONCPP_STRING answer;
JSONCPP_STRING formattedErrors; JSONCPP_STRING formattedErrors;
@@ -126,20 +129,20 @@ bool CWeather::GetWeatherDetails()
return false; return false;
} }
found = DataValues["currently"].get("time", 0).asDouble(); found = DataValues["current"].get("dt", 0).asDouble();
printf("[CWeather]: results found: %lf\n", found); printf("[CWeather]: results found: %lf\n", found);
if (found > 0) if (found > 0)
{ {
timezone = DataValues["timezone"].asString(); timezone = DataValues["timezone"].asString();
current.timestamp = DataValues["currently"].get("time", 0).asDouble(); current.timestamp = DataValues["current"].get("dt", 0).asDouble();
current.temperature = DataValues["currently"].get("temperature", "").asFloat(); current.temperature = DataValues["current"].get("temp", "").asFloat();
current.pressure = DataValues["currently"].get("pressure", "").asFloat(); current.pressure = DataValues["current"].get("pressure", "").asFloat();
current.humidity = DataValues["currently"].get("humidity", "").asFloat(); current.humidity = DataValues["current"].get("humidity", "").asFloat();
current.windSpeed = DataValues["currently"].get("windSpeed", "").asFloat(); current.windSpeed = DataValues["current"].get("wind_speed", "").asFloat();
current.windBearing = DataValues["currently"].get("windBearing", "").asDouble(); current.windBearing = DataValues["current"].get("wind_deg", "").asDouble();
current.icon = current.icon_only_name = DataValues["currently"].get("icon", "").asString(); current.icon = DataValues["current"]["weather"][0].get("icon", "").asString();
if (current.icon.empty()) if (current.icon.empty())
current.icon = "unknown.png"; current.icon = "unknown.png";
else else
@@ -151,26 +154,22 @@ bool CWeather::GetWeatherDetails()
printf("[CWeather]: temp in %s (%s): %.1f - %s\n", city.c_str(), timezone.c_str(), current.temperature, current.icon.c_str()); printf("[CWeather]: temp in %s (%s): %.1f - %s\n", city.c_str(), timezone.c_str(), current.temperature, current.icon.c_str());
forecast_data daily_data; forecast_data daily_data;
Json::Value elements = DataValues["daily"]["data"]; Json::Value elements = DataValues["daily"];
for (unsigned int i = 0; i < elements.size(); i++) for (unsigned int i = 0; i < elements.size(); i++)
{ {
daily_data.timestamp = elements[i].get("time", 0).asDouble(); daily_data.timestamp = elements[i].get("dt", 0).asDouble();
daily_data.weekday = (int)(localtime(&daily_data.timestamp)->tm_wday); daily_data.weekday = (int)(localtime(&daily_data.timestamp)->tm_wday);
daily_data.icon = daily_data.icon_only_name = elements[i].get("icon", "").asString(); daily_data.icon = elements[i]["weather"][0].get("icon", "").asString();
if (daily_data.icon.empty()) if (daily_data.icon.empty())
daily_data.icon = "unknown.png"; daily_data.icon = "unknown.png";
else else
daily_data.icon = daily_data.icon + ".png"; daily_data.icon = daily_data.icon + ".png";
daily_data.temperatureMin = elements[i]["temp"].get("min", "").asFloat();
if (daily_data.icon_only_name.empty()) daily_data.temperatureMax = elements[i]["temp"].get("max", "").asFloat();
daily_data.icon_only_name = "unknown"; daily_data.sunriseTime = elements[i].get("sunrise", 0).asDouble();
daily_data.sunsetTime = elements[i].get("sunset", 0).asDouble();
daily_data.temperatureMin = elements[i].get("temperatureMin", "").asFloat(); daily_data.windSpeed = elements[i].get("wind_speed", 0).asFloat();
daily_data.temperatureMax = elements[i].get("temperatureMax", "").asFloat(); daily_data.windBearing = elements[i].get("wind_deg", 0).asDouble();
daily_data.sunriseTime = elements[i].get("sunriseTime", 0).asDouble();
daily_data.sunsetTime = elements[i].get("sunsetTime", 0).asDouble();
daily_data.windSpeed = elements[i].get("windSpeed", 0).asFloat();
daily_data.windBearing = elements[i].get("windBearing", 0).asDouble();
struct tm *timeinfo; struct tm *timeinfo;
timeinfo = localtime(&daily_data.timestamp); timeinfo = localtime(&daily_data.timestamp);

View File

@@ -1,7 +1,7 @@
/* /*
Copyright (C) 2017,2018,2019 TangoCash Copyright (C) 2017, 2018, 2019, 2020 TangoCash
“Powered by Dark Sky” https://darksky.net/poweredby/ “Powered by OpenWeather” https://openweathermap.org/api/one-call-api
License: GPLv2 License: GPLv2