From b4dff8ffd93a7207aedbd7286602bbdfb1c5cd37 Mon Sep 17 00:00:00 2001 From: Andy Pearson Date: Sun, 14 Jun 2020 15:27:06 +0100 Subject: [PATCH 1/3] Change weather module to use WeatherAPI.com --- app/libraries/main.php | 3 ++- app/modules/weather/details.php | 38 ++++++++++++++++----------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/libraries/main.php b/app/libraries/main.php index 3169179c..3afd1b98 100644 --- a/app/libraries/main.php +++ b/app/libraries/main.php @@ -5709,7 +5709,8 @@ public function get_weather($lat, $lng, $datetime) ))) $locale = 'en'; // Dark Sky Provider - $JSON = $this->get_web_page('https://api.darksky.net/forecast/'.$settings['weather_module_api_key'].'/'.$lat.','.$lng.','.strtotime($datetime).'?exclude=minutely,hourly,daily,alerts&units=ca&lang='.$locale); + // $JSON = $this->get_web_page('https://api.darksky.net/forecast/'.$settings['weather_module_api_key'].'/'.$lat.','.$lng.','.strtotime($datetime).'?exclude=minutely,hourly,daily,alerts&units=ca&lang='.$locale); + $JSON = $this->get_web_page('https://api.weatherapi.com/v1/forecast.json?key='.$settings['weather_module_api_key'].'&q='.$lat.','.$lng); $data = json_decode($JSON, true); return (isset($data['currently']) ? $data['currently'] : false); diff --git a/app/modules/weather/details.php b/app/modules/weather/details.php index 5c200dd7..924401be 100644 --- a/app/modules/weather/details.php +++ b/app/modules/weather/details.php @@ -30,53 +30,53 @@ $weather = $this->get_weather($lat, $lng, $date); $imperial = (isset($settings['weather_module_imperial_units']) and $settings['weather_module_imperial_units']) ? true : false; -// Weather not found! -if(!is_array($weather) or (is_array($weather) and !count($weather))) return; ?>
-

+

- + + >
- -
+ +
- -
- - - weather_unit_convert($weather['temperature'], 'C_TO_F'); ?> - - + +
+ + + weather_unit_convert($weather['temp_c'], 'C_TO_F'); ?> + +
+
- +
- -
: weather_unit_convert($weather['windSpeed'], 'KM_TO_M');?>
+ +
: weather_unit_convert($weather['wind_kph'], 'KM_TO_M');?>
-
:
+
:
- -
: weather_unit_convert($weather['visibility'], 'KM_TO_M');?>
+ +
: weather_unit_convert($weather['vis_km'], 'KM_TO_M');?>
From b5e8771897046e34d2fcd59ffbc990238b3ce588 Mon Sep 17 00:00:00 2001 From: Andy Pearson Date: Sun, 14 Jun 2020 15:33:41 +0100 Subject: [PATCH 2/3] Switch to lite --- app/modules/weather/details.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/modules/weather/details.php b/app/modules/weather/details.php index 924401be..3057d856 100644 --- a/app/modules/weather/details.php +++ b/app/modules/weather/details.php @@ -32,7 +32,7 @@ ?>
-

+

@@ -49,11 +49,11 @@ -
+
- + weather_unit_convert($weather['temp_c'], 'C_TO_F'); ?> - +
@@ -62,21 +62,21 @@
- +
-
: weather_unit_convert($weather['wind_kph'], 'KM_TO_M');?>
+
: weather_unit_convert($weather['wind_kph'], 'KM_TO_M');?>
-
:
+
:
-
: weather_unit_convert($weather['vis_km'], 'KM_TO_M');?>
+
: weather_unit_convert($weather['vis_km'], 'KM_TO_M');?>
From c87d240c56cb1f2dfecbad77aade142bd2eade7f Mon Sep 17 00:00:00 2001 From: Andy Pearson Date: Sun, 14 Jun 2020 15:35:13 +0100 Subject: [PATCH 3/3] Add result check back --- app/modules/weather/details.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/modules/weather/details.php b/app/modules/weather/details.php index 3057d856..c61afecd 100644 --- a/app/modules/weather/details.php +++ b/app/modules/weather/details.php @@ -30,6 +30,8 @@ $weather = $this->get_weather($lat, $lng, $date); $imperial = (isset($settings['weather_module_imperial_units']) and $settings['weather_module_imperial_units']) ? true : false; +// Weather not found! +if(!is_array($weather) or (is_array($weather) and !count($weather))) return; ?>