Beispiel #1
0
def tiles(request, layer_name, z, x, y, extension, custom_tile=None):
    """
    Fetch tiles with tilestache.
    """
    metatile = TileStache.Core.Metatile()
    
    if custom_tile:
        config = get_config(custom_tile=custom_tile)
    else:
        config = get_config()
    
    path_info = "%s/%s/%s/%s.%s" % (layer_name, z, x, y, extension)
    coord, extension = TileStache.splitPathInfo(path_info)[1:]
    try:
        tilestacheLayer = config.layers[layer_name]
    except:
        return HttpResponseNotFound()

    status_code, headers, content = tilestacheLayer.getTileResponse(coord, extension)
    mimetype = headers.get('Content-Type')
    if len(content) == 0:
        status_code = 404

    response = HttpResponse(content, content_type=mimetype, status=status_code)
    response['Access-Control-Allow-Origin'] = '*'
    return response
Beispiel #2
0
 def __init__(self,layer_name,minzoom,maxzoom,Sbounds,Wbounds,Nbounds,Ebounds):
     print (layer_name,minzoom,maxzoom,Sbounds,Wbounds,Nbounds,Ebounds)
     self.ignore_cached = True
     self.padding = 0
     self.totalTile = 0
     self.currentTile = 0
     self.config_dict = config.get_config(create_cache=True)
     self.config_path = settings.TILESTACHE_CREATE_CACHE_CONFIG_PATH
     self.layer_name = layer_name
     self.config = buildConfiguration(self.config_dict, self.config_path)
     self.layer = self.config.layers[self.layer_name]
     self.zooms = range(int(minzoom),int(maxzoom)+1)
     self.create_bbox(Sbounds,Wbounds,Nbounds,Ebounds)        
     self.extension = self.create_extenstion()
     self.callback = False
     self.coordinates = self.generateCoordinates()
     self.create_tiles()
Beispiel #3
0
def generate_config():
	get_config(force=True)