self.reftile_x , self.refpix_x = self.lon2tilex( self.conf.lon , self.conf.zoom )
self.reftile_y , self.refpix_y = self.lat2tiley( self.conf.lat , self.conf.zoom )
+ def recenter ( self , latlon ) :
+
+ center = self.gps2pix( latlon , self.center() )
+ pixel = self.gps2pix( (self.conf.lat,self.conf.lon) , self.center() )
+
+ distance = math.sqrt( (pixel[0]-center[0])**2 + (pixel[1]-center[1])**2 )
+
+ # FIXME : instead of hardcoded, should depend on the actual display size
+ if distance > 150 :
+ self.conf.lat , self.conf.lon = latlon
+
+ self.reftile_x , self.refpix_x = self.lon2tilex( self.conf.lon , self.conf.zoom )
+ self.reftile_y , self.refpix_y = self.lat2tiley( self.conf.lat , self.conf.zoom )
+
+ self.composeMap()
+
def lon2tilex ( self , lon , zoom ) :
number = math.modf( ( lon + 180 ) / 360 * 2 ** zoom )
return int( number[1] ) , int( self.tile_size * number[0] )
self.composeMap()
def composeMap( self ) :
- center_x , center_y = self.win_x / 2 , self.win_y / 2
-
- # To get the central pixel in the window center, we must shift to the tile origin
- center_x -= self.refpix_x
- center_y -= self.refpix_y
+ center_x , center_y = self.center()
# Ranges should be long enough as to fill the screen
# Maybe they should be decided based on self.win_x, self.win_y
pixbuf.copy_area( init_x, init_y, size_x, size_y, self.get_pixbuf(), dest_x , dest_y )
del(pixbuf)
- self.draw_paths()
+# self.draw_paths()
self.plot_APs()
- def plot( self , pixmap , coords , colorname , radius=3 ) :
+ def center( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
center_x -= self.refpix_x
center_y -= self.refpix_y
+ return center_x , center_y
+
+ def plot( self , pixmap , coords , colorname , radius=3 ) :
+
+ center_x , center_y = self.center()
+
gc = pixmap.new_gc()
gc.foreground = pixmap.get_colormap().alloc_color( colorname )
self.buffer.insert_at_cursor( "%s %5d\n" % ( mac , rss ) )
if self.info[0] == "FIX" :
self.map.hide()
+ self.map.recenter( self.info[4:6] )
pixmap,mask = self.map.get_pixbuf().render_pixmap_and_mask()
self.map.plot( pixmap , ( float(self.info[4]) , float(self.info[5]) ) , "red" , 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.config = wifimap.config.Configuration()
self.config.zoom = 16
- self.map = wifimap.simpleMapWidget( self.config )
- self.map.plot_APs()
- self.add( self.map )
+ self.add( wifimap.simpleMapWidget( self.config ) )
class Wifiscanner ( AbstractWifiscanner , hildon.Window ) :