本文整理汇总了Python中mapproxy.cache.tile.TileManager.lock方法的典型用法代码示例。如果您正苦于以下问题:Python TileManager.lock方法的具体用法?Python TileManager.lock怎么用?Python TileManager.lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapproxy.cache.tile.TileManager
的用法示例。
在下文中一共展示了TileManager.lock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTileManagerWMSSource
# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import lock [as 别名]
class TestTileManagerWMSSource(object):
def setup(self):
self.file_cache = MockFileCache('/dev/null', 'png', lock_dir=tmp_lock_dir)
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.client = MockWMSClient()
self.source = WMSSource(self.client)
self.image_opts = ImageOptions(format='image/png')
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png',
meta_size=[2, 2], meta_buffer=0, image_opts=self.image_opts,
locker=self.locker,
)
def test_same_lock_for_meta_tile(self):
eq_(self.tile_mgr.lock(Tile((0, 0, 1))).lock_file,
self.tile_mgr.lock(Tile((1, 0, 1))).lock_file
)
def test_locks_for_meta_tiles(self):
assert_not_equal(self.tile_mgr.lock(Tile((0, 0, 2))).lock_file,
self.tile_mgr.lock(Tile((2, 0, 2))).lock_file
)
def test_create_tile_first_level(self):
self.tile_mgr.creator().create_tiles([Tile((0, 0, 1)), Tile((1, 0, 1))])
eq_(self.file_cache.stored_tiles, set([(0, 0, 1), (1, 0, 1)]))
eq_(self.client.requested,
[((-180.0, -90.0, 180.0, 90.0), (512, 256), SRS(4326))])
def test_create_tile(self):
self.tile_mgr.creator().create_tiles([Tile((0, 0, 2))])
eq_(self.file_cache.stored_tiles,
set([(0, 0, 2), (1, 0, 2), (0, 1, 2), (1, 1, 2)]))
eq_(sorted(self.client.requested),
[((-180.0, -90.0, 0.0, 90.0), (512, 512), SRS(4326))])
def test_create_tiles(self):
self.tile_mgr.creator().create_tiles([Tile((0, 0, 2)), Tile((2, 0, 2))])
eq_(self.file_cache.stored_tiles,
set([(0, 0, 2), (1, 0, 2), (0, 1, 2), (1, 1, 2),
(2, 0, 2), (3, 0, 2), (2, 1, 2), (3, 1, 2)]))
eq_(sorted(self.client.requested),
[((-180.0, -90.0, 0.0, 90.0), (512, 512), SRS(4326)),
((0.0, -90.0, 180.0, 90.0), (512, 512), SRS(4326))])
def test_load_tile_coords(self):
tiles = self.tile_mgr.load_tile_coords(((0, 0, 2), (2, 0, 2)))
eq_(tiles[0].coord, (0, 0, 2))
assert isinstance(tiles[0].source, ImageSource)
eq_(tiles[1].coord, (2, 0, 2))
assert isinstance(tiles[1].source, ImageSource)
eq_(self.file_cache.stored_tiles,
set([(0, 0, 2), (1, 0, 2), (0, 1, 2), (1, 1, 2),
(2, 0, 2), (3, 0, 2), (2, 1, 2), (3, 1, 2)]))
eq_(sorted(self.client.requested),
[((-180.0, -90.0, 0.0, 90.0), (512, 512), SRS(4326)),
((0.0, -90.0, 180.0, 90.0), (512, 512), SRS(4326))])