From 1e8776f66689d4cb082440609d71953d107550b3 Mon Sep 17 00:00:00 2001 From: hannes Date: Sat, 18 Feb 2017 13:31:19 +0100 Subject: [PATCH] added possibility to update conditions, forecast, astronomy and alerts by providing a specific pws-id. --- WundergroundClient.cpp | 31 +++++++++++++++++++++++++++++++ WundergroundClient.h | 6 +++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/WundergroundClient.cpp b/WundergroundClient.cpp index 5ad964e..7cc8790 100644 --- a/WundergroundClient.cpp +++ b/WundergroundClient.cpp @@ -51,11 +51,21 @@ void WundergroundClient::updateConditions(String apiKey, String language, String doUpdate("/api/" + apiKey + "/conditions/lang:" + language + "/q/zmw:" + zmwCode + ".json"); } +void WundergroundClient::updateConditionsPWS(String apiKey, String language, String pws) { + isForecast = false; + doUpdate("/api/" + apiKey + "/conditions/lang:" + language + "/q/pws:" + pws + ".json"); +} + void WundergroundClient::updateForecast(String apiKey, String language, String country, String city) { isForecast = true; doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/" + country + "/" + city + ".json"); } +void WundergroundClient::updateForecastPWS(String apiKey, String language, String pws) { + isForecast = true; + doUpdate("/api/" + apiKey + "/forecast10day/lang:" + language + "/q/pws:" + pws + ".json"); +} + // JJG added //////////////////////////////// void WundergroundClient::updateAstronomy(String apiKey, String language, String country, String city) { isForecast = true; @@ -63,6 +73,10 @@ void WundergroundClient::updateAstronomy(String apiKey, String language, String } // end JJG add //////////////////////////////////////////////////////////////////// +void WundergroundClient::updateAstronomyPWS(String apiKey, String language, String pws) { + isForecast = true; + doUpdate("/api/" + apiKey + "/astronomy/lang:" + language + "/q/pws:" + pws + ".json"); +} // fowlerk added void WundergroundClient::updateAlerts(String apiKey, String language, String country, String city) { currentAlert = 0; @@ -82,6 +96,23 @@ void WundergroundClient::updateAlerts(String apiKey, String language, String cou } // end fowlerk add +void WundergroundClient::updateAlertsPWS(String apiKey, String language, String country, String pws) { + currentAlert = 0; + activeAlertsCnt = 0; + isForecast = false; + isSimpleForecast = false; + isCurrentObservation = false; + isAlerts = true; + if (country == "US") { + isAlertUS = true; + isAlertEU = false; + } else { + isAlertUS = false; + isAlertEU = true; + } + doUpdate("/api/" + apiKey + "/alerts/lang:" + language + "/q/pws:" + pws + ".json"); +} + void WundergroundClient::doUpdate(String url) { JsonStreamingParser parser; parser.setListener(this); diff --git a/WundergroundClient.h b/WundergroundClient.h index d1ea028..198c733 100644 --- a/WundergroundClient.h +++ b/WundergroundClient.h @@ -103,10 +103,14 @@ class WundergroundClient: public JsonListener { WundergroundClient(boolean isMetric); void updateConditions(String apiKey, String language, String country, String city); void updateConditions(String apiKey, String language, String zmwCode); + void updateConditionsPWS(String apiKey, String language, String pws); void updateForecast(String apiKey, String language, String country, String city); + void updateForecastPWS(String apiKey, String language, String pws); void updateAstronomy(String apiKey, String language, String country, String city); + void updateAstronomyPWS(String apiKey, String language, String pws); void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016 - void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation + void updateAlertsPWS(String apiKey, String language, String country, String pws); + void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation // JJG added String getHours();