summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Weather/src/weather_data.cpp2
-rw-r--r--protocols/Weather/src/weather_update.cpp9
2 files changed, 10 insertions, 1 deletions
diff --git a/protocols/Weather/src/weather_data.cpp b/protocols/Weather/src/weather_data.cpp
index b7e9e7c0fc..5294befb0f 100644
--- a/protocols/Weather/src/weather_data.cpp
+++ b/protocols/Weather/src/weather_data.cpp
@@ -266,6 +266,8 @@ MHttpResponse* CWeatherProto::RunQuery(const wchar_t *id, int days)
}
pReq << CHAR_PARAM("unitGroup", "metric") << WCHAR_PARAM("key", pKey) << CHAR_PARAM("contentType", "json");
+ if (days)
+ pReq << CHAR_PARAM("elements", "+elevation");
auto *ret = Netlib_HttpTransaction(m_hNetlibUser, pReq);
delete pReq;
diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp
index 3b18def988..d3a3fdfb90 100644
--- a/protocols/Weather/src/weather_update.cpp
+++ b/protocols/Weather/src/weather_update.cpp
@@ -377,19 +377,24 @@ static CMStringW parseConditions(const CMStringW &str)
return ret;
}
+static double g_elevation = 0;
+
static void getData(OBJLIST<WIDATAITEM> &arValues, const JSONNode &node)
{
arValues.insert(new WIDATAITEM(LPGENW("Condition"), L"", parseConditions(node["conditions"].as_mstring())));
arValues.insert(new WIDATAITEM(LPGENW("Temperature"), L"C", node["temp"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("High"), L"C", node["tempmax"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Low"), L"C", node["tempmin"].as_mstring()));
+
+ CMStringW wszPressure(FORMAT, L"%lf", node["pressure"].as_float() - g_elevation);
+ arValues.insert(new WIDATAITEM(LPGENW("Pressure"), L"mb", wszPressure));
+
arValues.insert(new WIDATAITEM(LPGENW("Sunset"), L"", node["sunset"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Sunrise"), L"", node["sunrise"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Moon phase"), L"", moon2str(node["moonphase"].as_float())));
arValues.insert(new WIDATAITEM(LPGENW("Wind speed"), L"km/h", node["windspeed"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Wind direction"), L"grad", node["winddir"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Dew point"), L"C", node["dew"].as_mstring()));
- arValues.insert(new WIDATAITEM(LPGENW("Pressure"), L"mb", node["pressure"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Visibility"), L"km", node["visibility"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Humidity"), L"", node["humidity"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Feel"), L"C", node["feelslike"].as_mstring()));
@@ -414,6 +419,8 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact)
// writing current conditions
auto &curr = root["currentConditions"];
+ g_elevation = root["elevation"].as_float() / 7.877;
+
OBJLIST<WIDATAITEM> arValues(20);
getData(arValues, curr);