[SimBot-commits] CVS: simbot/tools create_wx_station_db.pl,1.2,1.3
Status: Abandoned
Brought to you by:
kstange
|
From: Kevin S. <ks...@us...> - 2005-05-07 03:53:41
|
Update of /cvsroot/simbot/simbot/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27462 Modified Files: create_wx_station_db.pl Log Message: This seems to have been completely wrong. :) Index: create_wx_station_db.pl =================================================================== RCS file: /cvsroot/simbot/simbot/tools/create_wx_station_db.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- create_wx_station_db.pl 7 May 2005 03:43:18 -0000 1.2 +++ create_wx_station_db.pl 7 May 2005 03:53:32 -0000 1.3 @@ -62,11 +62,8 @@ EOT # Set up our user agent my $ua = LWP::UserAgent->new; -if (defined &HTTP::Response::decoded_content) { - $ua->default_header('Accept-Encoding' => 'gzip, deflate'); -} else { - print "Warning: Your HTTP::Response does not support gzip\n"; -} +$ua->default_header('Accept-Encoding' => 'gzip, deflate'); + # Now with the boring stuff down, get the rather large METAR list print "Downloading METAR station list... "; @@ -77,12 +74,7 @@ if($response->is_error) { . $response->message . "\n"; } else { print "Done!\nReading it in"; - my $content; - if (defined &HTTP::Response::decoded_content) { - $content = $response->decoded_content; - } else { - $content = $response->content; - } + my $content = $response->decoded_content; my $cur_line; my $line_count = 0; @@ -95,17 +87,15 @@ if($response->is_error) { ($cur_line, $content) = split(/\n/, $content, 2); my ($station, undef, undef, $name, $state, $country, undef, $lat_dms, $long_dms) = split(/;/, $cur_line, 10); - my ($lat_deg, $long_deg, $minutes, $seconds, $dir); - if (defined $lat_dms) { - ($lat_deg, $minutes, $seconds, $dir) = $lat_dms - =~ m/(\d+)-(\d+)(?:-(\d+))?([NS])/; - $lat_deg = &dms_to_degrees($lat_deg, $minutes, $seconds, $dir); - } - if (defined $long_dms) { - ($long_deg, $minutes, $seconds, $dir) = $long_dms - =~ m/(\d+)-(\d+)(?:-(\d+))?([EW])/; - $long_deg = &dms_to_degrees($long_deg, $minutes, $seconds, $dir); - } + my ($long_deg); + my ($lat_deg, $minutes, $seconds, $dir) = $lat_dms + =~ m/(\d+)-(\d+)(?:-(\d+))?([NS])/; + $lat_deg = &dms_to_degrees($lat_deg, $minutes, $seconds, $dir); + + ($long_deg, $minutes, $seconds, $dir) = $long_dms + =~ m/(\d+)-(\d+)(?:-(\d+))?([EW])/; + $long_deg = &dms_to_degrees($long_deg, $minutes, $seconds, $dir); + { no warnings qw( uninitialized ); $update_station_query->execute( @@ -133,13 +123,7 @@ if($response->is_error) { } else { print "Done!\nReading it in"; my $xml; - my $content; - if (defined &HTTP::Response::decoded_content) { - $content = $response->decoded_content; - } else { - $content = $response->content; - } - if (!eval { $xml = XMLin($content, SuppressEmpty => 1); }) { + if (!eval { $xml = XMLin($response->decoded_content, SuppressEmpty => 1); }) { print STDERR " Failed!\n$@\n"; } else { my $update_station_query = $dbh->prepare( |