fix a warning when GeoIP can't find the country for a site

This commit is contained in:
Oliver Eikemeier 2004-07-07 14:48:44 +00:00
parent 6687a7a5c2
commit e41c0a0867
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=113147
2 changed files with 26 additions and 20 deletions

View File

@ -125,19 +125,22 @@ if (%newdistance && $hostcount > 1) {
foreach (keys %newdistance) {
my $dist;
my $cc = lc $gi->country_code_by_name($_);
my ($lat_cc, $lon_cc) = getlatlon($cc)
if defined $cc;
# Find the deltas
my $delta_lat = $lat_cc - $lat_home;
my $delta_lon = $lon_cc - $lon_home;
if ($cc) {
my ($lat_cc, $lon_cc) = getlatlon($cc)
if defined $cc;
# Find the Great Circle distance
my $temp = sin($delta_lat/2.0)**2 + cos($lat_home) * cos($lat_cc) * sin($delta_lon/2.0)**2;
$dist = atan2(sqrt($temp),sqrt(1-$temp));
# Find the deltas
my $delta_lat = $lat_cc - $lat_home;
my $delta_lon = $lon_cc - $lon_home;
$distance{$_} = [$dist, $expgood]
if defined $dist;
# Find the Great Circle distance
my $temp = sin($delta_lat/2.0)**2 + cos($lat_home) * cos($lat_cc) * sin($delta_lon/2.0)**2;
$dist = atan2(sqrt($temp),sqrt(1-$temp));
$distance{$_} = [$dist, $expgood]
if defined $dist;
}
}
open RANKS, ">$rankfile";

View File

@ -125,19 +125,22 @@ if (%newdistance && $hostcount > 1) {
foreach (keys %newdistance) {
my $dist;
my $cc = lc $gi->country_code_by_name($_);
my ($lat_cc, $lon_cc) = getlatlon($cc)
if defined $cc;
# Find the deltas
my $delta_lat = $lat_cc - $lat_home;
my $delta_lon = $lon_cc - $lon_home;
if ($cc) {
my ($lat_cc, $lon_cc) = getlatlon($cc)
if defined $cc;
# Find the Great Circle distance
my $temp = sin($delta_lat/2.0)**2 + cos($lat_home) * cos($lat_cc) * sin($delta_lon/2.0)**2;
$dist = atan2(sqrt($temp),sqrt(1-$temp));
# Find the deltas
my $delta_lat = $lat_cc - $lat_home;
my $delta_lon = $lon_cc - $lon_home;
$distance{$_} = [$dist, $expgood]
if defined $dist;
# Find the Great Circle distance
my $temp = sin($delta_lat/2.0)**2 + cos($lat_home) * cos($lat_cc) * sin($delta_lon/2.0)**2;
$dist = atan2(sqrt($temp),sqrt(1-$temp));
$distance{$_} = [$dist, $expgood]
if defined $dist;
}
}
open RANKS, ">$rankfile";