本文整理匯總了Python中TileStache.splitPathInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python TileStache.splitPathInfo方法的具體用法?Python TileStache.splitPathInfo怎麽用?Python TileStache.splitPathInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TileStache
的用法示例。
在下文中一共展示了TileStache.splitPathInfo方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: tiles
# 需要導入模塊: import TileStache [as 別名]
# 或者: from TileStache import splitPathInfo [as 別名]
def tiles(request, service_slug, z, x, y, extension):
"""
Proxy to tilestache
{X} - coordinate column.
{Y} - coordinate row.
{B} - bounding box.
{Z} - zoom level.
{S} - host.
"""
service = TileService.objects.get(slug=service_slug)
config = {
"cache": {"name": "Test"},
"layers": {}
}
config["layers"][service_slug]={
"provider": {
'name': 'mapnik',
"mapfile": service.mapfile
}
}
config = TileStache.Config.buildConfiguration(config)
path_info = "%s/%s/%s/%s.%s" % (service_slug, z, x, y, extension)
coord, extension = TileStache.splitPathInfo(path_info)[1:]
mimetype, content = TileStache.getTile(config.layers[service_slug], coord, extension)
return HttpResponse(content, mimetype=mimetype)
示例2: tiles
# 需要導入模塊: import TileStache [as 別名]
# 或者: from TileStache import splitPathInfo [as 別名]
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
示例3: tilestache
# 需要導入模塊: import TileStache [as 別名]
# 或者: from TileStache import splitPathInfo [as 別名]
def tilestache(request, layer_name, z, x, y, extension):
"""
Proxy to tilestache
{X} - coordinate column.
{Y} - coordinate row.
{B} - bounding box.
{Z} - zoom level.
{S} - host.
"""
config = get_config()
path_info = "%s/%s/%s/%s.%s" % (layer_name, z, x, y, extension)
coord, extension = TileStache.splitPathInfo(path_info)[1:]
mimetype, content = TileStache.getTile(config.layers[layer_name], coord, extension)
return HttpResponse(content, mimetype=mimetype)
示例4: application
# 需要導入模塊: import TileStache [as 別名]
# 或者: from TileStache import splitPathInfo [as 別名]
def application(environ, start_response):
config = environ["TILESTACHE_CONFIG"]
layer, coord, ext = TileStache.splitPathInfo(environ["PATH_INFO"])
if not config.layers.get(layer, False):
print >>environ["wsgi.errors"], "[gunistache] unknown layer: " + layer
status = "404 NOT FOUND"
data = ""
else:
try:
content_type, data = TileStache.handleRequest(config.layers[layer], coord, ext)
status = "200 OK"
except Exception, e:
print >>environ["wsgi.errors"], "[gunistache] failed to handle request:" + str(e)
status = "500 SERVER ERROR"
data = str(e)
示例5: tilestache_tiles
# 需要導入模塊: import TileStache [as 別名]
# 或者: from TileStache import splitPathInfo [as 別名]
def tilestache_tiles(request, layer_name, z, x, y, extension):
"""
:param request:
:param layer_name:
:param z:
:param x:
:param y:
:param extension:
:return:
Proxy to tilestache
{X} - coordinate column.
{Y} - coordinate row.
{B} - bounding box.
{Z} - zoom level.
{S} - host.
"""
config = TileStacheConfig.objects.filter(name='default')[0].config
path_info = "%s/%s/%s/%s.%s" % (layer_name, z, x, y, extension)
coord, extension = TileStache.splitPathInfo(path_info)[1:]
mimetype, content = TileStache.getTile(config.layers[layer_name], coord, extension)
return HttpResponse(content, mimetype=mimetype)