本文整理汇总了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)