From 3d1dd0b348fea5f768711ce2644f55a498da31c9 Mon Sep 17 00:00:00 2001 From: javiplx Date: Sat, 14 May 2011 13:06:32 +0000 Subject: [PATCH] Show on the map the displacement of the detected APs git-svn-id: file:///svnroot/wifihood/trunk@165 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/wifimap/replay.py | 3 +++ wifiscanner/wifimap/view.py | 12 ++++++++++++ wifiscanner/wifiscanner | 6 ++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/wifiscanner/wifimap/replay.py b/wifiscanner/wifimap/replay.py index 3d3113d..6a1b1fd 100644 --- a/wifiscanner/wifimap/replay.py +++ b/wifiscanner/wifimap/replay.py @@ -36,6 +36,7 @@ class ReplayScanner ( gobject.GObject ) : self.newap = 0 self.newaps = False self.aps = {} + self.oldpos = {} def start ( self , timeout=5000 , writelog=False ) : self.scan_timeout = timeout @@ -86,6 +87,8 @@ class ReplayScanner ( gobject.GObject ) : if not self.aps.has_key( mac ) : self.aps[ mac ] = [ 0 , 0 , 0 ] self.db.add( mac , max_rss , self.tstamp , self.info[4:] ) + if self.aps[mac][0] != 0 : + self.oldpos[mac] = self.aps[mac][1] / self.aps[mac][0] , self.aps[mac][2] / self.aps[mac][0] self.aps[mac][0] += 1 self.aps[mac][1] += self.info[4] self.aps[mac][2] += self.info[5] diff --git a/wifiscanner/wifimap/view.py b/wifiscanner/wifimap/view.py index 5ae2c1e..a7f688c 100755 --- a/wifiscanner/wifimap/view.py +++ b/wifiscanner/wifimap/view.py @@ -231,6 +231,18 @@ class simpleMapWidget ( AbstractmapWidget , gtk.Image ) : dest_x , dest_y = self.gps2pix( coords , ( center_x , center_y ) ) pixmap.draw_rectangle(gc, True , dest_x , dest_y , radius , radius ) + def line( self , pixmap , start , coords , colorname ) : + + center_x , center_y = self.center() + + gc = pixmap.new_gc() + gc.foreground = pixmap.get_colormap().alloc_color( colorname ) + + src_x , src_y = self.gps2pix( start , ( center_x , center_y ) ) + dest_x , dest_y = self.gps2pix( coords , ( center_x , center_y ) ) + dist = math.sqrt( (dest_x-src_x)**2 + (dest_y-src_y)**2 ) + pixmap.draw_line(gc , src_x , src_y , dest_x , dest_y ) + def plot_APs( self ) : pixmap,mask = self.get_pixbuf().render_pixmap_and_mask() diff --git a/wifiscanner/wifiscanner b/wifiscanner/wifiscanner index 49d6888..1f39e3d 100755 --- a/wifiscanner/wifiscanner +++ b/wifiscanner/wifiscanner @@ -63,8 +63,10 @@ class scanner ( wifimap.ReplayScanner ) : if self.newaps : pointsize += 2 self.map.plot( pixmap , ( float(self.info[4]) , float(self.info[5]) ) , "red" , pointsize ) - for ap in self.aps.values() : - self.map.plot( pixmap , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" , 1 ) + for mac,ap in self.aps.iteritems() : + if self.oldpos.get( mac ) : + self.map.line( pixmap , self.oldpos[mac] , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" ) + self.map.plot( pixmap , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" , 2 ) self.map.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.map.win_x, self.map.win_y ) self.map.show() -- 1.7.9.5