本文整理匯總了Python中tilecloud.BoundingPyramid.full方法的典型用法代碼示例。如果您正苦於以下問題:Python BoundingPyramid.full方法的具體用法?Python BoundingPyramid.full怎麽用?Python BoundingPyramid.full使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tilecloud.BoundingPyramid
的用法示例。
在下文中一共展示了BoundingPyramid.full方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_full
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import full [as 別名]
def test_full(self):
bp = BoundingPyramid.full(1, 3)
self.assertRaises(KeyError, bp.zget, 0)
self.assertEqual(bp.zget(1), (Bounds(0, 2), Bounds(0, 2)))
self.assertEqual(bp.zget(2), (Bounds(0, 4), Bounds(0, 4)))
self.assertEqual(bp.zget(3), (Bounds(0, 8), Bounds(0, 8)))
self.assertRaises(KeyError, bp.zget, 4)
示例2: __init__
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import full [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)
示例3: test_metatilecoords
# 需要導入模塊: from tilecloud import BoundingPyramid [as 別名]
# 或者: from tilecloud.BoundingPyramid import full [as 別名]
def test_metatilecoords(self):
bp = BoundingPyramid.full(1, 2)
metatilecoords = bp.metatilecoords(2)
self.assertEqual(TileCoord(1, 0, 0, 2), next(metatilecoords))
self.assertEqual(TileCoord(2, 0, 0, 2), next(metatilecoords))
self.assertEqual(TileCoord(2, 0, 2, 2), next(metatilecoords))
self.assertEqual(TileCoord(2, 2, 0, 2), next(metatilecoords))
self.assertEqual(TileCoord(2, 2, 2, 2), next(metatilecoords))
self.assertRaises(StopIteration, next, metatilecoords)