当前位置: 首页>>代码示例>>Python>>正文


Python tiles.TilesManager类代码示例

本文整理汇总了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))
开发者ID:roy-bukapeta,项目名称:landez,代码行数:26,代码来源:tests.py

示例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')
开发者ID:roy-bukapeta,项目名称:landez,代码行数:9,代码来源:tests.py

示例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))
开发者ID:Adapptor,项目名称:landez,代码行数:11,代码来源:tests.py

示例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])
开发者ID:roy-bukapeta,项目名称:landez,代码行数:16,代码来源:tests.py

示例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)])
开发者ID:roy-bukapeta,项目名称:landez,代码行数:5,代码来源:tests.py

示例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)])
开发者ID:roy-bukapeta,项目名称:landez,代码行数:4,代码来源:tests.py

示例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')))
开发者ID:roy-bukapeta,项目名称:landez,代码行数:4,代码来源:tests.py

示例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)
开发者ID:3Geo,项目名称:landez,代码行数:29,代码来源:tests.py


注:本文中的tiles.TilesManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。