From b0144643bf50cf6184b5f33087b2527c044729d7 Mon Sep 17 00:00:00 2001 From: javiplx Date: Sat, 14 May 2011 13:19:56 +0000 Subject: [PATCH] Port the dynamic map into the standard scanner git-svn-id: file:///svnroot/wifihood/trunk@166 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/wifimap/scanner.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wifiscanner/wifimap/scanner.py b/wifiscanner/wifimap/scanner.py index b45346f..984e667 100644 --- a/wifiscanner/wifimap/scanner.py +++ b/wifiscanner/wifimap/scanner.py @@ -27,7 +27,8 @@ class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) : # Values to be set by wireless scans self.newap = 0 self.newaps = False - self.aps = [] + self.aps = {} + self.oldpos = {} def start ( self , timeout=5000 , writelog=False ) : gps.GPSObject.start( self ) @@ -46,15 +47,23 @@ class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) : newap = 0 self.newaps = False for mac,max_rss in self.scanlist.iteritems() : - stored = self.db.db.execute( "SELECT rss, lat/n, lon/n FROM ap WHERE mac='%s'" % mac ).fetchone() + stored = self.db.db.execute( "SELECT rss, n, lat, lon FROM ap WHERE mac='%s'" % mac ).fetchone() if stored : - self.aps.append( stored[1:] ) + if not self.aps.has_key( mac ) : + self.aps[ mac ] = list(stored[1:]) if stored[0] > max_rss : max_rss = stored[0] self.db.update( mac , max_rss , self.tstamp , self.info[4:] ) else : newap += 1 + 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] if newap : self.newap += newap self.newaps = True -- 1.7.9.5