#!/usr/bin/perl # read netstumbler TSV files and generate Fig # Andrew Daviel, April 2005 $quiet = 0 ; $line_style = 0 ; $thickness = 1 ; $pen_color = 4 ; # red $red = 4 ; $gold = 31 ; $green = 14 ; $black = 0 ; $fill_color = 7 ; $pdepth = 40 ; $pen_style = -1 ; $area_fill = 20 ; $style_val = '0.000' ; $angle = '0.000' ; $textangle = '0.700' ; $pt = 2 ; # text point $join_style = 0 ; $cap_style = 0 ; $radius0 = 400000 ; $radius0 = 2000 ; $forward_arrow = 0 ; $backward_arrow = 0 ; $maxcol = 5 ; while ($ARGV[0] =~ /-([ned])/) { if ($1 eq 'n') { shift ; $legend = 1 ; } if ($1 eq 'e') { shift ; $doe = 1 ; } if ($1 eq 'd') { shift ; $dp1 = 1 ; } } $xscale = shift ; unless ($xscale) { die "Usage: $0 [] [] []\n" ; # e.g. 180000 } $yscale = shift ; unless ($yscale) { $yscale = $xscale ; } $yoff = shift ; $xoff = shift ; $radius0 = shift ; unless ($radius0) { $radius0 = 4000 ; } $radius = int ($xscale / $radius0) ; unless ($radius>0) { $radius = 1 ; } $scale2 = 1200/100 ; $scale2 = 1200 ; print<) { if (/^#/) { next ; } chomp ; tr/\r\n//d ; ($lat,$long,$ssid,$type,$bssid,$time,$SNR,$name,$flags,$cbits,$BI,$rate,$lastc) = split(/\t/) ; $ssid =~ s/^\( // ; $ssid =~ s/ \)$// ; $bssid =~ s/^\( // ; $bssid =~ s/ \)$// ; $name =~ s/^\# \([\s]*// ; $name =~ s/[\s]*\)$// ; if ($SNR =~ /[\s]+([\d]+)[\s]+([\d]+)[\s]+([\d]+)[\s]/) { $snr = $1 ; $sig = $2 ; $noise = $3 ; } unless ($lat and $long) { next ; } if ($lat =~ /([NS])[\s]+([\d\.]+)/) { if ($1 eq 'N') { $lat = $2 ; } elsif ($1 eq 'S') { $lat = -$2 ; } } if ($long =~ /([EW])[\s]+([\d\.]+)/) { if ($1 eq 'E') { $long = $2 ; } elsif ($1 eq 'W') { $long = -$2 ; } } $x = $xscale * ($long - $xoff) / 180 ; $y = $yscale * ($lat - $yoff) / 180 ; # from worldmap.c if ($xmax eq '') { $xmax = $xmin = $x ; } if ($ymax eq '') { $ymax = $ymin = $y ; } if ($x>$xmax) { $xmax = $x ; } if ($y>$ymax) { $ymax = $y ; } if ($x<$xmin) { $xmin = $x ; } if ($y<$ymin) { $ymin = $y ; } $x = int($x * $scale2 + 0.5 ) ; $y = int($y * -$scale2 + 0.5 ) ; # from ps2fig unless ($x and $y) { next ; } print< 5) { $pen_color = $gold ; } if ($snr > 10) { $pen_color = $green ; } $fill_color = $pen_color ; if ($doe) { $pen_color = $gold ; if ($wep) { $pen_color = $red ; } } $fill_color = $pen_color ; if (!$wep and !$doe or $doe and !$fast) { # circle $x2 = $x + $radius ; print "1 3 $line_style $thickness $pen_color" ; print " $fill_color $pdepth $pen_style $area_fill $angle 1 0.000 " ; print "$x $y $radius $radius $x $y $x2 $y \n" ; } else { # square $x1 = $x - $radius ; $x2 = $x + $radius ; $y1 = $y - $radius ; $y2 = $y + $radius ; #print "2 2 0 1 0 0 $depth 0 20 0.000 0 0 -1 0 0 5\n" ; print "2 2 $line_style $thickness $pen_color $fill_color $pdepth $pen_style $area_fill $angle 0 0 -1 0 0 5\n" ; print "\t$x1 $y1 $x2 $y1 $x2 $y2 $x1 $y2 $x1 $y1\n" ; } } $dx = $xmax-$xmin ; $dy = $ymax-$ymin ; print STDERR "x $xmin - $xmax : $dx\ny $ymin - $ymax : $dy\n" ;