Author Topic: ec-forecast.php V5.00 beta -- it's all XML parsing now :)  (Read 3923 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« on: September 20, 2017, 06:38:41 PM »
I did a bit of coding on vacation and after our return to switch ec-forecast.php V4+ to use the XML data feeds from the EC instead of page-scraping the raw HTML from the Environment Canada website.  I must say, the effort was worth it, and my thanks to Wim of Leuven Templates for the encouragement (and some examples in his script) to make the switch.

The chief obstacle for me was backward compatibility -- the current (and now the new) script uses the EC website URL for the forecast page, and I wasn't going to change that.  Instead, I found two files (one XML, one JSON) on the EC sites that allowed me to create a lookup table of EC page-id to the XML filename, and so I've added a required file (ec-forecast-lookup.txt) to the kit.  The V5.0 script will 'gripe' at you if that file is not in the same directory as ec-forecast.php, OR if you have an EC URL that the page-id is not in the lookup table.  Currently, I think I have all the pages indexed, except for the seasonally-available ones, so you should be good to give it a try.

These are the seasonally-available forecast entries that are not currently supported
Code: [Select]
..11 errors in merge of XML and JSON files found.
--missing JSON for 'HEF Coquihalla Highway - Hope to Merritt' -> 's0000846' in XML file
--missing JSON for 'HEF Coquihalla Highway - Merritt to Kamloops' -> 's0000847' in XML file
--missing JSON for 'HEF Highway 16 - Smithers to Terrace' -> 's0000848' in XML file
--missing JSON for 'HEF Highway 3 - Hope to Princeton via Allison Pass' -> 's0000849' in XML file
--missing JSON for 'HEF Highway 3 - Paulson Summit to Kootenay Pass' -> 's0000850' in XML file
--missing JSON for 'HEF Highway 97 - Clinton to 100 Mile House via Begbie Summit' -> 's0000851' in XML file
--missing JSON for 'HEF Highway 97 - Pine Pass' -> 's0000852' in XML file
--missing JSON for 'HEF Okanagan Connector - Merritt to Kelowna' -> 's0000853' in XML file
--missing JSON for 'HEF Sea to Sky - Squamish to Whistler' -> 's0000854' in XML file
--missing JSON for 'HEF Sea to Sky - West Vancouver Upper Levels to Squamish' -> 's0000855' in XML file
--missing JSON for 'HEF Trans-Canada Highway - Eagle Pass to Rogers Pass' -> 's0000856' in XML file

Download Script: https://saratoga-weather.org/wxtemplates/Canada/ec-forecast-V5.php?sce=view
Download Table:  https://saratoga-weather.org/wxtemplates/Canada/ec-forecast-lookup.txt

If you want to play with the beta, download both files and upload both files to your website.  If you're running standalone (not under the Saratoga template), then make your required changes to the settings area.  For Saratoga templates, the script will use your existing settings from Settings.php for operation.

To switch a Saratoga site to use the new script, just change Settings.php
Code: [Select]
$SITE['fcstscript']   = 'ec-forecast.php';    // Canada forecasts from Environment Canada
to
Code: [Select]
$SITE['fcstscript']   = 'ec-forecast-V5.php';    // Canada forecasts from Environment Canada
and the new script can co-exist with the V4 ec-forecast.php script.

Some differences to be aware of:
1) the XML doesn't have an 'abnormal temperatures' indicator (at least not one I could find in the XML or docs), so the legacy '*' after a temperature won't appear.
2) the XML files are stored in your specified cache directory with the name 'ec-forecast-{n}-{page-id}-{XMLfilename}-{lang}.txt' so they won't clobber any existing 'ec-forecast-{n}-{lang}.txt' caches used by the V4.x script.  The XML files are stored as content-only (no HTTP headers), unlike the full headers+content stored in the cache file with the V4.x script.
3) the ability to display short day names and or dates in the titles is not included in the script -- that data just wasn't readily available in the XML.
4) the $alertstring for alerts should be filled in correctly for multiple alerts (works for one alert), but... there's not an active alert in all of Canada that has more than one alert for me to test with.. more testing on that when the data becomes available.
5) this is really just a N.B., but the EC uses a bit of funkyness in the text weather descriptions.  Per the encoding="ISO-8859-1" on the XML, they mix both UTF-8 and ISO-8859-1 characters with diacritical marks in the string.  Guaranteed to blow up an iconv() call.  I've added a function to the script which replaces all the (rogue) characters with UTF-8 strings so the iconv() from UTF-8->ISO-8859-1 for the template works as expected.


