In the last few weeks weather.module has stopped working for my US zip code. I believe that the problem started when weatherroom.com changed their feed slightly to fix some bugs: the temperature doesn't show up anymore, i simply get "F" where the temperature should be. The default Victoria, BC location does work though.

CommentFileSizeAuthor
#8 weather.patch652 bytesmikeryan

Comments

Anonymous’s picture

I also get this error

Anonymous’s picture

You can just go here, http://www.weatherroom.com/add.html, and make your own, instead of using the module.

AFL’s picture

Title: Weather module not getting correct data for certain locations » weatherroom.com changed their feed... ° replaced with ° ?

I have weather.module working again by searching for ° and replacing it with a " " at line 552 of the 4.4.0 version.

// $Id: weather.module,v 1.85 2004/04/17 20:22:20 freedom Exp $.

552a553,554
> $weather_input = preg_replace("|°|", " ", $weather_input); //AFL
>

AFL’s picture

Title: weatherroom.com changed their feed... ° replaced with ° ? » weatherroom.com changed their feed... ° replaced with & #0176 ; ?

The ° is control character & # 0176;

gerardryan’s picture

great piece of deduction there. thank you.

i'm not quite sure what happened here at drupal.org regarding this module's development. i took a brief reprieve to tend to other projects (away from my computer) and when i last checked in, another developer was working on the module... now it seems all of his work is *gone*

... funny, too, because no one bothered to contact me and say "hey, i'm filling in for ya while you're away!" ... :-(

anyway, i'll be adding this in quite shortly.

in other news... i'm going to start up work on a completely overhauled module that will bypass weatherroom.com altogether and fetch/parse raw METAR data. i had been meaning to do this forever, but ultimately i was beseiged by laziness. it was far easier to parse an XML feed than to learn METAR codes and write a bunch of complicated regex to translate it into civilian-legible weather updates. also, METAR is forecast-stupid, so there would be the additional task of fetching/parsing TAF data as well. anyway, i've got a good leg up on development (thanks to some contributed code from another developer) and i should have this going Sometime Soon.

again, thanks for your solution!!

nv1962’s picture

Title: weatherroom.com changed their feed... ° replaced with & #0176 ; ? » Can't find the lines to patch...

Pardon this n00b - but in the cvs version I can't find the suggested lines to patch...

Here's what I have on lines 552, 553 and 553:

// $Id: weather.module,v 1.89 2004/08/21 03:20:50 tdobes Exp $.

      $request .= "User-Agent: Drupal Weather/Experimental\r\n";
      $request .= "Host: $host\r\n";
      $request .= "Accept: image/gif, image/x-xbitmap,image/jpeg, image/pjpeg, */*\r\n\r\n";

And lines 350, 351 and 352 -- where I found the named entity for the degree symbol -- look very different from what AFL showed:

    if (stristr($temp, $unit)) return str_replace(" " . $unit, "& deg;" . $unit, $temp);
    if (strtolower($unit) == "c") return round(((double)$temp - 32) * 5/9, 2) . "& deg;" . $unit;
    if (strtolower($unit) == "f") return round(((double)$temp * 9/5) + 32, 2) . "& deg;" . $unit;

Should I smite myself? :-)

P.S.: I had to place a space in the degree entity in the snippet above to avoid browser snafu. Also, the "problem" of not working temp is not just with the cvs version - also have it with 4.4.0.

nv1962’s picture

Title: Can't find the lines to patch... » weatherroom.com changed their feed... ° replaced with & #0176 ; ?

(sorry - no real follow-up, I just realized I had changed the title for the whole thread here, so I now set it back to the way it was... yup I'm a n00b here)

mikeryan’s picture

StatusFileSize
new652 bytes

Here's a patch against the 4.4 version (1.85). Two aspects of the patch:

The TEMP tag was being invoked three times - once for the temperature value, once for the °, and once for the F - only the last one was called. I modified the code to accumulate the values (this probably should apply to all of the character data, but I didn't want to mess with anything else without a demonstrated problem).

After this, the degree sign was showing up as a ?, so I applied the original suggested fix in the TEMP tag handler to translate it to °.

nv1962’s picture

Yay! Thanks Mike! It works now. One observation: your fix made the temperature work again - but the dewpoint and heatindex ("Feels like") still came up "empty" after applying your fix. So, what I did is take a plunge and apply your suggested changes also to the corresponding bits (windchill, heatindex, and dewpoint - immediately below the temp block starting at line 617)

Hope that was useful... Thanks again for making the weather thingie work!

toddy’s picture

Version: » 4.5.x-1.x-dev
Assigned: Unassigned » toddy
Status: Needs review » Closed (fixed)

Hi,

I've taken over maintainership of this module and have uploaded a new version which works with Drupal 4.7. This issue should be fixed, because weatherroom.com is no longer used for downloading the data, so I'm closing it. If you don't agree, feel free to file another issue against the weather module.

Regards,
Tobias