Archive for July 11th, 2006

PEAR Services_Weather example

July 11th, 2006

Ok, connecting Services_Weather to NOAA to get data isn’t that easy right out of the box.

First you have to provide a database to store the metar locations and airports. I created a database named ‘metar’ and added a user with privileges for that database.

CREATE DATABASE metar;
GRANT ALL ON `metar` . * TO 'metar'@ 'localhost';
pear install Services_Weather
php /usr/local/php5/lib/php/data/Services_Weather/buildMetarDB.php -l -t mysql -d metar -u metar
php /usr/local/php5/lib/php/data/Services_Weather/buildMetarDB.php -a -t mysql -d metar -u metar

Those last two commands actually connect, create tables and insert all of the metar info into the database.

Then modify the metar examples file to connect to mysql://metar@localhost/metar and the example should work.
To change the location to your own you can simply try different locations – I think the metar searchLocation function just connects to the database and finds an entry with location like %location%.