Let me know how the testing works out and any errors that you find.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #1 on: September 21, 2017, 12:24:53 AM »
Hi Ken and thanks for your continued work on this while traveling.

I have uploaded the 2 files and changed Settings.php to use ec-forecast-V5.php.
http://www.komokaweather.ca/check-fetch-times.php?show=versions still shows ver 4.03 for me but having some difficulty getting my pages to come up so may be a GoDaddy issue.
My http://www.komokaweather.ca/wxforecast.php seems to be working but getting too late to check further. 

Regards,
Paul

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #2 on: September 21, 2017, 12:53:28 AM »
Hi Paul,
Thanks for trying it out.

Your site is running the V5 script, but it won't show up on the check-fetch-times.php?show=versions for two reasons:]
1) the file 'ec-forecast-V5.php' isn't 'known' as part of the check-fetch-times.php set of core files and
2) the Update tool/master-file-list used is based on the distributed files in Base-Canada.zip (and the script is not replaced there yet). 
So.. no worries.

looking at http://www.komokaweather.com/komokaweather-ca/wxforecast.php?lang=fr# (the real, non-framed page) shows a problem with the French display.  Checking your installed ec-forecast-V5.php, I see the magic translate area is messed up.
Your version shows
Code: [Select]
function ECF_UTF_CLEANUP ($str) {
// Clean embedded ISO-8859-1 characters with UTF-8 replacements so iconv can work.
// EC is a bit lazy about mixing character sets in descriptions.

$cstr = str_replace(
  // ISO-8859-1 characters
array('À',' ','Â','â','Æ','æ',
'Ç','ç',
'É','é','È','è','Ê','ê','Ë','ë',
'Î','î','Ï','ï',
'Ô','ô','Œ','œ',
'Ù','ù','Û','û','Ü','ü',
'Ÿ','ÿ'),
// UTF-8 characters represented as ISO-8859-1
array('À','à ','Â','â','à ','æ',
'Ç','ç',
'É','é','È','è','à ','ê','Ë','ë',
'Î','î','Ï','ï',
'Ô','ô','Œ','œ',
'Ù','ù','Û','û','Ü','ü',
'Ÿ','ÿ'),
$str);
return($cstr);
}
when it should be
Code: [Select]
function ECF_UTF_CLEANUP ($str) {
// Clean embedded ISO-8859-1 characters with UTF-8 replacements so iconv can work.
// EC is a bit lazy about mixing character sets in descriptions.

$cstr = str_replace(
  // ISO-8859-1 characters
array('','','','','','',
'','',
'','','','','','','','',
'','','','',
'','','','',
'','','','','','',
'',''),
// UTF-8 characters represented as ISO-8859-1
array('À',' ','Â','â','Æ','æ',
'Ç','ç',
'É','é','È','è','Ê','ê','Ë','ë',
'Î','î','Ï','ï',
'Ô','ô','Œ','œ',
'Ù','ù','Û','û','Ü','ü',
'Ÿ','ÿ'),
$str);
return($cstr);
}
there.

Please try downloading https://saratoga-weather.org/wxtemplates/Canada/ec-forecast-V5-beta.zip, unzip the files and upload them to the site -- that should fix the odd recoding of the translate fix-up function that's causing the odd characters in the French display.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #3 on: September 21, 2017, 04:08:35 AM »
A little correction in the procedure to get the printable forecast - the link 'http://weather.gc.ca/' is outdated and brings one to the 'Government of Canada/Gouvernement du Canada' main Weather Information page/site. The correct link to the Canadian Weather page/site (where the map is located as well as the provinces and some major cities) should be 'https://weather.gc.ca/canada_e.html' - the language can also be chosen at the top-right side of all 'Government of Canada/Gouvernement du Canada' web pages.
R_o_B
---
eMail: weather@herray.net

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #4 on: September 21, 2017, 07:24:31 AM »
Hi Ken,
I have uploaded the new beta files and seems ok www.komokaweather.ca.  I am away for the day so will not get a chance to follow up further until this evening.

Paul

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #5 on: September 21, 2017, 10:43:12 AM »
A little correction in the procedure to get the printable forecast - the link 'http://weather.gc.ca/' is outdated and brings one to the 'Government of Canada/Gouvernement du Canada' main Weather Information page/site. The correct link to the Canadian Weather page/site (where the map is located as well as the provinces and some major cities) should be 'https://weather.gc.ca/canada_e.html' - the language can also be chosen at the top-right side of all 'Government of Canada/Gouvernement du Canada' web pages.
Thanks Ray,
I've changed the comments to read
Code: [Select]
//  Go to https://weather.gc.ca/canada_e.html and select your language (sorry, I don't
//  speak French, so these instructions are all in English)
//
//  Click on your province on the map.
//  Choose a location and click go from the menu on the right.
//
//  Copy the URL of the forecast page for your city, and paste it into $ECURL   

