本文整理匯總了Python中tiles.TilesManager.tile方法的典型用法代碼示例。如果您正苦於以下問題:Python TilesManager.tile方法的具體用法?Python TilesManager.tile怎麽用?Python TilesManager.tile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tiles.TilesManager
的用法示例。
在下文中一共展示了TilesManager.tile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_download_tile
# 需要導入模塊: from tiles import TilesManager [as 別名]
# 或者: from tiles.TilesManager import tile [as 別名]
def test_download_tile(self):
mb = TilesManager(cache=False)
tile = (1, 1, 1)
# Unknown URL keyword
mb = TilesManager(tiles_url="http://{X}.tile.openstreetmap.org/{z}/{x}/{y}.png")
self.assertRaises(DownloadError, mb.tile, (1, 1, 1))
# With subdomain keyword
mb = TilesManager(tiles_url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
content = mb.tile(tile)
self.assertTrue(content is not None)
# No subdomain keyword
mb = TilesManager(tiles_url="http://tile.openstreetmap.org/{z}/{x}/{y}.png")
content = mb.tile(tile)
self.assertTrue(content is not None)
# Subdomain in available range
mb = TilesManager(tiles_url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
tiles_subdomains=list("abc"))
for y in range(3):
content = mb.tile((10, 0, y))
self.assertTrue(content is not None)
# Subdomain out of range
mb = TilesManager(tiles_subdomains=list("abcz"))
self.assertRaises(DownloadError, mb.tile, (10, 1, 2))
# Invalid URL
mb = TilesManager(tiles_url="http://{s}.osm.com")
self.assertRaises(DownloadError, mb.tile, (10, 1, 2))
示例2: test_cache_is_stored_at_TMS_format
# 需要導入模塊: from tiles import TilesManager [as 別名]
# 或者: from tiles.TilesManager import tile [as 別名]
def test_cache_is_stored_at_TMS_format(self):
tm = TilesManager(tiles_url="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", cache=True, cache_scheme='tms')
tilecontent = tm.tile((12, 2064, 1495))
self.assertTrue(os.path.exists(os.path.join(self.temp_path, '12', '2064', '2600.png')))