#!/usr/bin/perl

#goto jump;

$width=12288; $height=6144;

open(OUTGV, ">$ARGV[0].dot");
print OUTGV "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";

open(FILE, $ARGV[0]);
$NODEID = 0;
while(<FILE>) {
    ($lat, $long, $cnt) = split/,/, $_; $cnt=~s/\s+$//;
    if ($cnt > 0) {
        $plat = $lat; $plong = $long;
        $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);
        print OUTGV "\tn$NODEID [height=\"0.01\",width=\"0.01\",pos=\"$plong,$plat\",style=\"filled\",shape=\"point\",color=\"#000000FF\",fontcolor=\"#000000FF\"];\n";
        $NODEID++;
    }
}
close(FILE);

print OUTGV "}\n";
close(OUTGV);

print "Rendering...\n";
print "CMD(neato -Gviewport=\"$width,$height\" -Gbgcolor=#FFFFFF -n -Tpng $ARGV[0].dot > $ARGV[0].png)\n";
system("neato -Gviewport=\"$width,$height\" -n -Tpng $ARGV[0].dot > $ARGV[0].png");
#########################################################################
