The PolarLava Weather Project II

The saga continues…

Over the past several years I've maintained a Perl module to scrape data from The Weather Channel and then later NOAA's National Weather Service.  These adventures were chronicled in The PolarLava Weather Project entry.  Today begins a departure into a new and likely more sane direction…

Last week Rob pointed out to me pxWeather, a PHP class that processes data from the NWS' XML Feed.  I was previously aware of this data feed, but the last time I looked into it, it was fairly limited.  The actual data provided was pretty minimal and the available locations were very small.  All that has appeared to have changed as the data provided is now pretty extensive and the available locations also have been greatly expanded.  For quite some time I've wanted an accurate, reliable and free XML weather feed.  And I believe I now have that.

The pxWeather class has some nice features, but when I started looking into and using it, I found some issue.  For starters there were some pretty basic coding errors in the setOption() method.  And the XML data processing was being handled by a third-party class which at one time probably was a good solution.  But with the much improved XML handling in PHP5, it seemed a bit much to me.  So what else to do than to build a better wheel?

It's certainly not feature complete, but I've now written the core portion of a weather class that is now driving my weather page.  The weather for my CycleLog is currently still using the Perl weather module, but at some point this will also be migrated to the new PHP weather class…unless I decide to reimplement it in Perl also.  That might be a possibility.

So in addition to reworking the cycling weather, the next item for the actual PHP class will probably be a caching function.  This isn't something I really need as all  of my web site uses a GZip compression data cache.  Most of my pages aren't cached, but the weather page is one of them.  This is a feature that others likely will find of use, thus I will be adding it.  One final note…this class is written for PHP5 and will not work under PHP4.  I'm sorry if you're interested but still running PHP4.  Face the reality, it's time to upgrade.  There are a number of advantages to running PHP5 and one of the most significant is XML handling.  So if you're still interested and would like to try my weather class, drop me note at kevinp ~AT~ polarlava.com.

—— 7/7/06

OK, I've completed the initial implementation of on this class.  It now supports using local images which includes downloading images the first time they are referenced.  So it will self-build a library of required images.  Additionally I've added caching of the XML data with a selectable timeout (default 1 hour).  As mentioned previously, not something I will be using but other might need it.

I've got class documentation (thanks Rob) now and will be working on putting together a page for that and making it downloadable at some point.

—— 9/3/06

I've now added functionality to retrieve observation station data.  This allows you to grab all weather stations by state/territory and then display the weather for that location on the fly.  Unlike the previous Zip Code based system, the XML feed requires that you know the four character observation station code.  Those are all listed in a giant XML file and that's what the new station fetching feature handles for you.  This new feature should be showing up on the Weather page very soon.
July 3, 2006 @ 10:24 am | Category:
comments powered by Disqus