def __init__ ( self , conf ) :
self.tilesize = 256
self.rootdir = "%s/%s/%s" % ( conf.mapsdir , conf.mapclass , conf.zoom )
- self.reftile = self.lon2tilex( conf.lon , conf.zoom ) , self.lat2tiley( conf.lat , conf.zoom )
+ self.reftile , self.refpix = self.get_reference( conf )
+
+ def get_reference ( self , conf ) :
+ tilex = self.lon2tilex( conf.lon , conf.zoom )
+ tiley = self.lat2tiley( conf.lat , conf.zoom )
+ return ( tilex[1] , tiley[1] ) , ( tilex[0] , tiley[0] )
def lon2tilex ( self , lon , zoom ) :
- tilecoord = math.modf( ( lon + 180 ) / 360 * 2 ** zoom )
- return int( tilecoord[1] )
+ return map( int , math.modf( ( lon + 180 ) / 360 * 2 ** zoom ) )
def lat2tiley ( self , lat , zoom ) :
lat = lat * math.pi / 180
- tilecoord = math.modf( ( 1 - math.log( math.tan( lat ) + 1 / math.cos( lat ) ) / math.pi ) / 2 * 2 ** zoom )
- return int( tilecoord[1] )
+ return map( int , math.modf( ( 1 - math.log( math.tan( lat ) + 1 / math.cos( lat ) ) / math.pi ) / 2 * 2 ** zoom ) )
def get_tile ( self , tile ) :
file = self.tilepath( self.reftile[0] + tile[0] , self.reftile[1] + tile[1] )