OSGeo / tilecache

Tilecache
35 stars 18 forks source link

Wrong GoogleDisk filenames #15

Open seidlmic opened 9 years ago

seidlmic commented 9 years ago

Unless there is some special requiremnets on bbox and maxResolution values (which is not clearly documented) this can happen in getKey function in GoogleDisk.py

def getKey (self, tile):
    grid = tile.layer.grid(tile.z)
    components = ( self.basedir,
                   tile.layer.name,
                   "%s" % int(tile.z),
                   "%s" % int(tile.x),
                   "%s.%s" % (int(grid[1] - 1 - tile.y), tile.layer.extension)
                   )
    filename = os.path.join( *components )
    return filename

grid can have volues (0.7022093750000402, 1.2695687499997277) and for tile.y = 0 one will get int(1.2695687499997277 - 1 - 0) that leads to 0 but apparently should be 1 becuase there are two rows of tiles. For tile.y = 1 int(1.2695687499997277 - 1 - 1) leads again to 0 that causes the previous file is overwritten.

For most cases this could be solution.

"%s.%s" % (int(grid[1] - tile.y), tile.layer.extension)

But if grid[1].is_integer() the current formula is correct.