By paddy_deburca on
As a great fan of the weather module, I was sad to see it continually fail as weatherroom.com failed...
I have updated the module code to use rssweather.com.
Someone with greater xml parsing skills may be able to do a more beautiful job.
Long live regular expressions!!
The main change between the two feeds, is that rssweather.com provides the data in a 'content:encoded' tag. I had to use regular expressions to extract the relevant information from the data as such:
case "CONTENT:ENCODED":
$stuff = preg_replace("/(.*)\<dt.*\/dt>(.*)/i", "$1$2", $data);
while (preg_match("/(.*)\<[^>]+\>(.*)/i", $stuff)) {
$stuff = preg_replace("/(.*)\<[^>]+\>(.*)/i", "$1$2", $stuff);
}
if (strpos($data, "humidity")) {
$this->weather["humidity"] = $stuff;
} else if (strpos($data, "windspeed")) {
$this->weather["wind"] = $this->weather["wind"] . $stuff;
} else if (strpos($data, "winddir")) {
$this->weather["wind"] = $stuff . $this->weather["wind"];
} else if (strpos($data, "pressure")) {
$this->weather["barometer"] = $stuff;
} else if (strpos($data, "dewpoint")) {
$this->weather["dewpoint"] = $stuff;
} else if (strpos($data, "heatindex")) {
$this->weather["temp"] = $stuff;
} else if (strpos($data, "windchill")) {
$this->weather["windchill"] = $stuff;
} else if (strpos($data, "visibility")) {
$this->weather["visibility"] = $stuff;
} else if (strpos($data, "images")) {
$this->weather["image"] = preg_replace("/.*src=\"([^\"]+).*/i", "$1", $data);
}
break;
The module can be found at http://amadain.net/rssweather and you can see it up and running on http://deburca.org
Just put in your 4 letter ICAO string and away she goes!!
Paddy.
Comments
Having trouble setting up the weather feed
If you can give me any help getting your new weather module to work, I would be very appreciative. I'm very excited that you have released an update for this broken module!
In setting up weather on Drupal 4.5.2 and with your update of the module, I have tried rssweather.com, rssWeather.com, www.rssweather.com, and www.rssWeather.com, and even hamweather.com in the XML service provider field (under admin>settings>weather), but I can't get the weather block to work properly or even display proper weather information. I retrieved the proper ICAO code and added this to my settings, saving the configuration. Enabling "mini-block" also breaks the formatting on my site by placing all of the text below into the left navigation pane and duplicating itself in the same section. There is a red x where the weather image should be. The text that is displayed is:
Do my problems have to do with the fact that I may not have the proper "link?" I'm not sure where this link should go, but one is apparently generated automatically by your module, so I would guess I'm missing something else... hopefully it's not too obvious!
Can you try this..
User gerardryan (http://drupal.org/user/3674) is the project maintainer.
I am just an avid user of the module and missed it too much.
I am also running Drupal 4.5.2 on http://deburca.org; I had the previous weather.module installed and just replaced it with this updated version.
My parameters are :
and then
The URL the module creates is as follows
Replace ELLX with your own ICAO 4 character code. The result should give you a RSS version 2.0 XML stream.
This should at lease verify that the www.rssweather.com provides the information you need.
Can you post what ICAO code you wish to use and what web-site I could visit to see the result ?
Paddy
http://deburca.org and http://amadain.net
Paddy.
http://deburca.org
Weird... it works with your ICAO code!
When I use your ICAO code, it works! As soon as I change it to the one for my area: "KM45," I get the weird formatting and the odd message. You can check out the results at...on the otherhand don't bother: I think it's just the county airport giving no information with its ICAO designation. The ICAO is supposed to be valid, but... I now think the text I've listed must be a default feed if there is no data? I'll have to check into why this county's feed isn't available.
If only life we so simple...
To get the weather for Alpine CO, CA from rssweather.com the URL needs to be changed.
The URL
Provides the XLM feed that is required. I shall have a look at the code and update to not not only use ICAO codes, but also rssweather.com location codes.
I'll keep you posted.
Paddy
http://deburca.org and http://amadain.org
Paddy.
http://deburca.org
Thanks
That would be great! I look forward to using the module!
alpine.ca.us is up and running
Hi,
I just added the following code
so that when you enter your location as "alpine.ca.us" the correct information is requested.
The new module can be found on http://amadain.net/rssweather
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org
I've given it a try...
But the weather for "Las Vegas, Nevada" is listed when I put alpine.ca.us in the ICAO field. Hmmm... did I do something wrong? The rssweather.com website lists the weather for Alpine County, so I'm not sure what's happening. I'm sorry to communicate this result... weird!
I really appreciate your efforts!
I was using split incorrectly
OK,
I think that I have it now.
The code can be found as usual on http://amadain.net/rssweather.
If you look at http://deburca.org you will see alpine.ca.us in action!
I still need to fix the powered-by link and the XML button.
Forecasts are for the future ;-)
Please continue to comment.
I will see how I can get (some of) these changes brought into CVS.
Paddy.
http://deburca.org, and http://amadain.net
Paddy.
http://deburca.org