BUGFIX : calculate reference pixel properly
authorjaviplx <javiplx@gmail.com>
Sun, 8 May 2011 12:25:03 +0000 (12:25 +0000)
committerjaviplx <javiplx@gmail.com>
Sun, 8 May 2011 12:25:03 +0000 (12:25 +0000)
git-svn-id: file:///svnroot/wifihood/branches/mapview-redesign@147 c51dfc6a-5949-4919-9c8e-f207a149c383

view.py

diff --git a/view.py b/view.py
index 4d2da74..0585a2a 100755 (executable)
--- a/view.py
+++ b/view.py
@@ -57,14 +57,16 @@ class tile_loader :
     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] )
+        tile = tilex[1] , tiley[1] 
+        pix = tilex[0] , tiley[0] 
+        return map( int , tile ) , map( lambda x : int( self.tilesize * x ) , pix )
 
     def lon2tilex ( self , lon , zoom ) :
-        return map( int , math.modf( ( lon + 180 ) / 360 * 2 ** zoom ) )
+        return math.modf( ( lon + 180 ) / 360 * 2 ** zoom )
 
     def lat2tiley ( self , lat , zoom ) :
         lat = lat * math.pi / 180
-        return map( int , math.modf( ( 1 - math.log( math.tan( lat ) + 1 / math.cos( lat ) ) / math.pi ) / 2 * 2 ** zoom ) )
+        return 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] )