import os
-import wifimap.config
+import wifimap.config , wifimap.db
class mapWidget ( gtk.Image ) :
tiley = math.pi * ( 1 - 2 * ( tiley + pixy/self.tile_size ) / 2.0 ** zoom )
return math.degrees( math.atan( math.sinh( tiley ) ) )
+ def gps2pix ( self , ( lat , lon ) , ( center_x , center_y ) ) :
+
+ x_pos = self.lon2tilex( lon , self.conf.zoom )
+ y_pos = self.lat2tiley( lat , self.conf.zoom )
+
+ dest_x = self.tile_size * ( x_pos[0] - self.reftile_x ) + center_x + x_pos[1]
+ dest_y = self.tile_size * ( y_pos[0] - self.reftile_y ) + center_y + y_pos[1]
+
+ return dest_x , dest_y
+
def composeMap( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
pixbuf.copy_area( init_x, init_y, size_x, size_y, self.get_pixbuf(), dest_x , dest_y )
del(pixbuf)
+ pixmap,mask = self.get_pixbuf().render_pixmap_and_mask()
+ red = pixmap.new_gc()
+ red.foreground = pixmap.get_colormap().alloc_color("red")
+ green = pixmap.new_gc()
+ green.foreground = pixmap.get_colormap().alloc_color("green")
+ blue = pixmap.new_gc()
+ blue.foreground = pixmap.get_colormap().alloc_color("blue")
+
+ filename = "data/wiscan_gui.info.old"
+ fd = open( filename )
+ for line in fd.readlines() :
+ values = line.split()
+ if values[1] == "FIX" :
+ dest_x , dest_y = self.gps2pix( ( float(values[5]) , float(values[6]) ) , ( center_x , center_y ) )
+ pixmap.draw_rectangle(blue, True , dest_x , dest_y , 3 , 3 )
+ fd.close()
+
+ db = wifimap.db.database( os.path.join( self.conf.homedir , self.conf.dbname ) )
+ db.open()
+ for ap in db.execute( "SELECT * FROM ap" ) :
+ if ap[3] > 1 :
+ dest_x , dest_y = self.gps2pix( ( ap[4]/ap[3] , ap[5]/ap[3] ) , ( center_x , center_y ) )
+ pixmap.draw_rectangle(red, True , dest_x , dest_y , 3 , 3 )
+ db.close()
+
+ self.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.win_x, self.win_y )
+
+
def tilename ( self , x , y , zoom ) :
file = self.tile2file( self.reftile_x + x , self.reftile_y + y , zoom )
try :