WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: mackbig on April 16, 2013, 12:58:56 PM

Title: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on April 16, 2013, 12:58:56 PM
Ken,
EC changed their site around, and the EC Forecast and Radar scripts are not working.
The radar one causes notices and warnings, the forecast is just null.

Let us know when you get a chance to have a look.

Thanks,
Andrew
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 16, 2013, 01:53:49 PM
Yep.. they've changed the website URL, and switched to UTF-8 for the charset (from ISO-8859-1).

I'll have to do some changes to both scripts.. working on it right now.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 16, 2013, 01:56:29 PM
Just saw the mess on my site, thanks for getting right on it, Ken :)
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: linuxfreak on April 16, 2013, 06:51:35 PM
Well, at least they haven't mucked with the weather radio broadcasts yet.   :shock: #-o :lol:

I just noticed the dashboard threw errors, guess a rewrite is needed for my EC-radar addon for NSDisplay!  ](*,) #-o

And I was just beginning to like spring!  :roll:

George

Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 16, 2013, 07:08:40 PM
Yes, ec-radar is next on my rework list based on Environment Canada changes today (16-Apr-2013)

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-ECforecast.php#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
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 16, 2013, 07:25:29 PM
Thanks for the fix, Ken =D> I notice they're using new icons as well:

http://weather.gc.ca/city/pages/on-47_metric_e.html (http://weather.gc.ca/city/pages/on-47_metric_e.html)
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 16, 2013, 07:29:34 PM
I'll do a new icons set after the ec-radar script fixes :)

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 16, 2013, 07:32:02 PM
Yay!!! Thanks, Ken \:D/
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 16, 2013, 08:10:07 PM
Ken, I also noticed that the watches/warnings alerts bar is not displaying my location:

http://www.beamsvillewx.ca/index.php (http://www.beamsvillewx.ca/index.php)
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 16, 2013, 08:12:48 PM
What was the code on your index.php that did the alerts display?  (BTW.. there aren't any alerts for your location right now)
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 16, 2013, 08:16:43 PM
Code: [Select]
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";

Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 16, 2013, 08:19:52 PM
I'll look at why $title is not being found later this evening. 

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: PaulMy on April 16, 2013, 10:23:29 PM
Quote
I have completed the needed mods to ec-forecast.php (V2.14 - 16-Apr-2012)
Thanks for the quick fix Ken, my EC forecast is back.
Quote
I should have a fix for the ec-radar issue(s) tomorrow (17-Apr-2013)
And as expected until you can get a fix for this, the radar is not working .

Quote
Ken, I also noticed that the watches/warnings alerts bar is not displaying my location:
We have no current watches or warnings and my home page does show the yellow bar with "No weather watches or warnings in effect for ,"

Also I did notice from my StatCounter that I had some visits from Environment Canada IP address earlier this morning,
Quote
www.google.ca — wxlink canada
which I have not seen before.

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on April 17, 2013, 06:32:36 AM
Thanks Ken

Andrew
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on April 17, 2013, 09:56:06 AM
Strange.  It worked after I deleted the old ec-forecast-en.txt file.

Then a few hours laters, I went back in and it created a new null one again. Hmmm?

Andrew
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 17, 2013, 11:33:24 PM
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-ECforecast.php#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 (http://saratoga-weather.org/wxtemplates/updates.php) for Base-Canada, 17-Apr-2013

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: PaulMy on April 18, 2013, 12:51:33 AM
Great, and seems to be working properly again.  Thanks again Ken.

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on April 18, 2013, 07:14:55 AM
Ken,
The radar script worked great.

I have this recurring problem with the forecast script.  It will work for a while.  Then my http://www.mackweather.com/ec-forecast-en.txt will end up like this below.

Code: [Select]
HTTP/1.1 301 Moved Permanently
Date: Thu, 18 Apr 2013 11:05:15 GMT
Server: Apache
Location: http://weather.gc.ca/city/pages/on-85_metric_e.html
Vary: Accept-Encoding
Content-Length: 259
Connection: close
Content-Type: text/html; charset=iso-8859-1
X-Pad: avoid browser bug

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://weather.gc.ca/city/pages/on-85_metric_e.html">here</a>.</p>
</body></html>

I will go into ftp, delete it, then it will work for a while, then revert. 

Thanks
Andrew
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 18, 2013, 10:17:02 AM
Great work, Ken, thanks. Have a look at my radar page-

http://www.beamsvillewx.ca/wxradar.php (http://www.beamsvillewx.ca/wxradar.php)

The size of the map keeps changing  :???:

Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 18, 2013, 11:03:26 AM
Ken,
The radar script worked great.

I have this recurring problem with the forecast script.  It will work for a while.  Then my http://www.mackweather.com/ec-forecast-en.txt will end up like this below.

Code: [Select]
HTTP/1.1 301 Moved Permanently
Date: Thu, 18 Apr 2013 11:05:15 GMT
Server: Apache
Location: http://weather.gc.ca/city/pages/on-85_metric_e.html
Vary: Accept-Encoding
Content-Length: 259
Connection: close
Content-Type: text/html; charset=iso-8859-1
X-Pad: avoid browser bug

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://weather.gc.ca/city/pages/on-85_metric_e.html">here</a>.</p>
</body></html>

I will go into ftp, delete it, then it will work for a while, then revert. 

Thanks
Andrew

Very strange .. the 301 redirects to exactly the same URL ?!? -- I think this is a weather.gc.ca website problem. 
They appear to have two server addresses
Quote
04/18/13 07:59:29 dns weather.gc.ca
Canonical name: weather.gc.ca
Addresses:
  199.212.17.39
  199.212.17.28
and maybe this is a load balancing attempt if they are doing round-robin DNS for load balancing.

Great work, Ken, thanks. Have a look at my radar page-

http://www.beamsvillewx.ca/wxradar.php (http://www.beamsvillewx.ca/wxradar.php)

The size of the map keeps changing  :???:


I tried the page, and there are 3 different map sizes with their new website.
The NAT is 600x522px, the regional ones are 573x300px and the individual radar sites are 580x480px

Is that what you meant by 'the size of the map keeps changing'?

Title: Re: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 18, 2013, 11:14:53 AM
Yes.  I  have my ec-radar.php page set for my local radar, not the national or provincial radar,  so I wonder why it's displaying the national radar?
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 18, 2013, 12:37:47 PM
Just did an update to wxadvisory.php for Base-Canada to fix the warning image overflow and correct links for new EC website design.

The wxadvisory.php main copy area now has
Code: [Select]
<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 -->

Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 18, 2013, 12:40:40 PM
Yes.  I  have my ec-radar.php page set for my local radar, not the national or provincial radar,  so I wonder why it's displaying the national radar?

Your Settings.php has
Code: [Select]
// radar settings for wxradar.php page
$SITE['ecradar']    = 'NAT';  // set to default Site for ec-radar (same as id=xxx on EC website)
so that is the default map that will be displayed on the wxradar.php page.

Best regards,
Ken

Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 18, 2013, 02:01:10 PM
Have made the change to my Settings.php and ec-radar.php. My index page still has errors. I chose 'ONT' as my radar in my index.php.
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 18, 2013, 02:04:20 PM
Ann-Marie,
The messages
Quote
Notice: Undefined offset: 0 in /homepages/22/d364066440/htdocs/maps/ec-radar.php on line 265

Notice: Undefined offset: 0 in /homepages/22/d364066440/htdocs/maps/ec-radar.php on line 274

Notice: Undefined offset: 0 in /homepages/22/d364066440/htdocs/maps/ec-radar.php on line 275

Notice: Undefined offset: 0 in /homepages/22/d364066440/htdocs/maps/ec-radar.php on line 276
are there because the ec-radar.php in the /maps/ directory is the old one (not the updated one)

I suggest you either update the script in that directory, or better still, change the index.php to use the
new script in your home directory instead.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 18, 2013, 02:18:23 PM
Thanks Ken :) Do the cities not display on the provincial or national radar?
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 18, 2013, 03:21:57 PM
I see the site now has overlays for cities for the NAT and provinces.. I'll add that to the script.
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 18, 2013, 06:01:49 PM
Sigh.. the API will not honor overlays to the NAT/regional radar composite images so no, the cities will not be displayed there. :(

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on April 18, 2013, 06:21:06 PM
C'est la vie :-|
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: linuxfreak on April 22, 2013, 05:01:30 AM
Hi Ken,

Small little nagging problem with the ec-forecast, the tags have totally changed from what they should be!  #-o

$forecasttitles should be Today, Tonight, Monday, Tuesday.... etc. but are now giving back instead:

Sun 21 Apr, Mon 22 Apr, Tue 23 Apr, Wed 24 Apr, Thu 25 Apr, Fri 26 Apr, Sat 27 Apr.

Any way of getting back the "original" tag values rather than the "new & improved" tags which are totally breaking the forecast section of the dashboard.

Nice as it is to have the date, but having the day of the week would be nice without having to run a "search & replace" script to trash the date and redo the day name in full.

I just love it when the Government thinks we need better!  :roll: :lol:

George

Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 22, 2013, 11:37:39 AM
Hi George,

The 'original' tags were what the EC previously used on their website .. now they offer only the 'day dd mon' format on their site and I see no option on the query to specify what format to use :(

The script simply uses what they provide without modifying it (except to convert from UTF-8 to ISO-8859-1 character set).
Sorry...

Ken

BTW.. the NOAA/NWS site replaces day names with national holiday names (also annoying) so 'Today' can be 'Washington's Birthday', 'Memorial Day', 'Christmas Day' etc.
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: linuxfreak on April 22, 2013, 01:44:35 PM
Lovely!!  :roll:

What I see of the generated html
Code: [Select]
            <div class="fperiod">
              <h3>
                <abbr title="Monday">Mon</abbr>
                <br><span class="fdate">22&nbsp;<abbr title="April">Apr</abbr>
                </span>
              </h3><img width="60" height="51" src="/weathericons/01.gif" alt="Mainly sunny" title="Mainly sunny"><ul>
                <li class="pop">&nbsp;</li>
                <li class="high" title="High">14&deg;<abbr title="Celsius">C</abbr>
                </li>
                <li class="low">&nbsp;</li>
              </ul>
            </div>
I seem to see the weekday spelled out as "Monday" rather than "Mon 22 Apr" :?

Code: [Select]
              <dl>
                <dt>Today<span class="wb-invisible">, 22&nbsp;April</span></dt>
                <dd>Mainly sunny. Wind southeast 20 km/h. High 14 except 8 near Lake Ontario. UV index 6 or high.</dd>
                <dt>Tonight<span class="wb-invisible">, 22&nbsp;April</span></dt>
                <dd>A few clouds. Wind becoming southeast 20 km/h after midnight. Low plus 4.</dd>
                <dt>Tuesday<span class="wb-invisible">, 23&nbsp;April</span></dt>
                <dd>Mainly sunny. Increasing cloudiness late in the evening. Wind southeast 20 km/h becoming light in the afternoon. High 15.</dd>
                <dt>Wednesday<span class="wb-invisible">, 24&nbsp;April</span></dt>
                <dd>Rain. Low 6. High 8.</dd>
                <dt>Thursday<span class="wb-invisible">, 25&nbsp;April</span></dt>
                <dd>A mix of sun and cloud. Low minus 1. High 11.</dd>
                <dt>Friday<span class="wb-invisible">, 26&nbsp;April</span></dt>
                <dd>Sunny. Low plus 1. High 11.</dd>
                <dt>Saturday<span class="wb-invisible">, 27&nbsp;April</span></dt>
                <dd>A mix of sun and cloud. Low 6. High 14.</dd>
                <dt>Sunday<span class="wb-invisible">, 28&nbsp;April</span></dt>
                <dd>A mix of sun and cloud. Low 7. High 14.</dd>
              </dl>


And the time periods of "Today" & "Tonight"  rather than "Today, 22 April" & "Tonight, 22 April" :?

Could the parsing be tweaked  a little to get back the array's of useful tags that once existed?

$forecasttitles[0] used to say "Today"
$forecasttitles[1] used to say either "Tonight" or the next day name
$forecasttitles[2] used to say the next day name

It was nice, today's & tonight's forecast would nicely stack one above the other, now tonight's forecast has tomorrow's date and name!  #-o

This site change is for the birds!  :lol: Causing nothing but more fixes, and I think I ran into that "double-dns" myself with the EC Alerts script I'm running here, one fetch there are weather statements, next time get none.  ](*,)

Thanks anyway Ken, guess I'll have to figure out the parsing and make a work around for the problem.  ;)

George
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on April 22, 2013, 03:35:59 PM
George,

Thanks for pointing out the text is already (hidden) in the site.

Try http://saratoga-weather.org/wxtemplates/Canada/ec-forecast.php?sce=view on your site and see if it does what you want (Long names for day instead of 'Day, dd Mon') controlled by $doLongDayNames flag in the settings area.

Note that this doesn't change the detailed forecast period format .. that could be done too if need be.  Only the icon names in $forecasttitles is changed.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: linuxfreak on April 23, 2013, 12:27:19 PM
Well that did clean things a bit.  =D&gt;

Pretty close....  See the first image fcst1.jpg

What we used to have is the second image fcst2.jpg

I got that by tossing in this bit of code just before that section of the dashboard:
Code: [Select]
<?php 
for($i=0$i<=2$i++) {
$tmp explode(",",$forecasttitles[$i]);
$forecasttitles[$i] = $tmp[0];
 }
?>
       

It gets rid of the extra date string which showed up with the EC website "renovation".  :lol: #-o

Any way of getting another setting tag to strip or not the ", 23 April " from the $forecasttitles[] array?

George
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on April 23, 2013, 12:54:09 PM
My double dns issue went away late last week.  I noticed I saw it happen around the "10's".   I would be on the site at ?:13 and the bad cache was generated at ?:10.   I noticed this several times, and the chance that an external visitor (with my traffic) was always hitting writting around the 10 was unusual.  Then I remember that I had WD fetch the page every 10 minutes.  This is listed as a page load speed helper in the template faq's.    I thought it was a remote shot, but somehow this was somehow contributing to the issue.  So I disabled that fetch and voila, it went away.  Probably pure coincidence, but it hasnt happened since, and in the first few days it was happening a lot.

Andrew

..........and I think I ran into that "double-dns" myself with the EC Alerts script I'm running here, one fetch there are weather statements, next time get none.  ](*,)
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: linuxfreak on April 24, 2013, 12:53:58 AM
Thanks for that heads up Andrew.

My ECalerts script is triggered every 5 minutes to grab the Southern Ontario warnings (all county codes) and the Special Weather Statements.  The 2 "revised" scripts to replace the old ECwarn and ECspecial use parts from the ECalerts script, and I have seen and been getting reports that the SWS script breaks, one fetch - everything is peachy, next fetch - zero content in the cache file!  #-o

I'm using the "pseudo-cron" with the Windows Scheduler to trigger the scripts to run, I think I'll try offsetting the trigger times and see if that fixes what I've seen happening on my end, but I'm thinking that my regex strings for the capture might not be doing what I thought they were 100% of the time, so more testing on my end!  :roll:

George
 
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on May 14, 2013, 01:38:58 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]
# --- 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 (http://saratoga-weather.org/wxtemplates/updates.php) page for Base-Canada, 13-May-2013

Standalone users should use the scripts page (http://saratoga-weather.org/scripts-ECforecast.php) for download.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on May 14, 2013, 06:12:34 AM
Thanks Ken

You must be reading our minds.  I was going to post yesterday that I'd noticed the null forecast popping up more and more the past week.  I was going to ask if we could force the script to look everytime, since when you got the null you were stuck with it for several minutes even if you hit reload, or had to delete manually using ftp which is hard if remote or on a mobile.  Or I was going to ask if a kill script could be created to run manaully.

Of course this is much better.  I will try to install from work, if not this evening.

Thanks again

Andrew
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on May 14, 2013, 08:59:43 AM
Works great Ken.
Thanks
Andrew

ps:  I played with your array.  I added a small town you missed... Toronto   ;)  I guess after they blew that 4-1 lead vs Boston our city card got revoked.

I also sorted geographically (kind of)  I added/amended cities in Southern Ontario around GTA. Added Edmonton due to size, and Gander due to travel significance, perhaps more I cant recall.   Then sorted the rest from east Coast to West, with northern territories at the bottom.  Fixed the accents in Montreal and Orleans too.

Code: [Select]
'Markham, ON|http://weather.gc.ca/city/pages/on-85_metric_e.html', // Markham, ON
'Toronto, ON|http://weather.gc.ca/city/pages/on-143_metric_e.html', // Toronto, ON
'Toronto Island, ON|http://weather.gc.ca/city/pages/on-128_metric_e.html', // Toronto, ON
'Pickering, ON|http://weather.gc.ca/city/pages/on-54_metric_e.html', // Pickering
'Collingwood, ON|http://weather.gc.ca/city/pages/on-150_metric_e.html', // Collingwood, ON
'St. Catharines, ON|http://weather.gc.ca/city/pages/on-107_metric_e.html', // St. Catharines, ON
'Niagara Falls, ON|http://weather.gc.ca/city/pages/on-125_metric_e.html', //
'Gander, NL|http://weather.gc.ca/city/pages/nl-16_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',
'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',
'Fredericton, NB|http://weather.gc.ca/city/pages/nb-29_metric_e.html',
'Montr&eacute;al, QC|http://weather.gc.ca/city/pages/qc-147_metric_e.html',
'Ottawa (Kanata - Orl&eacute;ans), ON|http://weather.gc.ca/city/pages/on-118_metric_e.html',
'Winnipeg, MB|http://weather.gc.ca/city/pages/mb-38_metric_e.html',
'Regina, SK|http://weather.gc.ca/city/pages/sk-32_metric_e.html',
'Calgary, AB|http://weather.gc.ca/city/pages/ab-52_metric_e.html',
'Edmonton, AB|http://weather.gc.ca/city/pages/ab-50_metric_e.html',
'Vancouver, BC|http://weather.gc.ca/city/pages/bc-74_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',
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on May 14, 2013, 01:37:45 PM
Thanks Andrew!
It was never my intent to omit any particular city in the sample list -- I was just looking for a wide range of forecast locations to test the script with varying conditions.

One thing I think will help with the stability of your website display given some instability in the weather.gc.ca website (with odd 30x redirects) is the new logic used when cache refresh is needed.
First, it tries the URL.  If it gets a 30x redirect, it waits 2 seconds and tries the URL from the Location: header.
If that works (return code 200), then all is well and the new cache is saved.  Otherwise, the cache reload is ignored and
the prior cache file is used instead.  That should keep display on the home page and forecast page as current as feasible.

Also, two new switches (with override from Settings.php entries) allow you to choose to use the
old way of specifying legends on the icons and detail text forecasts, or the new method that includes dates with the day/period.

The view-source of a page now shows much more info about the fetch of the data from weather.gc.ca website
Quote
        <!-- ec-forecast.php - V2.16 - 13-May-2013 -->
<!-- GET /city/pages/ab-50_metric_e.html HTTP/1.1
      Host: weather.gc.ca  Port: 80 IP=199.212.17.39 -->
<!-- HTTP stats:  dns=0.001 conn=0.081 put=0.000 get(36 blocks)=0.158 close=0.000 total=0.240 secs -->
<!-- fetch function elapsed= 1 secs. -->
<!-- time to fetch: 0.240 sec (200 OK) -->
<!-- Webserver returned gzipped data, unzipping response -->
<!-- fetch_gzdecode err='None' -->
<!-- headers returned:
HTTP/1.1 200 OK
Date: Tue, 14 May 2013 17:38:52 GMT
Server: Apache
Last-Modified: Tue, 14 May 2013 17:03:02 GMT
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 5606
Connection: close
Content-Type: text/html
 -->
<!-- unable to open ./cache/ec-forecast-18-en.txt for writing .. cache not saved -->
<!-- using charsetInput='UTF-8' charsetOutput='ISO-8859-1' doIconv='1' -->
<!-- converted lookup keys to UTF-8 -->
<!-- conditions
Array
(
    [temperature] => 17&deg;C
    [icon] => 00.png
    [ydayheading] => Yesterday
    [ydaymaxtemp] => Max: <b>21.3&deg;C</b>
    [ydaymintemp] => Min: <b>11.3&deg;C</b>
    [ydayprecip] => Precip: <b>0.0 mm</b>
    [normsheading] => Normals
    [normsmaxtemp] => Max: <b>18&deg;C</b>
    [normsmintemp] => Min: <b>5&deg;C</b>
    [heading] => Today
    [sunrise] => Sunrise: <b>5:35</b>
    [sunset] => Sunset: <b>21:26</b>
    [cityobserved] => Observed at: <b>Edmonton City Centre Airport</b><br/> Date: <b>11:00 AM MDT Tuesday 14 May 2013</b>
    [obsdate] => Date: <b>11:00 AM MDT Tuesday 14 May 2013</b>
    [citycondition] => <b>Sunny</b>
    [baro] => Pressure: <b>101.0&nbsp;kPa</b>
    [barotrend] => Tendency: <b>rising</b>
    [vis] => Visibility: <b>15 km</b>
    [temp] => Temperature: <b>16.5&deg;C</b>
    [dew] => Dewpoint: <b>-0.5&deg;C</b>
    [humid] => Humidity: <b>31%</b>
    [wind] => Wind: <b>WNW 30 gust 41 km/h</b>
)
 -->
<!-- title='Edmonton, AB' -->

I do note that your ./cache/ directory does not seem to be writable for the new files used with the multi-forecast .. you should check your permissions on that directory and set it to 766 or so so new files can be created/written.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on May 14, 2013, 03:25:35 PM
I know Ken, I was just kidding.  Toronto and Edmonton, only material misses, so you did good.  The rest of Canada would applaud you as they think Toronto gets too much attention.  CN tower envy  :lol:

Thanks Andrew!
It was never my intent to omit any particular city in the sample list -- I was just looking for a wide range of forecast locations to test the script with varying conditions.

 :oops: wasnt a problem with permissions on the cache folder.  The problem was that I didnt have a cache folder.  I think older iterations I had it writing to root, didnt notice that "change".  All fixed now.

Thanks again.
Andrew

I do note that your ./cache/ directory does not seem to be writable for the new files used with the multi-forecast .. you should check your permissions on that directory and set it to 766 or so so new files can be created/written.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: PaulMy on May 14, 2013, 06:02:14 PM
Thanks for the update Ken.  And Andrew, thanks for the sorted array of EC sites, and I left Toronto near the top.  But the omission of Komoka London??

I have updated and the ec-forecast is working great but now I like Andrew's icons better.  Trying to follow the Readme but can't find the PNG icons as I only have the GIF.  Did I miss something in my previous upgrade, and where would I get those icons?

Ken, I had tried the $SITE [ECiconsDayDate'] and [ECdetailsDayDate'] = true; setting but that displays the forecast details out of order such as "Wednesday, 15 May" above/ahead of "Wednesday Night, 14 May"

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on May 14, 2013, 08:52:51 PM
Thanks very much for this great script, Ken, I love the new icons :-)
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on May 14, 2013, 09:04:26 PM
Sorry Paul.  London and Waterloo were also under consideration.