Hi Ken,
I have uploaded the new beta files and seems ok www.komokaweather.ca.  I am away for the day so will not get a chance to follow up further until this evening.

Paul
I just checked the page on your site, and the French is now displaying without garbled characters :)

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #6 on: September 21, 2017, 12:33:27 PM »
I did a mod to the ECF_UTF_CLEANUP() function to prevent the issue that Paul had with the French translation garbled characters due to the translation table not remaining in ASCII/ISO-8859-1 format.  The new code is
Code: [Select]
<?php
function ECF_UTF_CLEANUP ($str) {
// Clean embedded ISO-8859-1 characters with UTF-8 replacements so iconv can work.
// EC is a bit lazy about mixing character sets in descriptions.
/*
// we need to use an array like this, but sometimes this script will not be
// saved as ASCII/ISO-8859-1, and the array of characters gets garbled.

$trantab = array(
  'ISO' =>
array('','','','','','',
 '','',
 '','','','','','','','',
 '','','','',
 '','','','',
 '','','','','','',
 '',''),
// UTF-8 characters represented as ISO-8859-1
'UTF' =>
array('À',' ','Â','â','Æ','æ',
 'Ç','ç',
 'É','é','È','è','Ê','ê','Ë','ë',
 'Î','î','Ï','ï',
 'Ô','ô','Œ','œ',
 'Ù','ù','Û','û','Ü','ü',
 'Ÿ','ÿ'),
);
// so we used the following to encode it:

$serialized = serialize($trantab);
$base64 = base64_encode($serialized);

// and used the output of the base64_encode in the define() statement below.
// then we reconstitute the array with perfect fidelity using 
//   $trantab = unserialize(base64_decode(ISO_UTF_ARRAY));
// below.
*/
if(!defined('ISO_UTF_ARRAY')) {
define('ISO_UTF_ARRAY',
'YToyOntzOjM6IklTTyI7YTozMjp7aTowO3M6MToiwCI7aToxO3M6MToi4CI7aToyO3M6MToi 
wiI7aTozO3M6MToi4iI7aTo0O3M6MToixiI7aTo1O3M6MToi5iI7aTo2O3M6MToixyI7aTo3 
O3M6MToi5yI7aTo4O3M6MToiySI7aTo5O3M6MToi6SI7aToxMDtzOjE6IsgiO2k6MTE7czox 
OiLoIjtpOjEyO3M6MToiyiI7aToxMztzOjE6IuoiO2k6MTQ7czoxOiLLIjtpOjE1O3M6MToi 
6yI7aToxNjtzOjE6Is4iO2k6MTc7czoxOiLuIjtpOjE4O3M6MToizyI7aToxOTtzOjE6Iu8i 
O2k6MjA7czoxOiLUIjtpOjIxO3M6MToi9CI7aToyMjtzOjE6IowiO2k6MjM7czoxOiKcIjtp 
OjI0O3M6MToi2SI7aToyNTtzOjE6IvkiO2k6MjY7czoxOiLbIjtpOjI3O3M6MToi+yI7aToy 
ODtzOjE6ItwiO2k6Mjk7czoxOiL8IjtpOjMwO3M6MToinyI7aTozMTtzOjE6Iv8iO31zOjM6 
IlVURiI7YTozMjp7aTowO3M6Mjoiw4AiO2k6MTtzOjI6IsOgIjtpOjI7czoyOiLDgiI7aToz 
O3M6Mjoiw6IiO2k6NDtzOjI6IsOGIjtpOjU7czoyOiLDpiI7aTo2O3M6Mjoiw4ciO2k6Nztz 
OjI6IsOnIjtpOjg7czoyOiLDiSI7aTo5O3M6Mjoiw6kiO2k6MTA7czoyOiLDiCI7aToxMTtz 
OjI6IsOoIjtpOjEyO3M6Mjoiw4oiO2k6MTM7czoyOiLDqiI7aToxNDtzOjI6IsOLIjtpOjE1 
O3M6Mjoiw6siO2k6MTY7czoyOiLDjiI7aToxNztzOjI6IsOuIjtpOjE4O3M6Mjoiw48iO2k6 
MTk7czoyOiLDryI7aToyMDtzOjI6IsOUIjtpOjIxO3M6Mjoiw7QiO2k6MjI7czoyOiLFkiI7 
aToyMztzOjI6IsWTIjtpOjI0O3M6Mjoiw5kiO2k6MjU7czoyOiLDuSI7aToyNjtzOjI6IsOb 
IjtpOjI3O3M6Mjoiw7siO2k6Mjg7czoyOiLDnCI7aToyOTtzOjI6IsO8IjtpOjMwO3M6Mjoi 
xbgiO2k6MzE7czoyOiLDvyI7fX0='
);
}
//reconstitute our trantab from the base64 encoded serialized value
//so we won't have issues if someone inadvertantly saves this script as
// UTF-8 instead of ASCII/ISO-8859-1
//
$trantab unserialize(base64_decode(ISO_UTF_ARRAY));

$cstr str_replace(
  
// ISO-8859-1 characters
$trantab['ISO'],
// UTF-8 characters represented as ISO-8859-1
$trantab['UTF'],
$str); 
return($cstr);
}

