lat = lat * math.pi / 180
return int( ( 1 - math.log( math.tan( lat ) + 1 / math.cos( lat ) ) / math.pi ) / 2 * 2 ** zoom )
+ def tilex2lon ( self , tilex , zoom ) :
+ return tilex / 2.0 ** zoom * 360.0 - 180.0
+
+ def tiley2lat ( self , tiley , zoom ) :
+ tiley = math.pi * ( 1 - 2 * tiley / 2.0 ** zoom )
+ return math.degrees( math.atan( math.sinh( tiley ) ) )
+
def composeMap( self ) :
center_x , center_y = self.win_x / 2 , self.win_y / 2
def SetZoom( self , zoom ) :
self.hide()
- # FIXME : Use current lat,lon instead of hardcoded ones
- lat , lon = 40.40491 , -3.6774
+ lat = self.tiley2lat( self.reftile_y , self.zoom )
+ lon = self.tilex2lon( self.reftile_x , self.zoom )
self.reftile_x , self.reftile_y = self.lon2tilex( lon , zoom ) , self.lat2tiley( lat , zoom )
self.zoom = zoom
self.refpix_x , self.refpix_y = 128 , 128