[Tilecache] locating bad tiles...

Tim Schaub noreply at geocartic.com
Fri May 4 12:11:59 EDT 2007


John Cole wrote:
> I have a few tiles that apparently have bad image files behind them (TC
> returns very slowly, and the tiles show up white instead of pink). It would
> be nice to be able to set an option in the config file to overlay the
> filename of the tile somehow so I can find the few, seemingly random tiles
> and remove them, without deleting the entire zoom level.

See attached (quick hack) TileUtil.py.

If you can right-click a tile to get the URL, you can

TileUtil.forceRefresh(url)

to trash the bad one and request a new one.

Tim


> 
> With the addition of the watermarking feature, could it also do this?
> 
> Thanks,
> 
> John
> 
> No virus found in this outgoing message.
> Checked by AVG Free Edition. 
> Version: 7.5.467 / Virus Database: 269.6.2/785 - Release Date: 5/2/2007 2:16
> PM
>  
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache

-------------- next part --------------
import TileCache
import cgi
import os

def getServiceLayerTileBounds(url):
    """Return layer, tile, and bounds given the url."""
    
    bounds = None
    if url.find('?') != -1:
        queryDict = cgi.parse_qs(url.split('?')[1])
        queryDict = dict([(k.upper(), v) for (k, v) in queryDict.iteritems()])
        bounds = [float(i) for i in queryDict['BBOX'][0].split(',')]
        layerName = queryDict['LAYERS'][0]

    cfgfiles = TileCache.cfgfiles
    service = TileCache.Service.load(*cfgfiles)
    layer = service.layers[layerName]
    tile = layer.getTile(bounds)
    return service, layer, tile, bounds
    
def getTilePath(url):
    """Return the disk based tile path for the tile represented by the url."""
    
    service, layer, tile, bounds = getServiceLayerTileBounds(url)
    return service.cache.getKey(tile)

def forceRefresh(url):
    """Delete the disk based tile and request another one given the url."""
    
    service, layer, tile, bounds = getServiceLayerTileBounds(url)
    path = service.cache.getKey(tile)
    os.unlink(path)
    data = layer.render(tile)
    service.cache.set(tile, data)


More information about the Tilecache mailing list