While I dislike having to rely on a base64_decode to reconstitute the $trantab array, it will ensure that that array/table won't be changed.   I changed the update date to 21-Sep-2017, version still 5.00. Also, Ray's comment changes included.
Attached is the new .zip
« Last Edit: September 21, 2017, 01:08:34 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #7 on: September 22, 2017, 08:44:04 AM »
Ken, I have been going through the new code for the past two days, incorporating the changes you made into my own template. So far, I have not found anything to report (although I am probably only half way through the script - completed the '$currentConditions' section early Friday morning after adding more than a dozen+ new variables)  :-|.
R_o_B
---
eMail: weather@herray.net

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #8 on: September 22, 2017, 09:53:56 AM »
I have uploaded the latest beta files and looks fine www.komokaweather.ca/wxforecast.php

I don't speak French but all looks fine if franais selected

Enjoy,
Paul

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #9 on: September 22, 2017, 12:04:39 PM »
Ken, I have been going through the new code for the past two days, incorporating the changes you made into my own template. So far, I have not found anything to report (although I am probably only half way through the script - completed the '$currentConditions' section early Friday morning after adding more than a dozen+ new variables)  :-|.
Thanks for taking a look at the new script.  I'm guessing that the additions to $currentConditions you are adding are coming from the <almanac> section in the XML -- I'm planning on adding that as an option to the conditions area too.  The XML also includes a short-term hourly forecast that might be useful as a meteogram-type display.  More on that later...

I've revved the date on the ec-forecast-V5.php to 22-Sep-2017 and incorporated your setup comment changes.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #10 on: September 22, 2017, 09:19:01 PM »
I'm guessing that the additions to $currentConditions you are adding are coming from the <almanac> section in the XML...
Nope! I the additional variables consist of having the weather values without any formatting code and having the date/time in a Unix format so those variables can be more easily formatted/presented on my web pages.

As for the <almanac> section, I have  not  found any references of the displayed values to values displayed on the main EC weather pages - so far, I have no idea what they represent.  :oops:

The XML also includes a short-term hourly forecast that might be useful as a meteogram-type display.
The hourly forecasts will be included into my 'large/long' version of the script...  :-|
R_o_B
---
eMail: weather@herray.net

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #11 on: September 22, 2017, 10:33:58 PM »
I've figured out the Almanac section and now produce a $almanac variable with that data in a box like the $currentConditions box.
I've placed it at the bottom of the page (above the link to the Environment Canada page).

Uploaded 5.00 - 22-Sep-2017 of the beta to the site.
« Last Edit: September 22, 2017, 10:40:07 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #12 on: September 22, 2017, 11:33:44 PM »
Thanks Ken, I like that new addition and have often wondered how that could be added.

However, I now get the following message in my dashboard www.komokaweather.ca
Quote
Notice:  Undefined offset: 1 in /home/content/96/5379896/html/komokaweather-ca/ajax-dashboard.php on line 1189
 
 Notice:  Undefined offset: 2 in /home/content/96/5379896/html/komokaweather-ca/ajax-dashboard.php on line 1190
 
 Notice:  Undefined offset: 3 in /home/content/96/5379896/html/komokaweather-ca/ajax-dashboard.php on line 1191
 New Moon

Probably nothing to do with the ec-forecast V5.00 beta.

