本文整理匯總了Python中tiles.TilesManager類的典型用法代碼示例。如果您正苦於以下問題:Python TilesManager類的具體用法?Python TilesManager怎麽用?Python TilesManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TilesManager類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_download_tile
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_folder
def test_cache_folder(self):
mb = TilesManager(tiles_url='http://server')
self.assertEqual(mb.cache.folder, '/tmp/landez/server')
over = TilesManager(tiles_url='http://toto')
self.assertEqual(over.cache.folder, '/tmp/landez/toto')
mb.add_layer(over)
self.assertEqual(mb.cache.folder, '/tmp/landez/servertoto10')
mb.add_layer(over, 0.5)
self.assertEqual(mb.cache.folder, '/tmp/landez/servertoto10toto05')
示例3: test_clean
def test_clean(self):
mb = TilesManager()
self.assertEqual(mb.tmp_dir, '/tmp/landez')
# Missing dir
self.assertFalse(os.path.exists(mb.tmp_dir))
mb.clean()
# Empty dir
os.makedirs(mb.tmp_dir)
self.assertTrue(os.path.exists(mb.tmp_dir))
mb.clean()
self.assertFalse(os.path.exists(mb.tmp_dir))
示例4: test_tileslist
def test_tileslist(self):
mb = TilesManager()
# World at level 0
l = mb.tileslist((-180.0, -90.0, 180.0, 90.0), [0])
self.assertEqual(l, [(0, 0, 0)])
# World at levels [0, 1]
l = mb.tileslist((-180.0, -90.0, 180.0, 90.0), [0, 1])
self.assertEqual(l, [(0, 0, 0),
(1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)])
# Incorrect bounds
self.assertRaises(InvalidCoverageError, mb.tileslist, (-91.0, -180.0), [0])
self.assertRaises(InvalidCoverageError, mb.tileslist, (-90.0, -180.0, 180.0, 90.0), [])
self.assertRaises(InvalidCoverageError, mb.tileslist, (-91.0, -180.0, 180.0, 90.0), [0])
self.assertRaises(InvalidCoverageError, mb.tileslist, (-91.0, -180.0, 181.0, 90.0), [0])
self.assertRaises(InvalidCoverageError, mb.tileslist, (-90.0, 180.0, 180.0, 90.0), [0])
self.assertRaises(InvalidCoverageError, mb.tileslist, (-30.0, -90.0, -50.0, 90.0), [0])
示例5: test_tileslist_at_z1_x0_y0_tms
def test_tileslist_at_z1_x0_y0_tms(self):
mb = TilesManager()
l = mb.tileslist((-180.0, 1, -1, 90.0), [1], scheme='tms')
self.assertEqual(l, [(1, 0, 1)])
示例6: test_tileslist_at_z1_x0_y0
def test_tileslist_at_z1_x0_y0(self):
mb = TilesManager()
l = mb.tileslist((-180.0, 1, -1, 90.0), [1])
self.assertEqual(l, [(1, 0, 0)])
示例7: test_cache_is_stored_at_TMS_format
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')))
示例8: test_download_tile
def test_download_tile(self):
output = '/tmp/tile.png'
if os.path.exists(output): os.remove(output)
# Unknown URL keyword
mb = TilesManager()
mb.tiles_url = "http://{X}.tile.openstreetmap.org/{z}/{x}/{y}.png"
self.assertRaises(DownloadError, mb.download_tile, output, 1, 1, 1)
self.assertFalse(os.path.exists(output))
# With subdomain keyword
mb.tiles_url = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
mb.download_tile(output, 1, 1, 1)
self.assertTrue(os.path.exists(output))
# No subdomain keyword
mb.tiles_url = "http://tile.cloudmade.com/f1fe9c2761a15118800b210c0eda823c/1/{size}/{z}/{x}/{y}.png"
mb.download_tile(output, 1, 1, 1)
self.assertTrue(os.path.exists(output))
# Subdomain in available range
mb.tiles_url = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
mb.tiles_subdomains = list("abc")
for y in range(3):
mb.download_tile(output, 10, 0, y)
self.assertTrue(os.path.exists(output))
# Subdomain out of range
mb.tiles_subdomains = list("abcz")
self.assertRaises(DownloadError, mb.download_tile, output, 10, 1, 2)
# Clean out
os.remove(output)