Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.3.0 (build 3063) - 10 January 2020.
    Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

    See the Wiki for downloading either version.

    Base-Canada users -- ec-forecast/ec-radar being updated...

    Discussion of Ken True's web site templates

    Moderator: saratogaWX

    Post Reply
    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Base-Canada users -- ec-forecast/ec-radar being updated...

    Post by saratogaWX » Tue 16 Apr 2013 8:07 pm

    Looks like the Environment Canada website has made some changes and I'm updating the ec-forecast.php and ec-radar.php scripts to support the changes.

    I'll let you know when the updates are ready.

    Best regards,
    Ken

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Tue 16 Apr 2013 11:09 pm

    I have completed the needed mods to ec-forecast.php (V2.14 - 16-Apr-2012)

    Standalone users: get source or package from http://saratoga-weather.org/scripts-ECf ... ECforecast
    Template users: use http://saratoga-weather.org/wxtemplates/updates.php for Base-Canada, 16-Apr-2013

    Note: The EC has switched to using UTF-8 for their website so to retain the output as ISO-8859-1, a lot of iconv() calls
    were added to the code. I found at least one instance of the EC posting text with mixed UTF-8 and ISO-8859-1 special characters which chokes the current PHP versions of iconv() .. so if you see a detailed forecast with funny characters in it,
    that's the native UTF-8 showing as the iconv() failed .. hopefully, the EC folks will use UTF-8 throughout their forecasts so that issue should be few and far between.
    Also, the URLs changed from weatheroffice.gc.ca to weather.gc.ca .. if you use $ECURLs with the old address, the code will replace 'weatheroffice' with 'weather' in the URL so it should work fine.

    After loading up the new ec-forecast.php on your site, run the page with ?cache to refresh the cache file and your forecasts should display again.

    I should have a fix for the ec-radar issue(s) tomorrow (17-Apr-2013)

    Best regards,
    Ken

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Thu 18 Apr 2013 3:30 am

    I have finished with the updates to support Environment Canada's new website design. :D

    ec-forecast.php V1.15 - 17-Apr-2013
    fixes the $title issue so alerts will show the name of the city
    Standalone users: get source or package from http://saratoga-weather.org/scripts-ECf ... ECforecast

    ec-radar.php V1.09 - 17-Apr-2013
    changes for new EC website design, UTF-8 to ISO-8859-1 conversion and a modified method for the /radar/ directory
    Standalone users: get source or package from http://saratoga-weather.org/scripts-ECradar.php#ECradar

    Template users can get both scripts using the update tool for Base-Canada, 17-Apr-2013

    Best regards,
    Ken

    Template users: use http://saratoga-weather.org/wxtemplates/updates.php for Base-Canada, 16-Apr-2013

    User avatar
    PaulMy
    Posts: 2043
    Joined: Sun 28 Sep 2008 11:54 pm
    Weather Station: Davis Vantage Pro 2+ w/Envoy USB
    Operating System: Windows-8
    Location: Komoka, ON Canada
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by PaulMy » Thu 18 Apr 2013 4:55 am

    Well done again Ken. Thanks very much for being on top of those things.

    Paul

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Thu 18 Apr 2013 4:47 pm

    Did a fix for the wxadvisory.php page to correct URLs and resize the graphic if need be. The new main copy contents are

    Code: Select all

    <div id="main-copy">
      
      
      <div align="center">       
    	<?php 
    		 $doInclude	   = true; // handle ec-forecast and WXSIM include also
    		 $doPrint	   = false; //  ec-forecast.php setting
    		 include_once($SITE['fcstscript']);
    		 if ($alertstring <> '') { 
    		 print $alertstring; // will produce alert box with link if advisories found
    		 } else { 
    		 print "<p class=\"advisoryBox\">".langtransstr("No watches or warnings in effect for")." $title.</p>\n"; 
    		 }
    	?>
    <?php 
    if(preg_match('|narrow|',$SITE['CSSscreen'])) {
    	$wtext = 'width="610" height="523"'; 
    } else {
    	$wtext = 'width="852" height="731"'; 
    }
    if($SITE['lang'] == 'fr') {$L = 'f'; } else {$L = 'e'; } ?>
    <a href="http://weather.gc.ca/warnings/index_<?php echo $L; ?>.html" style="border: none">
    <img src="http://weather.gc.ca/data/download/canada.png" style="border:none;" <?php echo $wtext; ?> alt="national advisories"/></a>
    <?php if($SITE['lang'] == 'fr') { $legend = 'CanadaLegend-fr.gif'; } else { $legend = 'CanadaLegend-en.gif'; } ?>
    <img src="<?php echo $legend;?>" alt="National Advisory Legend" title="National Advisory Legend"/>
    <?php print "<p><a href=\"$ECURL\">$ECNAME</a></p>\n"; ?>
      </div>
      
      
    </div><!-- end main-copy -->
    
    or you can get the update from the updates tool page (Base-Canada, 18-Apr-2012)

    Best regards,
    Ken

    User avatar
    PaulMy
    Posts: 2043
    Joined: Sun 28 Sep 2008 11:54 pm
    Weather Station: Davis Vantage Pro 2+ w/Envoy USB
    Operating System: Windows-8
    Location: Komoka, ON Canada
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by PaulMy » Fri 19 Apr 2013 12:13 am

    Hi Ken,
    I did the wxadvisory update and that also works well. One issue I have now encountered though. A few weeks ago I made wxradar and ec-radar php files for each of the 31 EC radar sites by modifying those files with each site's specific letter code and renaming, such as wxradar.php change the include_once to 'WBI' and save as wxradar-wbi.php, and the same for the ec-radar.php change the $siteID = 'WBI' and save as ec-radar-wbi.php. Then I had each as a separate line in the flyout-menu and looked good and worked well.

    However, since the changes that have been to the templates in the past days I can not get the new wxradar-???.php to display that site's radar but instead it shows the default as in the Settings.php. I am only showing 3 radar sites on my site at the moment until I can get this working again. By entering the url with ec-radar-???.php http://www.komokaweather.com/ec-radar-wbi.php it loads that specific site's radar map so I have the template working. Likely just a setting change needed somewhere to override the default from Settings.php?

    As was pointed out a few weeks ago there is an better/easier way to accomplish what I wanted, but my knowledge and understanding is not there as yet to know how to tackle that so I used the individual files method :oops:

    Thanks for any hint you can give me again.
    Paul

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Fri 19 Apr 2013 7:04 pm

    Hi Paul,

    There is a simpler way to make the different radar sites use the same base wxradar.php page.

    http://www.komokaweather.com/wxradar.php will show your default page
    adding ?site=SSS to the URL in links will cause it to show the requested site like:

    http://www.komokaweather.com/wxradar.php?site=ONT shows the Ontario sites
    http://www.komokaweather.com/wxradar.php?site=NAT shows the big National sites

    Any of the regional or national site have hotlinks built into the map and clicking on them will do the same thing.. show the requested site.

    So.. if you want a list of all the sites to be linked, just insert them in your flyout-menu.xml with link="wxradar.php?site=SSS" in the <item /> entries.

    So.. no fuss or bother with editing multiple copies of the script are needed to do what you want :)

    Hope this helps...

    Best regards,
    Ken

    User avatar
    PaulMy
    Posts: 2043
    Joined: Sun 28 Sep 2008 11:54 pm
    Weather Station: Davis Vantage Pro 2+ w/Envoy USB
    Operating System: Windows-8
    Location: Komoka, ON Canada
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by PaulMy » Sat 20 Apr 2013 2:49 am

    Yes that was very helpful and thank you again. Made the change to flyout-menu and got them all listed, plus the regional sites. This was so much easier but then one doesn't learn as well if it is all easy.

    Paul

    Fox
    Posts: 1
    Joined: Tue 22 Nov 2011 6:15 pm
    Weather Station: WS-1090
    Operating System: Win 7 x64/Server 2k3
    Location: Canada

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by Fox » Sun 28 Apr 2013 5:54 pm

    I updated the forecast images to the new, more modern pictures used by EC. I ended up using .png, so you have to change the replace_icon function if anyone wants to use them:

    Code: Select all

    function replace_icon($icon,$pop) {
    // now replace icon with spiffy updated icons with embedded PoP to
    //    spruce up the dull ones from www.weatheroffice.ec.gc.ca 
      global $imagedir;
    			  
      $curicon = $icon;
      if ($pop > 0) {
    	$testicon = preg_replace("|.gif|","p$pop.gif",$curicon);
    	if (file_exists("$imagedir/$testicon")) {
    	  $newicon = $testicon;
    	} else {
    	  $newicon = $curicon;
    	}
      } else {
    	$newicon = $curicon;
      }
      return($newicon);  
    }
    to

    Code: Select all

    function replace_icon($icon,$pop) {
    // now replace icon with spiffy updated icons with embedded PoP to
    //    spruce up the dull ones from www.weatheroffice.ec.gc.ca 
      global $imagedir;
    			  
      $curicon = $icon;
      if ($pop > 0) {
    	$testicon = preg_replace("|.gif|","p$pop.png",$curicon);
    	if (file_exists("$imagedir/$testicon")) {
    	  $newicon = $testicon;
    	} else {
    	  $newicon = $curicon;
    	}
      } else {
    	$newicon = preg_replace("|.gif|",".png",$curicon);
      }
      return($newicon);  
    }
    Icons here: http://foxed.ca/cumulus/ec-icons.zip

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Sun 28 Apr 2013 9:40 pm

    Nicely done! :clap:

    The new icons look great. I'll put a variable in ec-forecast.php to allow setting the type of icon (.gif or .png) for the next update.

    Thanks again for sharing your created icons from the new EC site set.

    Best regards,
    Ken

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Tue 14 May 2013 5:35 am

    I've done a major update to ec-forecast.php (now at V2.16 - 13-May-2013) which includes the following changes:

    * settings to control display of dates with day names for both icons and detail forecast legends
    * ability to use new transparent PNG icons in place of the older GIF icons
    * improved diagnostics for HTTP fetch from weather.gc.ca website, and a built-in retry for a 30x redirect
    * multiple forecast locations with drop-down control selector
    * support for cache files in the $SITE['CacheFileDir'] location

    You can install the V2.16+ version to directly replace your older version in the template with no additional
    configuration necessary. If you would like to enable the newer features (like day/date, PNG icons, multiple
    forecast locations) then copy the following to your template Settings.php and make the configuration changes
    you desire.

    Add this to your Settings.php after the $SITE['fcsticonsdirEC'] entry

    Code: Select all

    # --- new settings with ec-forecast.php V2.16+
    $SITE['ECiconDayDate'] = false;        // =false; Icon names = day of week. =true; icon names as Day dd Mon
    $SITE['ECdetailDayDate'] = false;      // =false; for day name only, =true; detail day as name, nn mon. 
    $SITE['ECiconType'] = '.gif';            // ='.gif' or ='.png' for ec-icons file type 
    // Note: for .png, make sure you have installed the PNG icons in the $SITE['fcsticonsdirEC'] directory
    //
    // The optional multi-city forecast .. make sure the first entry is for the $SITE['fcsturlEC'] location
    //*
    $SITE['ECforecasts'] = array(
     // Location|forecast-URL  (separated by | character)
    'St. Catharines, ON|http://weather.gc.ca/city/pages/on-107_metric_e.html', // St. Catharines, ON
    'Vancouver, BC|http://weather.gc.ca/city/pages/bc-74_metric_e.html',
    'Calgary, AB|http://weather.gc.ca/city/pages/ab-52_metric_e.html',
    'Regina, SK|http://weather.gc.ca/city/pages/sk-32_metric_e.html',
    'Winnipeg, MB|http://weather.gc.ca/city/pages/mb-38_metric_e.html',
    'Ottawa (Kanata - Orléans), ON|http://weather.gc.ca/city/pages/on-118_metric_e.html',
    'Montréal, QC|http://weather.gc.ca/city/pages/qc-147_metric_e.html',
    'Happy Valley-Goose Bay, NL|http://weather.gc.ca/city/pages/nl-23_metric_e.html',
    'St. John\'s, NL|http://weather.gc.ca/city/pages/nl-24_metric_e.html',
    'Fredericton, NB|http://weather.gc.ca/city/pages/nb-29_metric_e.html',
    'Halifax, NS|http://weather.gc.ca/city/pages/ns-19_metric_e.html',
    'Charlottetown, PE|http://weather.gc.ca/city/pages/pe-5_metric_e.html',
    'Whitehorse, YT|http://weather.gc.ca/city/pages/yt-16_metric_e.html',
    'Yellowknife, NT|http://weather.gc.ca/city/pages/nt-24_metric_e.html',
    'Resolute, NU|http://weather.gc.ca/city/pages/nu-27_metric_e.html',
    'Iqaluit, NU|http://weather.gc.ca/city/pages/nu-21_metric_e.html',
    ); 
    
    //*/ 
    # --- end of new settings with ec-forecast.php V2.16+
    
    The new transparent PNG format icons are courtesy of Thayer Fox at http://foxed.ca/ who has given
    his kind permission to distribute them from the Saratoga-Weather.org website.
    http://saratoga-weather.org/ec-icons-png.zip -- the icons should be placed in the same directory as the old .GIF icons.

    Saratoga template users can get the update from the update tool page for Base-Canada, 13-May-2013

    Standalone users should use the scripts page for download.

    Best regards,
    Ken

    gemini06720
    Posts: 1700
    Joined: Mon 10 Aug 2009 10:16 pm
    Weather Station: No weather station
    Operating System: No operating system
    Location: World...

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by gemini06720 » Wed 15 May 2013 9:04 pm

    Ken, it appears that, once again, Environment Canada has made some additional changes to their forecast pages - I just checked (at 13:45 PDT) both your 'demo' and 'in-page demo' and get the same negative results.

    A while back, I wrote to the people at Environment Canada and one of the administrators suggested that I get the up-to-date weather data from their XML templates - he gave me the following link to obtain the required templates: 'Index of /citypage_weather'.

    I believe that using the XML data templates would certainly involve a complete rewrite of the 'ec-forecast' script, but it is also my understanding from my additional communications with the administrator at Environment Canada that using the XML templates would prevent also the situations you and I are encountering whenever some changes/modifications are made to display/presentation the Environment Canada pages - might it be worth to invest some of your time in order to eliminate/suppress the dependency on extracting data from an ever changing HTML page... :|

    User avatar
    saratogaWX
    Posts: 1012
    Joined: Wed 06 May 2009 5:02 am
    Weather Station: Davis Vantage Pro Plus
    Operating System: Windows 10 Professional
    Location: Saratoga, CA, USA
    Contact:

    Re: Base-Canada users -- ec-forecast/ec-radar being updated.

    Post by saratogaWX » Wed 15 May 2013 11:46 pm

    Sigh.. just when we thought is was going to work for awhile, the EC webmaster fiddled slightly with the HTML markup and broke the script again. :shock: :roll:

    But.. it's all fixed now with V2.17 - 15-May-2013 :D

    Template users: use the updates tool page for Base-Canada, 15-May-2013

    Standalone users: use the ec-forecast.php scripts page for the download link.

    Ray, thanks for the info link on an XML forecast .. I'll take a look at that, and if it provides the same info, I'll work up a V3 script to use it instead. Pesky webmasters at EC seem to enjoy tweaking the generated HTML for their page. :bash:

    Best regards,
    Ken

    Post Reply