The PNG icons are in post 36 from Ken.

Andrew

Thanks for the update Ken.  And Andrew, thanks for the sorted array of EC sites, and I left Toronto near the top.  But the omission of Komoka London??

I have updated and the ec-forecast is working great but now I like Andrew's icons better.  Trying to follow the Readme but can't find the PNG icons as I only have the GIF.  Did I miss something in my previous upgrade, and where would I get those icons?

Ken, I had tried the $SITE [ECiconsDayDate'] and [ECdetailsDayDate'] = true; setting but that displays the forecast details out of order such as "Wednesday, 15 May" above/ahead of "Wednesday Night, 14 May"

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: PaulMy on May 14, 2013, 11:00:03 PM
Now how did I not see this :oops:
Quote
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.

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on May 14, 2013, 11:32:47 PM
It's also a link in the template install/download page (http://saratoga-weather.org/wxtemplates/install.php) and a link in the standalone EC forecast script page (http://saratoga-weather.org/scripts-ECforecast.php) :)

I've left the default to .gif (along with the .gif icons included in the standalone version) for backward compatibility -- new installs can choose which icon types to use.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: PaulMy on May 14, 2013, 11:48:31 PM
Thanks again Ken and Andrew, and to Thayer Fox as well for making them available, I have them downloaded and working,

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on May 15, 2013, 02:55:08 PM
Ugh.  Did they make another small change?  At first I thought it was just my mobile site.   The current conidtion box appears, but the forecast is null.   Then I checked my site, thinking it was just me.  Then I went to the source.  Ken's is also wonky.

Andrew
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: linuxfreak on May 15, 2013, 03:08:13 PM
I thought I was seeing things too!  #-o

They "fixed" it to break it!  :roll: :lol:

George
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: saratogaWX on May 15, 2013, 07:43:08 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.  #-o  ](*,)

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

Template users: use the updates tool page (http://saratoga-weather.org/wxtemplates/updates.php) for Base-Canada, 15-May-2013

Standalone users: use the ec-forecast.php scripts page (http://saratoga-weather.org/scripts-ECforecast.php#ECforecast) for the download link.

Best regards,
Ken
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: weathergirl on May 15, 2013, 07:52:16 PM
Awesome job, Ken, thanks!
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: PaulMy on May 15, 2013, 09:32:24 PM
Thanks Ken, got it back working again.  Getting some good practice on how to do the upgrades - really quite easy once one gets the hang of it.  Great work!

Paul
Title: Re: Enviro Canada web developers have been busy .... Radar and Forecast
Post by: mackbig on May 16, 2013, 06:05:27 AM
Thanks again Ken,

Andrew