Author Topic: ec-radar.php script dead due to Environment Canada website changes  (Read 1565 times)

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 156
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
It looks like Environment Canada has change the radar presentation to use a map-based version, and is no longer generating the images needed by the ec-radar.php script for operation.

I've started working on a replacement script, but for now, the old script is dead :(
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

saratogaWX

  • Strong Breeze
  • ***
  • Posts: 156
  • Weather website programming enthusiast
    • Saratoga-Weather.org
  • Station Details: Davis VP1 +, iMAC 21, OSX 10.6.8
Re: ec-radar.php script dead due to Environment Canada website changes
« Reply #1 on: April 14, 2021, 07:17:43 PM »
Replacement scripts DONE!

I've shamelessly stolen the HAniS animation script set from Jerry Wilkins (thanks Jerry!) and with a tip from a Twitter follower, located a new set of Environment Canada radar .gif images that are being updated.

Use the update tool for Base-Canada, Plugin-*, 14-Apr-2021 to get the script set.

Note:  you'll need to do changes to index.php (but an updated wxindex.php is included).  Here's the 'README-wxecradar.txt' contents:

Quote
This is the README file for wxecradar scripts (Environment Canada Radar display using HAniS).

As of 30-Mar-2021, Environment Canada changed their Radar website to use a map to display radar information, and
stopped publishing radar images as .gif files on their main website.  This rendered the former display script
of ec-radar.php obsolete and non-functional (since the images were no longer available).

Fortunately, the radar .gif images continue to be published on https://dd.weather.gc.ca/radar/PRECIPET/GIF/{sitename}/
BUT sadly, they no longer have the detail overlays of towns, highways, rivers on the new maps. So, the new .gif
radar images are a bit sparse but do otherwise display the 14-color versions of the original .gif images.

Contents:
  wxradar.php       (the linked-to script from the menu for radar display in Base-Canada template)
  wxecradar-inc.php (provides selection capability and <iframe> for HAniS display)
  wxecradar-iframe.php (provides contents to display in the <iframe>)
  wxecradar-list-inc.php  (list of current radar stations for display)
  hanis_min.js      (the HAniS script)
  wxindex.php       (updated to use wxecradar-iframe.php to display a radar image set)

All the files should be in the same directory (normally, the document root of the website).

If manually converting from an older wxindex.php to the new one, just replace:

------
         <?php
         // fetch fresh national radar image if needed .. you can chang it to
         // 'NAT' = National radar view
         // 'PAC' = Pacific region
         // 'WRN' = Praries region
         // 'ONT' = Ontario
         // 'QUE' = Quebec
         // 'ERN' = Atlantic region
           $_REQUEST['site'] = 'NAT'; // one of the sites above, or your radar designator
           $doPrint = false;
           include_once("ec-radar.php");
         ?>
         <img src="<?php echo $radarDir . 'radar-' . $_REQUEST['site'] . '-0.png'; ?>"
         alt="Radar, courtesy of Environment Canada"
         title="Radar, courtesy of Environment Canada" />
------

with

------
         <?php
         // fetch national radar image if needed
         // 'PYR' = Pacific region
         // 'PNR' = Praries region
         // 'ONT' = Ontario
         // 'QUE' = Quebec
         // 'ATL' = Atlantic region
         // or use the local radar site code like WKR or CASET .. see wxecradar-list-inc.php for codes

           $radarLoc = 'ONT';
            
         //  $radarLoc = $SITE['ecradar']; // use Settings.php entry   
            $radar='RAIN'; // ='RAIN' or ='SNOW';
         ?>
<iframe name="wxradarshanis" width="617" height="<?php echo (in_array($radarLoc,array('PYR','PNR','ONT','QUE','ATL')))?'380':'555';?>" src="./wxecradar-iframe.php?radar=<?php echo $radar?>&amp;radarLoc=<?php echo $radarLoc?>&amp;lang=<?php echo $SITE['lang']; ?>" scrolling="no" style="border:none"></iframe>
------

Your Settings.php entry of:

  $SITE['ecradar'] = 'WKR';

will determine the selected site in wxradar.php display

--------------

See the running version at Saratoga Base-Canada Demo.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis Vantage Pro Plus - FARS, Boltek-PCI/NexStorm, GRLevel3, WD, WL, VWS, Cumulus, Meteohub, WeatherSnoop, WeatherCat
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP