本文整理汇总了Python中TileStache.handleRequest方法的典型用法代码示例。如果您正苦于以下问题:Python TileStache.handleRequest方法的具体用法?Python TileStache.handleRequest怎么用?Python TileStache.handleRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileStache
的用法示例。
在下文中一共展示了TileStache.handleRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import handleRequest [as 别名]
def render(self, config, input_img, coord):
layer_img, color_img, mask_img = None, None, None
if self.layername:
layer = config.layers[self.layername]
mime, body = TileStache.handleRequest(layer, coord, 'png')
layer_img = PIL.Image.open(StringIO(body))
if self.maskname:
layer = config.layers[self.maskname]
mime, body = TileStache.handleRequest(layer, coord, 'png')
mask_img = PIL.Image.open(StringIO(body)).convert('L')
if self.colorname:
color = makeColor(self.colorname)
color_img = PIL.Image.new('RGBA', input_img.size, color)
output_img = input_img.copy()
if layer_img and color_img and mask_img:
raise Exception('could be ugly')
elif layer_img and color_img:
output_img.paste(color_img, None, color_img)
output_img.paste(layer_img, None, layer_img)
elif layer_img and mask_img:
# need to combine the masks here
layermask_img = PIL.Image.new('RGBA', layer_img.size, (0, 0, 0, 0))
layermask_img.paste(layer_img, None, mask_img)
output_img.paste(layermask_img, None, layermask_img)
elif color_img and mask_img:
output_img.paste(color_img, None, mask_img)
elif layer_img:
output_img.paste(layer_img, None, layer_img)
elif color_img:
output_img.paste(color_img, None, color_img)
elif mask_img:
raise Exception('nothing')
else:
raise Exception('nothing')
return output_img
示例2: renderTile
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import handleRequest [as 别名]
def renderTile(self, width, height, srs, coord):
image = PIL.Image.new('RGBA', (width, height), (0, 0, 0, 0))
image = self.stack.render(self.layer.config, image, coord)
return image
layer = self.layer.config.layers['base']
mime, body = TileStache.handleRequest(layer, coord, 'png')
img_base = PIL.Image.open(StringIO(body))
layer = self.layer.config.layers['outlines']
mime, body = TileStache.handleRequest(layer, coord, 'png')
img_outlines = PIL.Image.open(StringIO(body))
layer = self.layer.config.layers['halos']
mime, body = TileStache.handleRequest(layer, coord, 'png')
img_halos = PIL.Image.open(StringIO(body))
img_outlinesmask = PIL.Image.new('RGBA', img_outlines.size, (0, 0, 0, 0))
img_outlinesmask.paste(img_outlines, None, img_halos.convert('L'))
layer = self.layer.config.layers['streets']
mime, body = TileStache.handleRequest(layer, coord, 'png')
img_streets = PIL.Image.open(StringIO(body))
img = PIL.Image.new('RGBA', (256, 256))
img.paste(img_base, (0, 0), img_base)
img.paste(img_outlines, None, img_outlinesmask)
img.paste(img_streets, (0, 0), img_streets)
return img
pass
示例3: app
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import handleRequest [as 别名]
def app(environ, start_response):
layer, coord, ext = TileStache._splitPathInfo(environ['PATH_INFO'])
if not config.layers.get(layer, False):
status = '404 NOT FOUND'
data = ''
else:
try:
content_type, data = TileStache.handleRequest(config.layers[layer], coord, ext)
status = '200 OK'
except Exception, e:
status = '500 SERVER ERROR'
data = str(e)
示例4: application
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import handleRequest [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)