Thatgeek – Previously Sonicpling

Monday October 11, 2004

Weather Icon - Again

Filed under: General — Jeremiah @ 9:15 pm

Wow, last post was on Sep 3.
I’m so lazy.

In case you’re interested (and didn’t already know) the newest version of the code for the little weather do-dad you can see to the right is available here: weather.phps

if you want the whole shebang (icons and all), then check here: weather-hack.

9 Responses to “Weather Icon - Again”

  1. Thor Says:

    Love it! I put it on my site today.

  2. Garett Says:

    I must say the script is a beauty, but I have located a minor bug in the script (not sure if this is the best place to mention it). If you are using multiple stations (one after another on the menu), the conditions of one will carry to the other, assuming it doesn’t have a condition of its own. For example I’m in Regina (CYQR). At the moment it is snowing with blowing snow. My second one is Bermuda (TXKF), which is currently a little cloudy, and about 30 degrees C (much warmer, incapable of snow). If I display them in the order I just listed, it claims it is snowing in Bermuda (a news story in itself I believe). In any case, reversing the order makes everything perform as expected. I tracked the problem to the variable $conditions in get_conditions, ie:

    function get_conditions($part, &$metarPtr, &$group, &$wxInfo,$visibility_unit,$wind_unit) {
    static $conditions='';
    .

    I have patched mine version changing this line to:


    global $conditions

    and in the main function (WeatherIcon) making the following changes


    function WeatherIcon($station='CYQR', $location='Regina, SK') {

    global $Itemid, $conditions;

    ...

    $weather='' // ...
    $conditions='' // clears condition data

    ...

    This is a kludge fix, but I figured I’d let you know. For reporting purposes, I’m running the newest version of the code available (ie what is presented above - 1.1.5).

    Thanks again for the code.

  3. Garett Says:

    Oh and the obvious semi-colons where I missed ‘em too … (I really should have just cut and pasted … *sigh*)

  4. Garett Says:

    Found another possible bug. Wind data sometimes doesn’t contain a speed. In the case of today it read: “Wind Speed: Calm km/h.” Replacing this line:

    if ($display_wind=='yes' && $wxInfo['WIND']<>”) $weather = $weather . “

  5. ” ._WIND.” “.$wxInfo[’WIND’].” $wind_unit
  6. “;

    with this
    play_wind=='yes' && $wxInfo['WIND']<>”)
    {
    $weather = $weather . “

  7. ” ._WIND.” “.$wxInfo[’WIND’];
    if (eregi(”[0-9]”, $wxInfo[’WIND’]))
    {
    $weather = $weather . ” $wind_unit”;
    }
    $weather = $weather . “
  8. “;
    }

    “Wind Speed: Calm” and still allows the other wind speeds to function normally. Since there is only one case where it a windspeed not requiring a wind unit (ie: calm), this shouldn’t break anything else.

  9. Garett Says:

    Okay, copy/pasting doesn’t work too well either. *sigh* It should read:

    if ($display_wind=='yes' && $wxInfo['WIND']'')
    {
    $weather = $weather . "" ._WIND." ".$wxInfo['WIND'];
    if (eregi("[0-9]", $wxInfo['WIND']))
    {
    $weather = $weather . " $wind_unit";
    }
    $weather = $weather . "";
    }

  10. Stuart Says:

    I’m using your plugin on my wordpress site… very nice!

  11. David Blangstrup Says:

    the language file is turning up as a plugin now in the latest nightly WP 1.3 - it didn’t do that before, did it? :-|

  12. Scott Says:

    Awesome plugin. Thanks! And I have a question for you. Would it be possible for you to send me your index.php and wp-comments.php (and any other files that one would need for your template). I really like the nice and simple design and I’d love to use yours as a base to start my design from. (I could give you credit on the page if you’d want). Thanks!

    (Sorry for posting this here but I couldn’t find your email address).

  13. Luc-Marie Says:

    Hi,

    Thanks for that nice plugin.
    If you want I have translated the language file in french.
    Feel free to ask me for it if you want it.

    Luc-Marie

Leave a Reply