Skip to content

Commit fa0ff47

Browse files
authored
Merge pull request #56 from gschora/master
Possibility to get updates from a specific personal weather station (PWS)
2 parents 8240efa + 00d15ea commit fa0ff47

File tree

2 files changed

+61
-26
lines changed

2 files changed

+61
-26
lines changed

WundergroundClient.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,23 @@ 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

59-
void WundergroundClient::updateForecast(String apiKey, String language, String zmwCode) {
64+
65+
void WundergroundClient::updateForecastPWS(String apiKey, String language, String pws) {
66+
isForecast = true;
67+
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/pws:" + pws + ".json");
68+
}
69+
70+
void WundergroundClient::updateForecastZMW(String apiKey, String language, String zmwCode) {
6071
isForecast = true;
6172
doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/zmw:" + zmwCode + ".json");
6273
}
@@ -68,6 +79,10 @@ void WundergroundClient::updateAstronomy(String apiKey, String language, String
6879
}
6980
// end JJG add ////////////////////////////////////////////////////////////////////
7081

82+
void WundergroundClient::updateAstronomyPWS(String apiKey, String language, String pws) {
83+
isForecast = true;
84+
doUpdate("/api/" + apiKey + "/astronomy/lang:" + language + "/q/pws:" + pws + ".json");
85+
}
7186
// fowlerk added
7287
void WundergroundClient::updateAlerts(String apiKey, String language, String country, String city) {
7388
currentAlert = 0;
@@ -87,6 +102,23 @@ void WundergroundClient::updateAlerts(String apiKey, String language, String cou
87102
}
88103
// end fowlerk add
89104

105+
void WundergroundClient::updateAlertsPWS(String apiKey, String language, String country, String pws) {
106+
currentAlert = 0;
107+
activeAlertsCnt = 0;
108+
isForecast = false;
109+
isSimpleForecast = false;
110+
isCurrentObservation = false;
111+
isAlerts = true;
112+
if (country == "US") {
113+
isAlertUS = true;
114+
isAlertEU = false;
115+
} else {
116+
isAlertUS = false;
117+
isAlertEU = true;
118+
}
119+
doUpdate("/api/" + apiKey + "/alerts/lang:" + language + "/q/pws:" + pws + ".json");
120+
}
121+
90122
void WundergroundClient::doUpdate(String url) {
91123
JsonStreamingParser parser;
92124
parser.setListener(this);

WundergroundClient.h

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ class WundergroundClient: public JsonListener {
104104
WundergroundClient(boolean isMetric);
105105
void updateConditions(String apiKey, String language, String country, String city);
106106
void updateConditions(String apiKey, String language, String zmwCode);
107+
void updateConditionsPWS(String apiKey, String language, String pws);
107108
void updateForecast(String apiKey, String language, String country, String city);
108-
void updateForecast(String apiKey, String language, String zmwCode);
109+
void updateForecastPWS(String apiKey, String language, String pws);
110+
void updateForecastZMW(String apiKey, String language, String zmwCode);
109111
void updateAstronomy(String apiKey, String language, String country, String city);
110-
void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016
111-
void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation
112-
112+
void updateAstronomyPWS(String apiKey, String language, String pws);
113+
void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016
114+
void updateAlertsPWS(String apiKey, String language, String country, String pws);
115+
void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation
113116
// JJG added
114117
String getHours();
115118
String getMinutes();
@@ -146,13 +149,13 @@ class WundergroundClient: public JsonListener {
146149
String getDewPoint();
147150

148151
String getPrecipitationToday();
149-
// fowlerk added...
150-
String getFeelsLike();
152+
// fowlerk added...
153+
String getFeelsLike();
151154

152-
String getUV();
155+
String getUV();
153156

154-
String getObservationTime(); // fowlerk add, 04-Dec-2016
155-
// end fowlerk add
157+
String getObservationTime(); // fowlerk add, 04-Dec-2016
158+
// end fowlerk add
156159

157160
String getForecastIcon(int period);
158161

@@ -161,36 +164,36 @@ class WundergroundClient: public JsonListener {
161164
String getForecastLowTemp(int period);
162165

163166
String getForecastHighTemp(int period);
164-
// fowlerk added...
165-
String getForecastDay(int period);
167+
// fowlerk added...
168+
String getForecastDay(int period);
166169

167-
String getForecastMonth(int period);
170+
String getForecastMonth(int period);
168171

169-
String getForecastText(int period);
172+
String getForecastText(int period);
170173

171-
String getPoP(int period);
174+
String getPoP(int period);
172175

173-
int getActiveAlertsCnt();
176+
int getActiveAlertsCnt();
174177

175-
String getActiveAlerts(int alertIndex);
178+
String getActiveAlerts(int alertIndex);
176179

177-
String getActiveAlertsText(int alertIndex);
180+
String getActiveAlertsText(int alertIndex);
178181

179-
String getActiveAlertsMessage(int alertIndex);
182+
String getActiveAlertsMessage(int alertIndex);
180183

181-
bool getActiveAlertsMessageTrunc(int alertIndex);
184+
bool getActiveAlertsMessageTrunc(int alertIndex);
182185

183-
String getActiveAlertsStart(int alertIndex);
186+
String getActiveAlertsStart(int alertIndex);
184187

185-
String getActiveAlertsEnd(int alertIndex);
188+
String getActiveAlertsEnd(int alertIndex);
186189

187-
String getActiveAlertsPhenomena(int alertIndex);
190+
String getActiveAlertsPhenomena(int alertIndex);
188191

189-
String getActiveAlertsSignificance(int alertIndex);
192+
String getActiveAlertsSignificance(int alertIndex);
190193

191-
String getActiveAlertsAttribution(int alertIndex);
194+
String getActiveAlertsAttribution(int alertIndex);
192195

193-
// end fowlerk add
196+
// end fowlerk add
194197

195198
virtual void whitespace(char c);
196199

0 commit comments

Comments
 (0)