# FIXME : instead of hardcoded, should depend on the actual display size
if distance > 150 :
- self.conf.lat , self.conf.lon = latlon
+ self.conf.set_latlon( 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 tilex2lon ( self , ( tilex , pixx ) , zoom ) :
+ tilex = float(tilex)
+ pixx = float(pixx)
+ return ( tilex + pixx/self.tile_size ) / 2.0 ** zoom * 360.0 - 180.0
+
+ def tiley2lat ( self , ( tiley , pixy ) , zoom ) :
+ tiley = float(tiley)
+ pixy = float(pixy)
+ tiley = math.pi * ( 1 - 2 * ( tiley + pixy/self.tile_size ) / 2.0 ** zoom )
+ return math.degrees( math.atan( math.sinh( tiley ) ) )
+
+ def SetZoom( self , zoom ) :
+ self.hide()
+ lat = self.tiley2lat( ( self.reftile_y , self.refpix_y ) , self.conf.zoom )
+ lon = self.tilex2lon( ( self.reftile_x , self.refpix_x ) , self.conf.zoom )
+ self.reftile_x , self.refpix_x = self.lon2tilex( lon , zoom )
+ self.reftile_y , self.refpix_y = self.lat2tiley( lat , zoom )
+ self.conf.set_zoom( zoom )
+ self.composeMap()
+ self.show()
+
def lon2tilex ( self , lon , zoom ) :
number = math.modf( ( lon + 180 ) / 360 * 2 ** zoom )
return int( number[1] ) , int( self.tile_size * number[0] )
class interactiveMapWidget :
- def tilex2lon ( self , ( tilex , pixx ) , zoom ) :
- tilex = float(tilex)
- pixx = float(pixx)
- return ( tilex + pixx/self.tile_size ) / 2.0 ** zoom * 360.0 - 180.0
-
- def tiley2lat ( self , ( tiley , pixy ) , zoom ) :
- tiley = float(tiley)
- pixy = float(pixy)
- tiley = math.pi * ( 1 - 2 * ( tiley + pixy/self.tile_size ) / 2.0 ** zoom )
- return math.degrees( math.atan( math.sinh( tiley ) ) )
-
def Shift( self , dx , dy ) :
self.hide()
self.composeMap()
self.show()
- def ZoomChange ( self , selector ) :
- model = selector.get_model(0)
- active = selector.get_active(0)
- value = model.get( model.get_iter(active) , 0 )
- self.SetZoom( int(value[0]) )
-
- def SetZoom( self , zoom ) :
- self.hide()
- lat = self.tiley2lat( ( self.reftile_y , self.refpix_y ) , self.conf.zoom )
- lon = self.tilex2lon( ( self.reftile_x , self.refpix_x ) , self.conf.zoom )
- self.reftile_x , self.refpix_x = self.lon2tilex( lon , zoom )
- self.reftile_y , self.refpix_y = self.lat2tiley( lat , zoom )
- self.conf.zoom = zoom
- self.composeMap()
- self.show()
-
def Up( self ) :
self.hide()
self.reftile_y -= 1
pixbuf.copy_area( init_x, init_y, size_x, size_y, self.get_pixbuf(), dest_x , dest_y )
del(pixbuf)
-# self.draw_paths()
self.plot_APs()
def center( self ) :
dest_x , dest_y = self.gps2pix( coords , ( center_x , center_y ) )
pixmap.draw_rectangle(gc, True , dest_x , dest_y , radius , radius )
- def draw_paths( self ) :
+ def line( self , pixmap , start , coords , colorname ) :
- pixmap,mask = self.get_pixbuf().render_pixmap_and_mask()
+ center_x , center_y = self.center()
- filename = "data/wiscan_gui.info.old"
- fd = open( filename )
- for line in fd.readlines() :
- values = line.split()
- if values[1] == "FIX" :
- self.plot( pixmap , ( float(values[5]) , float(values[6]) ) , "red" )
- fd.close()
+ gc = pixmap.new_gc()
+ gc.foreground = pixmap.get_colormap().alloc_color( colorname )
- self.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.win_x, self.win_y )
+ 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 ) :