#!/usr/bin/perl # link_coords.pl # # Extracts linkpairs from wleiden.conf files # $scriptname="link_coords.pl"; $author ="Ous"; $versionstring="0.1"; $versiondate="06Jun07"; # # # License: WL # # History: # ver: date: Desc: # 0.1 5jun07 Initial attempt # # Todo: # # Known issues: # ======================================================================================== $nodelist="./node_coords_converted.txt"; $linklist="./reduced_linklist.txt"; $outfile="./linkcoords_list.txt"; #=======MAIN============ &init; &read_nodes; &read_links; &show_linkcoords; &close_all; #======================= #======================== sub init { $date=localtime; #print "$date\n"; ($dat_weekday, $dat_month, $dat_day, $dat_time, $dat_year)= split(/\s+/,$date); $lastchange="$dat_day $dat_month $dat_year"; open (NODELIST,$nodelist) or die "Can't open $nodelist"; open (LINKLIST,$linklist) or die "Can't open $linklist"; open (OUTFILE, ">$outfile"); print OUTFILE "# Link coordinates list\n"; print OUTFILE "# Generated on $lastchange:$dat_time by $scriptname ver.$versionstring auth:$author\n#\n"; print OUTFILE "# From\tTo\tFromRDX,RDY\tToRDX,RDY\tFromLong,Lat\tToLong,Lat\n"; print OUTFILE "# ====\t==\t===========\t=========\t============\t==========\n"; # open (OUTFILE3, ">$outfile3"); # open (OUTFILE2, ">$outfile2"); }#tini #======================== #======================== sub close_all { close (NODELIST); close (LINKLIST); close(OUTFILE); # close(OUTFILE2); # close(OUTFILE3); }#lla_esolc #======================= #======================= sub read_nodes { while($node=) { chomp($node); if ($node !~ /^#/) { ($nodename,$status,$ip,$RDX,$RDY,$long,$lat)=split(/\t+/,$node); # print "\L$nodename\t$status\t$ip\t$RDX+$RDY\t$long+$lat\n"; $nodename =~ s/\s+//;$nodename = "\L$nodename"; $nodestatus{$nodename}=$status; $nodeRD{$nodename}="$RDX,$RDY"; $nodelonglat{$nodename}="$long,$lat"; } } # @nodestatus=%nodestatus;@nodeRD=%nodeRD;@nodelonglat=%nodelonglat; # print "@nodestatus\n"; # print "@nodeRD\n"; # print "@nodelonglat\n"; }#sedon_daer #======================= #======================= sub read_links { while($linkin=) { chomp($linkin); if ($linkin !~ /^#/) { ($linkno,$fromto)=split(/\t+/,$linkin); $links{$linkno}=$fromto; # print "$fromto\n"; } } }#sknil_daer #======================= #======================= sub show_linkcoords { for $link (sort {$a <=> $b} keys %links ) { ($from,$to) = split ( /\+/ , $links{$link}); $rdfrom=$nodeRD{$from}; $rdto=$nodeRD{$to}; $longlatfrom=$nodelonglat{$from}; $longlatto=$nodelonglat{$to}; print "from:$from\tTo:$to\trdfrom:$rdfrom\trdto:$rdto\tlongfrom:$longlatfrom\tlatfrom:$longlatto\n"; print OUTFILE "$from\t$to\t$rdfrom\t$rdto\t$longlatfrom\t$longlatto\n"; } }#sdroocknil_wohs #=======================