[LON-CAPA-cvs] cvs: modules /gerd localizedomain.pl
www
lon-capa-cvs@mail.lon-capa.org
Sun, 17 Aug 2003 02:11:40 -0000
www Sat Aug 16 22:11:40 2003 EDT
Added files:
/modules/gerd localizedomain.pl
Log:
Adds info from adddomain.tab to XXX_domain.tab
Index: modules/gerd/localizedomain.pl
+++ modules/gerd/localizedomain.pl
my $table='production';
open(TABLE,'adddomain.tab') || die "Could not read table\n";
while ($line=<TABLE>) {
chomp($line);
my ($domain,$lang,$cty,$coords)=split(/\&/,$line);
$language{$domain}=$lang;
$city{$domain}=$cty;
my ($l1,$l2,$l3,$ld,$e1,$e2,$e3,$ed)=
($coords=~/^\s*(\d+)\:(\d+)\:(\d+)\s+(\w)\s+(\d+)\:(\d+)\:(\d+)\s+(\w)\s*/);
#
my $longitude=$e1+($e2+$e3/60.0)/60.0;
if ($ed eq 'W') { $longitude=-$longitude; }
$longi{$domain}=int($longitude*100.0+0.5)/100.0;
#
my $latitude=$l1+($l2+$l3/60.0)/60.0;
if ($ld eq 'S') { $latitude=-$latitude; }
$lati{$domain}=int($latitude*100.0+0.5)/100.0;
#
}
close TABLE;
open(IN,'/home/www/loncapa/loncom/'.$table.'_domain.tab') || die "No table $table\n";
open(OUT,'>'.$table.'_domain.tab');
while ($line=<IN>) {
if ($line=~/^\W/) { print OUT $line; next; }
chomp $line;
my ($domain,$univ,$sc1,$sc2)=split(/\:/,$line);
print OUT join(':',($domain,$univ,$sc1,$sc2,$language{$domain},
$city{$domain},$longi{$domain},$lati{$domain}))."\n";
}
close OUT;
close IN;