Skip to content

Commit 1e8776f

Browse files
committed
added possibility to update conditions, forecast, astronomy and alerts by providing a specific pws-id.
1 parent 1b9e06c commit 1e8776f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

WundergroundClient.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,32 @@ void WundergroundClient::updateConditions(String apiKey, String language, String
5151
doUpdate("/api/" + apiKey + "/conditions/lang:" + language + "/q/zmw:" + zmwCode + ".json");
5252
}
5353

54+
void WundergroundClient::updateConditionsPWS(String apiKey, String language, String pws) {
55+
isForecast = false;
56+
doUpdate("/api/" + apiKey + "/conditions/lang:" + language + "/q/pws:" + pws + ".json");
57+
}
58+
5459
void WundergroundClient::updateForecast(String apiKey, String language, String country, String city) {
5560
isForecast = true;
5661
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/" + country + "/" + city + ".json");
5762
}
5863

64+
void WundergroundClient::updateForecastPWS(String apiKey, String language, String pws) {
65+
isForecast = true;
66+
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/pws:" + pws + ".json");
67+
}
68+
5969
// JJG added ////////////////////////////////
6070
void WundergroundClient::updateAstronomy(String apiKey, String language, String country, String city) {
6171
isForecast = true;
6272
doUpdate("/api/" + apiKey + "/astronomy/lang:" + language + "/q/" + country + "/" + city + ".json");
6373
}
6474
// end JJG add ////////////////////////////////////////////////////////////////////
6575

76+
void WundergroundClient::updateAstronomyPWS(String apiKey, String language, String pws) {
77+
isForecast = true;
78+
doUpdate("/api/" + apiKey + "/astronomy/lang:" + language + "/q/pws:" + pws + ".json");
79+
}
6680
// fowlerk added
6781
void WundergroundClient::updateAlerts(String apiKey, String language, String country, String city) {
6882
currentAlert = 0;
@@ -82,6 +96,23 @@ void WundergroundClient::updateAlerts(String apiKey, String language, String cou
8296
}
8397
// end fowlerk add
8498

99+
void WundergroundClient::updateAlertsPWS(String apiKey, String language, String country, String pws) {
100+
currentAlert = 0;
101+
activeAlertsCnt = 0;
102+
isForecast = false;
103+
isSimpleForecast = false;
104+
isCurrentObservation = false;
105+
isAlerts = true;
106+
if (country == "US") {
107+
isAlertUS = true;
108+
isAlertEU = false;
109+
} else {
110+
isAlertUS = false;
111+
isAlertEU = true;
112+
}
113+
doUpdate("/api/" + apiKey + "/alerts/lang:" + language + "/q/pws:" + pws + ".json");
114+
}
115+
85116
void WundergroundClient::doUpdate(String url) {
86117
JsonStreamingParser parser;
87118
parser.setListener(this);

WundergroundClient.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ class WundergroundClient: public JsonListener {
103103
WundergroundClient(boolean isMetric);
104104
void updateConditions(String apiKey, String language, String country, String city);
105105
void updateConditions(String apiKey, String language, String zmwCode);
106+
void updateConditionsPWS(String apiKey, String language, String pws);
106107
void updateForecast(String apiKey, String language, String country, String city);
108+
void updateForecastPWS(String apiKey, String language, String pws);
107109
void updateAstronomy(String apiKey, String language, String country, String city);
110+
void updateAstronomyPWS(String apiKey, String language, String pws);
108111
void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016
109-
void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation
112+
void updateAlertsPWS(String apiKey, String language, String country, String pws);
113+
void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation
110114

111115
// JJG added
112116
String getHours();

0 commit comments

Comments
 (0)