[SimBot-commits] CVS: simbot/plugins weather.pl,1.66,1.67
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2005-05-06 23:56:17
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10522/plugins Modified Files: weather.pl Log Message: We now have the latitude and longitude of 289 of the US current observation stations. The other 1488 don't provide it. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -p -r1.66 -r1.67 --- weather.pl 6 May 2005 22:37:47 -0000 1.66 +++ weather.pl 6 May 2005 23:56:05 -0000 1.67 @@ -42,8 +42,6 @@ package SimBot::plugin::weather; use strict; use warnings; -use Data::Dumper; - # The weather, more or less! use Geo::METAR; @@ -95,6 +93,10 @@ use constant FORCE_METAR => 64; # cache here. sub cleanup_wx { $dbh->disconnect; + + # We shouldn't have done anything to the zip codes DB, but just in case + $zip_dbh->rollback; + $zip_dbh->disconnect; } ### messup_wx @@ -268,30 +270,35 @@ sub got_station_list { # but in some cases the number is X.Y . Is that X degrees, Y minutes, # and 0 seconds, or X.Y degrees? # I'll figure it out later... most stations just report NA anyway. -# my ($latitude, $dir) -# = $cur_station->{'latitude'} -# =~ m/([\d\.]+)([NS])/; -# -# if($dir eq 'S') { -# $latitude = $latitude * -1; -# } -# -# my $longitude; -# ($longitude, $dir) -# = $cur_station->{'longitude'} -# =~ m/([\d\.]+)([EW])/; -# -# if($dir eq 'W') { -# $longitude = $longitude * -1; -# } + my ($lat_deg, $lat_min, $lat_sec, $lat_dir); + if(($lat_deg, $lat_min, $lat_sec, $lat_dir) = $cur_station->{'latitude'} + =~ m/(\d+)\.(\d+)(?:\.(\d+))([NS])/) + { + $lat_deg += $lat_min * 0.0166666667; + $lat_deg += $lat_sec * 0.000277777778; + if($lat_dir eq 'S') { + $lat_deg = $lat_deg * -1; + } + } + + my ($long_deg, $long_min, $long_sec, $long_dir); + if(($long_deg, $long_min, $long_sec, $long_dir) = $cur_station->{'longitude'} + =~ m/(\d+)\.(\d+)(?:\.(\d+))?([EW])/) + { + $long_deg += $long_min * 0.0166666667; + $long_deg += $long_sec * 0.000277777778; + if($long_dir eq 'W') { + $long_deg = $long_deg * -1; + } + } $update_station_query->execute( $cur_station->{'station_id'}, $cur_station->{'station_name'}, $cur_station->{'state'}, 'United States', - undef, #$latitude, - undef, #$longitude, + $lat_deg, #$latitude, + $long_deg, #$longitude, $cur_station->{'xml_url'} ); } |