Rewrite complete! ec-forecast.php V6.01 - 26-Oct-2024 is now available.
The major change is to use a JSON feed instead of the (deprecated) citypage XML for the display – the EC had dropped including alerts in the XML (so necessitating the rewrite).
The EC website no longer uses the city/page URLs, but has a new format with latitude,longitude. I’ve included code to use an existing lookup table, so all your existing city/page URLs should work fine (but may show slightly different locations due to lat,long fuzziness in the lookup).
OLD: $ECURL = ‘hxxps://weather.gc.ca/city/pages/on-77_metric_e.html’; # Old format
NEW $ECURL = ‘hxxps://weather.gc.ca/en/location/index.html?coords=43.258,-79.869’; # New Format
To add new sites, you’ll need to use the new format URLs (but you don’t need to change existing city/page URLs if they still display the forecast name for the location correctly).
The alerts (if any) are displayed as a mimic of the weather.gc.ca weather page – a colored bar (color by type of alert) with the alert name.
Clicking on the left icon, warning text, or right icon will cause the details of the alert to display. Ended alerts are not displayed.
The $alertstring works the same as the old versions (empty if no alerts otherwise fully formatted HTML+JavaScript to display the alerts).
Template users can use the update tool with query Base-Canada,*-Plugin, 26-Oct-2024
Standalone users can use GitHub distribution or the script page to download.
Let me know any issues either by this topic or email using Saratoga-Weather.org - Contact
Best regards,
Ken
Sample output (in French):
Expanded Alert sample