#!/usr/bin/perl $FILEBASE = 'NETMAP'; $WIDTH=4096; $HEIGHT=2048; #$HEIGHT*=3; $WIDTH*=3; ######################################################################### open(FILE, $ARGV[0]); #this is the CSV file to import... $NODEID = 0; while() { $_=~s/\s+$//; ($coord1, $coord2, $count) = split/,/, $_; ($lat1, $lon1) = split/#/, $coord1; ($lat2, $lon2) = split/#/, $coord2; #if ($lat1 > 0 && $lat2 > 0 && $lat1 < 30 && $lat2 < 30 && $lon1 > -20 && $lon2 > -20 && $lon1 < 20 && $lon2 < 20 && $count > 500) { #use a filter like this to narrow to a more precise part of the world or adjust the filter criteria... if ($count > 250) { #post-adjusting the filter criteria... $key1 = $coord1; $key1=~s/#/,/; $key2 = $coord2; $key2=~s/#/,/; if ($key1 ne $key2) { if (!exists($NODES{$key1})) {$NODES{$key1} = $NODEID;$NODEID++;} if (!exists($NODES{$key2})) {$NODES{$key2} = $NODEID;$NODEID++;} $EDGES{"n$NODES{$key1} -- n$NODES{$key2}"}+=$count; if ($count > $MAX) {$MAX = $count;} } } } close(FILE); print "MAX: $MAX...\n"; ######################################################################### ######################################################################### #now write out our GV file... do the header first... open(OUT, ">./$FILEBASE.dot"); print OUT "strict graph converted {\n\tncorner0 [height=\"0.0\",width=\"0.0\",pos=\"0,0\",style=\"invis\"];\n \tnocorner1 [height=\"0.0\",width=\"0.0\",pos=\"$WIDTH,$HEIGHT\",style=\"invis\"];\n"; ########################### #now write all of the nodes... foreach $key (keys %NODES) { ($plat, $plong) = split/,/, $key; $plat+=90; $plong+=180; #offset to 0,0 $plat=$plat*$HEIGHT/180; $plong=$plong*$WIDTH/360; #norm to 100x100... $plat = sprintf("%0.4f", $plat); $plong = sprintf("%0.4f", $plong); $PROJCOORD{$key} = "$plong,$plat"; #print OUT "\tn$NODES{$key} [height=\"0.1\",width=\"0.1\",pos=\"$plong,$plat\",style=\"filled\",shape=\"point\",color=\"#FFFFFF20\",fontcolor=\"#FFFFFFFF\"];\n"; #use this version if you want to see the nodes themselves... print OUT "\tn$NODES{$key} [height=\"0.0\",width=\"0.0\",pos=\"$plong,$plat\",style=\"filled\",shape=\"point\",color=\"#FFFFFF20\",fontcolor=\"#FFFFFFFF\"];\n"; $TOTAL_NODES++; } ########################### #now write all of the edges... foreach $key (keys %EDGES) { if ($EDGES{$key} > 500) { #for REFNET #if ($EDGES{$key} > 10) { #for RTNET #$alpha = ($EDGES{$key} / $MAX * 100) * 40; $alpha = ($EDGES{$key} / $MAX * 100) * 20; #$alpha = ($EDGES{$key} / $MAX * 100) * 5; #if ($alpha < 30) {$alpha = 30;} if ($alpha < 5) {$alpha = 5;} #if ($alpha < 2) {$alpha = 2;} #$alpha = sprintf("%02d", $alpha); $alpha = sprintf("%02X", $alpha); print OUT "\t$key [color=\"#FFFFFF$alpha\"];\n"; #if ($k++ > 1000) {goto jumpclear;} $TOTAL_EDGES++; } } jumpclear: ########################### print OUT "}\n"; close(OUT); print "Wrote $TOTAL_NODES and $TOTAL_EDGES...\n"; #exit; ######################################################################### ######################################################################### #and then render it... print "Rendering...\n"; system("neato -Gviewport=\"$WIDTH,$HEIGHT\" -Gbgcolor=#000000 -n -Tpng $FILEBASE.dot > $FILEBASE.png"); print "Compositing...\n"; system("composite -limit thread 1 -compose atop -geometry -75-25 ./BASEMAP-WHITE.png ./$FILEBASE.png ./${FILEBASE}-COUNTRY.png"); #system("composite -limit thread 1 -compose atop -blend 30% -geometry -225-75 ./BASEMAP-WHITE-3X.png ./$FILEBASE.png ./${FILEBASE}-COUNTRY.png"); #use this version and set height/width at the top of this script to generate a larger version... #########################################################################