Paul

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #13 on: September 23, 2017, 12:05:36 AM »
No, I think the issue in your ajax-dashboard.php is related to the code
Code: [Select]
function moonphase ($WDmoonage) {

  preg_match_all('|(\d+)|is',$WDmoonage,$matches);
//  print "<!-- matches=\n" . print_r($matches,true) . "-->\n";
  $mdays = $matches[1][0];
  $mhours = $matches[1][1];
  $mmins = $matches[1][2];
  $mpct  = $matches[1][3];
...
but I don't know how that is happening..  You're correct, it is likely not an issue caused by ec-forecast-V5.php
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #14 on: September 23, 2017, 09:27:59 AM »
Hi Ken,
I changed Settings.php back to use ec-forecast.php instead of ec-forecast-V5.php and the notices disappeared.  Then changed again to use ec-forecast-V5.php and the Notices appear again.  No other changes made.  I repeated this change 3 times and with the same result each time.  Now using the ec-forecast-V5.php so you can have a look.

I have tried to compare my latest ec-forecast.php to ec-forecast-V5.php but due to so many differences, and not good in understanding code, am not able to see what difference may be causing the Notices.  Any suggestions?

Regards,
Paul

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #15 on: September 23, 2017, 09:48:35 AM »
Hi Paul,

Sorry.. I'd left
Code: [Select]
error_reporting(E_ALL); // uncomment for checking errata in code
active in the ec-forecast-V5.php

Change that to
Code: [Select]
//error_reporting(E_ALL); // uncomment for checking errata in code
to revert to your normal error_reporting settings.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #16 on: September 23, 2017, 10:04:29 AM »
Thanks Ken, all shows fine now http://www.komokaweather.ca/wxforecast.php

Enjoy,
Paul

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #17 on: September 23, 2017, 07:38:44 PM »
Yea!
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #18 on: September 23, 2017, 11:36:57 PM »
Well, I have (finally) finished integrating my modifications into the script, including the almanac. Unfortunately, there has not been any warning in my area, so that part of the code still needs to be further checked/proofed/tested.   :-s

My next integration will be the hourly forecasts. Then I have to cleanup the code and remove the 'way-too-many' comments I have placed into the code to allow me to better understand all the values found in the XML code.   [-o&lt;

I cannot remember having found any error with the original variables.   :-k
R_o_B
---
eMail: weather@herray.net

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #19 on: September 24, 2017, 11:12:47 AM »
I've found several locales that had alerts, including two that had multiple watches and a warning, and the alert code worked just fine to produce a combined warning box and a separate watch box on the display, so that appears to be all OK.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline chrisgrainger

  • Contributor
  • ***
  • Posts: 122
    • Top of The Rideau
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #20 on: September 25, 2017, 05:33:19 PM »
Hey Ken,


Been away for a while and just noticed this beta.  Have it installed and all seems to be working.  I like the new warnings and alerts display.  But...  how do you turn on the Averages and Extremes and where does the data come from?  Running Meteobridge here is that's the sticking point.


Chris

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #21 on: September 25, 2017, 06:10:43 PM »
Hi Chris,
The Averages and Extremes should automatically show if they are available for your selected forecast site.
Make sure you are running V5.00 - 22-Sep-2017 version. 
download from: https://saratoga-weather.org/wxtemplates/Canada/ec-forecast-V5.php?sce=view
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline chrisgrainger

  • Contributor
  • ***
  • Posts: 122
    • Top of The Rideau
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #22 on: September 25, 2017, 07:13:40 PM »
Thanks muchly, Ken.  I was a day early on my version of the script.  At first blush, it is working as advertised.


Cheers!


Chris

Offline chrisgrainger

  • Contributor
  • ***
  • Posts: 122
    • Top of The Rideau
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #23 on: September 25, 2017, 07:26:26 PM »
Hi Ken,


Is the Advisory section related to the V5.00 beta forecast code?  Since downloading the Sept 22 2017 version from your site per your sce=view link above, when clicking on any of the warning or advisory links on the page, I'm getting a yellow like of text saying, "A valid location ID code is required"


I'm assuming I missed something


Chris

Offline R_o_B

  • WxElement panel
  • Senior Member
  • *****
  • Posts: 85
Re: ec-forecast.php V5.00 beta -- it's all XML parsing now :)
« Reply #24 on: September 26, 2017, 08:04:39 AM »
I've found several locales that had alerts, including two that had multiple watches and a warning, and the alert code worked just fine to produce a combined warning box and a separate watch box on the display, so that appears to be all OK.
I do not (and did not) doubt that the code to produce the alerts/warnings had any problem...  ;)

It is just that, as usual, there is a lot more happening in my code than yours and I have not had any alert nor warning in my are to test the operation of the extra code.

I have also spent some time producing a script to extract and display the upcoming 24-hour forecasts - I put the finishing touches earlier this morning. Rather than including the code inside the 'ec-forecast.php' script, I have developed a fully autonomous script that not only check the age of the cache file, but also update the cache file, extract the forecasts for the upcoming 24 hours and display those forecasts on a separate web page thus does not cramp nor congest the normal forecast page.
R_o_B
---
eMail: weather@herray.net