本文整理汇总了Python中TileStache.parseConfigfile方法的典型用法代码示例。如果您正苦于以下问题:Python TileStache.parseConfigfile方法的具体用法?Python TileStache.parseConfigfile怎么用?Python TileStache.parseConfigfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileStache
的用法示例。
在下文中一共展示了TileStache.parseConfigfile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tile_config
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfigfile [as 别名]
def get_tile_config():
import TileStache as tilestache
pth = os.path.join(TILE_CONFIG_DIR, 'tiles.cfg')
try:
cfg = tilestache.parseConfigfile(pth)
except (IOError, ValueError):
cfg = None
return cfg
示例2: __call__
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfigfile [as 别名]
def __call__(self, environ, start_response):
""" Handle a request, using PATH_INFO and QUERY_STRING from environ.
There are six required query string parameters: width, height,
xmin, ymin, xmax and ymax. Layer name must be supplied in PATH_INFO.
"""
if self.autoreload: # re-parse the config file on every request
try:
self.config = TileStache.parseConfigfile(self.config_path)
except Exception, e:
raise Core.KnownUnknown("Error loading Tilestache config file:\n%s" % str(e))
示例3: configuration
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfigfile [as 别名]
(options, args) = parser.parse_args()
if options.include_paths:
for p in options.include_paths.split(':'):
path.insert(0, p)
import TileStache
try:
if options.config is None:
raise TileStache.Core.KnownUnknown('Missing required configuration (--config) parameter.')
if options.layer is None:
raise TileStache.Core.KnownUnknown('Missing required layer (--layer) parameter.')
config = TileStache.parseConfigfile(options.config)
if options.layer not in config.layers:
raise TileStache.Core.KnownUnknown('"%s" is not a layer I know about. Here are some that I do know about: %s.' % (options.layer, ', '.join(sorted(config.layers.keys()))))
provider = Provider(config.layers[options.layer], options.verbose, options.ignore_cached)
try:
outfile = args[0]
except IndexError:
raise BadComposure('Error: Missing output file.')
if options.center and options.extent:
raise BadComposure("Error: bad map coverage, center and extent can't both be set.")
elif options.extent and options.dimensions and options.zoom:
示例4: make_server
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfigfile [as 别名]
"-v",
"--verbose",
dest="verbose",
help="Enable verbose logging. Default is false.",
action="store_true",
default=False,
)
options, args = parser.parse_args()
if options.verbose:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
# Some day, Python will have a -I flag...
if options.include:
for path in options.include.split(":"):
logging.debug("include %s to Python's sys.path")
sys.path.insert(0, path)
logging.info("start server on %s:%s" % (options.host, options.port))
# http://docs.python.org/library/wsgiref.html
httpd = make_server(options.host, int(options.port), application)
httpd.base_environ["TILESTACHE_CONFIG"] = TileStache.parseConfigfile(options.config)
httpd.serve_forever()
示例5: Response
# 需要导入模块: import TileStache [as 别名]
# 或者: from TileStache import parseConfigfile [as 别名]
data = response.read()
pfTile = vector_pb2.VectorMapTile()
pfTile.ParseFromString(data)
return Response(
content_type="text/plain",
body=pfTile.__str__()
)
@view_config(route_name='tileFinder')
def getTile(request):
proj = vectormap.GoogleProjection()
latlon = map(float,request.matchdict['latlon'].split(','))
zoom = int(request.matchdict['zoom'])
tile = proj.fromLLtoTileId(latlon, zoom)
return Response(
content_type="text/plain",
body=tile.__str__()
)
if __name__ == '__main__':
config_path = 'tilestache.cfg'
tsConfig = TileStache.parseConfigfile(config_path)
config = Configurator()
config.add_route('ref', '/ref/{zoom}/{y}/{x}')
config.add_route('tileFinder', '/finder/{zoom}/{latlon}')
config.scan('server')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8088, app)
print 'starting server...'
server.serve_forever()