[LON-CAPA-cvs] cvs: modules /gerd adddomain.tab earth.png makemap.pl

www lon-capa-cvs@mail.lon-capa.org
Sun, 17 Aug 2003 22:17:17 -0000


www		Sun Aug 17 18:17:17 2003 EDT

  Added files:                 
    /modules/gerd	earth.png makemap.pl 

  Modified files:              
    /modules/gerd	adddomain.tab 
  Log:
  Produces little map of LON-CAPA servers for web site.
  
  When location labels are included, takes a long time trying to figure out
  how to not make them overlap - go get a cup of coffee while this runs.
  
  
Index: modules/gerd/adddomain.tab
diff -u modules/gerd/adddomain.tab:1.2 modules/gerd/adddomain.tab:1.3
--- modules/gerd/adddomain.tab:1.2	Sun Aug 17 15:50:34 2003
+++ modules/gerd/adddomain.tab	Sun Aug 17 18:17:16 2003
@@ -15,7 +15,7 @@
 unihalle&de&Halle, Germany&51:28:48 N 11:58:12 E
 sc&en-US&Columbia, SC&34:00:02 N 081:02:06 W
 udel&en-US&Newark, DE&39:41:01 N 075:45:00 W
-uwsp&en-US&Stevens Point&44:31:25 N 089:34:28 W
+uwsp&en-US&Stevens Point, WI&44:31:25 N 089:34:28 W
 fit&en-US&Melbourne, FL&28:04:43 N 080:36:10 W
 csm&en-US&Golden, CO&39:45:20 N 105:13:14 W
 nau&en-US&Flagstaff, AZ&35:11:53 N 111:39:02 W

Index: modules/gerd/makemap.pl
+++ modules/gerd/makemap.pl
  my $cluster='production';

  use Image::WorldMap;
  my $map = Image::WorldMap->new("earth.png","maian/8");
  &servers($map,$cluster);
  $map->draw("loncapamap_$cluster.png");
  exit 0;

sub servers {
    my ($map,$which)=@_;
    my %city=();
    my %longi=();
    my %lati=();
    my $name=();
    my %useddomains=();
    open(DOMAINS,'/home/www/loncapa/loncom/'.$which.'_domain.tab') 
	|| die "Could not read domain: $which";
    while ($line=<DOMAINS>) {
	chomp $line;
	if ($line=~/^\W/) { next; }
	my @entries=split(/\:/,$line);
	my $domain=$entries[0];
	$name{$domain}=$entries[1];
	$city{$domain}=$entries[5];
	$longi{$domain}=$entries[6];
	$lati{$domain}=$entries[7];
    }
    close(DOMAINS);
    open(HOSTS,'/home/www/loncapa/loncom/'.$which.'_hosts.tab') 
	|| die "Could not read host: $which";
    while ($line=<HOSTS>) {
	chomp $line;
	unless ($line=~/\w/) { next; }
	if ($line=~/^\W/) { next; }
	my ($hostname,$domain,$function)=split(/\:/,$line);
	unless ($lati{$domain}) { next; }
	print $hostname.': '.$longi{$domain}.', '.$lati{$domain}."\n";
	$useddomains{$city{$domain}}=$longi{$domain}.':'.$lati{$domain};
	my $wlongi=$longi{$domain}*(1.0+0.01*(-0.5+rand()));
        my $wlati=$lati{$domain}*  (1.0+0.01*(-0.5+rand()));
	if ($function eq 'library') {
	    $map->add($wlongi,$wlati); 
	} else {
	    $map->add($wlongi,$wlati,undef,[255,127,00]);
	}
    }
    close(HOSTS);
    foreach (keys %useddomains) {
	$map->add(split(/\:/,$useddomains{$_}),$_,[0,255,0]);
    }
}