[SimBot-commits] CVS: simbot/tools create_wx_station_db.pl,1.4,1.5
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2005-05-14 00:28:44
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10873/tools Modified Files: create_wx_station_db.pl Log Message: - Remove XML current conditions reports. They don't tell us anything METAR doesn't, and are often further behind. - Fix &distance... 'course, it isn't called anymore, but that'll change soon. - Remove url column from the weather db. Index: create_wx_station_db.pl =================================================================== RCS file: /cvsroot/simbot/simbot/tools/create_wx_station_db.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- create_wx_station_db.pl 7 May 2005 18:39:41 -0000 1.4 +++ create_wx_station_db.pl 14 May 2005 00:28:26 -0000 1.5 @@ -53,8 +53,7 @@ CREATE TABLE stations ( state STRING, country STRING, latitude REAL, - longitude REAL, - url STRING + longitude REAL ); EOT @@ -112,37 +111,6 @@ if($response->is_error) { print " Done! Read $line_count lines\n" } -# now let's get the XML data file. -# this only has US stations, and generally lacks lat/long. - -print "Downloading XML station list... "; -$response = $ua->get('http://www.nws.noaa.gov/data/current_obs/index.xml'); - -if($response->is_error) { - print STDERR "Failed!\n " . $response->code . ' ' - . $response->message . "\n"; -} else { - print "Done!\nReading it in"; - my $xml; - if (!eval { $xml = XMLin($response->decoded_content, SuppressEmpty => 1); }) { - print STDERR " Failed!\n$@\n"; - } else { - my $update_station_query = $dbh->prepare( - 'UPDATE stations SET url = ? WHERE id = ?'); - my $line_count = 0; - foreach my $cur_station (@{$xml->{'station'}}) { - if(++$line_count % 300 == 0) { print '.'; } - no warnings qw( uninitialized ); - - $update_station_query->execute( - $cur_station->{'xml_url'}, - $cur_station->{'station_id'} - ); - } - print " Done! Read $line_count lines\n"; - } -} - # OK, now we have a great list of station codes. However, not all have # METAR reports. Let's find codes to remove... @@ -155,10 +123,9 @@ if($response->is_error) { my $line_count = 0; print "Done!\nReading it in"; - # Stations with URLs are XML stations, we don't care if METAR is unavailable # Create a temprary table as a list of candidates for deletion $dbh->do(<<EOT); -CREATE TEMPORARY TABLE delrows AS SELECT id FROM stations WHERE url IS NULL; +CREATE TEMPORARY TABLE delrows AS SELECT id FROM stations; CREATE UNIQUE INDEX delstationid ON delrows (id); EOT |