本文整理匯總了Python中tilecloud.BoundingPyramid.from_wgs84方法的典型用法代碼示例。如果您正苦於以下問題:Python BoundingPyramid.from_wgs84方法的具體用法?Python BoundingPyramid.from_wgs84怎麽用?Python BoundingPyramid.from_wgs84使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tilecloud.BoundingPyramid
的用法示例。
在下文中一共展示了BoundingPyramid.from_wgs84方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import from_wgs84 [as 別名]
def __init__(self, tile_json, urls_key='tiles', **kwargs):
# FIXME schema
# FIXME version 1.0.0 support
d = json.loads(tile_json)
assert 'tiles' in d
assert isinstance(d['tiles'], list)
assert len(d['tiles']) > 0
for key in self.KEYS:
kwargs.setdefault(key, d.get(key, None))
if 'bounding_pyramid' not in kwargs:
zmin, zmax = d.get('minzoom', 0), d.get('maxzoom', 22)
if 'bounds' in d:
lonmin, latmin, lonmax, latmax = d['bounds']
bounding_pyramid = BoundingPyramid.from_wgs84(zmin, zmax,
lonmin, lonmax,
latmin, latmax)
else:
bounding_pyramid = BoundingPyramid.full(zmin, zmax)
kwargs['bounding_pyramid'] = bounding_pyramid
urls = d[urls_key]
if 'content_type' not in kwargs:
exts = set(os.path.splitext(urlparse(url).path)[1] for url in urls)
content_types = set(mimetypes.types_map.get(ext) for ext in exts)
assert len(content_types) == 1
kwargs['content_type'] = content_types.pop()
templates = [re.sub(r'\{([xyz])\}', lambda m: '%%(%s)d' % m.group(1), url)
for url in urls]
tile_layouts = map(TemplateTileLayout, templates)
URLTileStore.__init__(self, tile_layouts, **kwargs)