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.

http://deburca.org and http://amadain.org

Comments

bomarmonk’s picture

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:

Current weather, forecasts and alerts delivered using RSS.
The weather information for this RSS feed is taken from the
National Weather Service (http://weather.noaa.gov/), and
powered by HamWeather (http://www.hamweather.com/). The RSS feed is provided so that you don't have to look out of the window to find out the weather, do not use it for making decisions that involve yours or anybody elses life.

Using the Feeds

Request Frequency - The feeds are updated once per hour. More frequent requests may result in your access being limited.
Web Site Usage - If you are using the feed on your web site, you are required to maintain a link to rssWeather.com

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!

paddy_deburca’s picture

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 :

Enter RSS Weather XML Service provider: www.rssweather.com
Enter a ICAO 4-letter airport indentifier code: ELLX

and then

Display options: Metric, show mini-block, block re-caching and enable cron.

The URL the module creates is as follows

http://www.rssweather.com/rss.php?hwvUT=C&hwvUP=mb&hwvUS=kmh&hwvUV=km&hwvCCChange=forecast&hwvSF=Y&maxdays=2&daysonly=2&hwvStyle=ce&alt=rss20a&icao=ELLX

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

bomarmonk’s picture

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.

paddy_deburca’s picture

To get the weather for Alpine CO, CA from rssweather.com the URL needs to be changed.

The URL

http://www.rssweather.com/hw3.php?place=alpine&state=ca&country=us

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

bomarmonk’s picture

That would be great! I look forward to using the module!

paddy_deburca’s picture

Hi,

I just added the following code

	if (strpos($this->_region, ".")) {
	  list($place, $state, $country) = split(".", $this->_region);
	  $uri .= "&place=" . $place . "&state=" . $state . "&country=" . $country;
	} else {
 	  $uri .= "&icao=" . $this->_region;
    }

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

bomarmonk’s picture

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!

paddy_deburca’s picture

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