本文整理汇总了Python中mapproxy.cache.tile.TileManager类的典型用法代码示例。如果您正苦于以下问题:Python TileManager类的具体用法?Python TileManager怎么用?Python TileManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TileManager类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TestTileManagerLocking
class TestTileManagerLocking(object):
def setup(self):
self.tile_dir = tempfile.mkdtemp()
self.file_cache = MockFileCache(self.tile_dir, 'png', lock_dir=tmp_lock_dir)
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.source = SlowMockSource()
self.image_opts = ImageOptions(format='image/png')
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png',
meta_size=[2, 2], meta_buffer=0, image_opts=self.image_opts)
def test_get_single(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.source.requested,
[((-180.0, -90.0, 180.0, 90.0), (512, 256), SRS(4326))])
def test_concurrent(self):
def do_it():
self.tile_mgr.creator().create_tiles([Tile((0, 0, 1)), Tile((1, 0, 1))])
threads = [threading.Thread(target=do_it) for _ in range(3)]
[t.start() for t in threads]
[t.join() for t in threads]
eq_(self.file_cache.stored_tiles, set([(0, 0, 1), (1, 0, 1)]))
eq_(self.file_cache.loaded_tiles, counting_set([(0, 0, 1), (1, 0, 1), (0, 0, 1), (1, 0, 1)]))
eq_(self.source.requested,
[((-180.0, -90.0, 180.0, 90.0), (512, 256), SRS(4326))])
assert os.path.exists(self.file_cache.tile_location(Tile((0, 0, 1))))
def teardown(self):
shutil.rmtree(self.tile_dir)
开发者ID:atrawog,项目名称:mapproxy,代码行数:33,代码来源:test_cache.py
示例2: TestTileManagerWMSSource
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))])
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:57,代码来源:test_cache.py
示例3: TestTileManagerBulkMetaTiles
class TestTileManagerBulkMetaTiles(object):
def setup(self):
self.file_cache = MockFileCache("/dev/null", "png")
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90], origin="ul")
self.source_base = SolidColorMockSource(color="#ff0000")
self.source_base.supports_meta_tiles = False
self.source_overlay = MockSource()
self.source_overlay.supports_meta_tiles = False
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(
self.grid,
self.file_cache,
[self.source_base, self.source_overlay],
"png",
meta_size=[2, 2],
meta_buffer=0,
locker=self.locker,
bulk_meta_tiles=True,
)
def test_bulk_get(self):
tiles = self.tile_mgr.creator().create_tiles([Tile((0, 0, 2))])
eq_(len(tiles), 2 * 2)
eq_(self.file_cache.stored_tiles, set([(0, 0, 2), (1, 0, 2), (0, 1, 2), (1, 1, 2)]))
for requested in [self.source_base.requested, self.source_overlay.requested]:
eq_(
set(requested),
set(
[
((-180.0, 0.0, -90.0, 90.0), (256, 256), SRS(4326)),
((-90.0, 0.0, 0.0, 90.0), (256, 256), SRS(4326)),
((-180.0, -90.0, -90.0, 0.0), (256, 256), SRS(4326)),
((-90.0, -90.0, 0.0, 0.0), (256, 256), SRS(4326)),
]
),
)
def test_bulk_get_error(self):
self.tile_mgr.sources = [self.source_base, ErrorSource()]
try:
self.tile_mgr.creator().create_tiles([Tile((0, 0, 2))])
except Exception as ex:
eq_(ex.args[0], "source error")
def test_bulk_get_multiple_meta_tiles(self):
tiles = self.tile_mgr.creator().create_tiles([Tile((1, 0, 2)), Tile((2, 0, 2))])
eq_(len(tiles), 2 * 2 * 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)]),
)
开发者ID:olt,项目名称:mapproxy,代码行数:51,代码来源:test_cache.py
示例4: TestTileManagerTiledSource
class TestTileManagerTiledSource(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 = MockTileClient()
self.source = TiledSource(self.grid, self.client)
self.image_opts = ImageOptions(format='image/png')
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png',
image_opts=self.image_opts)
def test_create_tiles(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_(sorted(self.client.requested_tiles), [(0, 0, 1), (1, 0, 1)])
开发者ID:atrawog,项目名称:mapproxy,代码行数:14,代码来源:test_cache.py
示例5: setup
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.source = MockSource()
self.image_opts = ImageOptions(format='image/png')
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png',
image_opts=self.image_opts)
开发者ID:atrawog,项目名称:mapproxy,代码行数:7,代码来源:test_cache.py
示例6: test_sources_with_mixed_support_for_meta_tiles
def test_sources_with_mixed_support_for_meta_tiles(self):
self.source_base.supports_meta_tiles = False
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
meta_size=[2, 2], meta_buffer=0,
locker=self.locker)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:7,代码来源:test_cache.py
示例7: setup
def setup(self):
self.cache_dir = tempfile.mkdtemp()
self.file_cache = FileCache(cache_dir=self.cache_dir, file_ext="png")
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.client = MockTileClient()
self.source = TiledSource(self.grid, self.client)
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], "png", locker=self.locker)
开发者ID:olt,项目名称:mapproxy,代码行数:8,代码来源:test_cache.py
示例8: TestTileManagerSource
class TestTileManagerSource(object):
def setup(self):
self.file_cache = MockFileCache("/dev/null", "png")
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.source = MockSource()
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", image_opts=self.image_opts, locker=self.locker
)
def test_create_tile(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_(
sorted(self.source.requested),
[((-180.0, -90.0, 0.0, 90.0), (256, 256), SRS(4326)), ((0.0, -90.0, 180.0, 90.0), (256, 256), SRS(4326))],
)
开发者ID:olt,项目名称:mapproxy,代码行数:18,代码来源:test_cache.py
示例9: test_sources_with_no_support_for_meta_tiles
def test_sources_with_no_support_for_meta_tiles(self):
self.source_base.supports_meta_tiles = False
self.source_overlay.supports_meta_tiles = False
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
meta_size=[2, 2], meta_buffer=0)
assert self.tile_mgr.meta_grid is None
开发者ID:atrawog,项目名称:mapproxy,代码行数:9,代码来源:test_cache.py
示例10: TestTileManagerMultipleSources
class TestTileManagerMultipleSources(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.source_base = MockSource()
self.source_overlay = MockSource()
self.image_opts = ImageOptions(format='image/png')
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
image_opts=self.image_opts)
self.layer = CacheMapLayer(self.tile_mgr)
def test_get_single(self):
self.tile_mgr.creator().create_tiles([Tile((0, 0, 1))])
eq_(self.file_cache.stored_tiles, set([(0, 0, 1)]))
eq_(self.source_base.requested,
[((-180.0, -90.0, 0.0, 90.0), (256, 256), SRS(4326))])
eq_(self.source_overlay.requested,
[((-180.0, -90.0, 0.0, 90.0), (256, 256), SRS(4326))])
开发者ID:atrawog,项目名称:mapproxy,代码行数:19,代码来源:test_cache.py
示例11: setup
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 = MockTileClient()
self.source = TiledSource(self.grid, 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',
image_opts=self.image_opts,
locker=self.locker,
)
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:11,代码来源:test_cache.py
示例12: TestTileManagerDifferentSourceGrid
class TestTileManagerDifferentSourceGrid(object):
def setup(self):
self.file_cache = MockFileCache("/dev/null", "png")
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.source_grid = TileGrid(SRS(4326), bbox=[0, -90, 180, 90])
self.client = MockTileClient()
self.source = TiledSource(self.source_grid, 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", image_opts=self.image_opts, locker=self.locker
)
def test_create_tiles(self):
self.tile_mgr.creator().create_tiles([Tile((1, 0, 1))])
eq_(self.file_cache.stored_tiles, set([(1, 0, 1)]))
eq_(self.client.requested_tiles, [(0, 0, 0)])
@raises(InvalidSourceQuery)
def test_create_tiles_out_of_bounds(self):
self.tile_mgr.creator().create_tiles([Tile((0, 0, 0))])
开发者ID:olt,项目名称:mapproxy,代码行数:21,代码来源:test_cache.py
示例13: TestTileManagerWMSSourceMinimalMetaRequests
class TestTileManagerWMSSourceMinimalMetaRequests(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.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png',
meta_size=[2, 2], meta_buffer=10, minimize_meta_requests=True)
def test_create_tile_single(self):
# not enabled for single tile requests
self.tile_mgr.creator().create_tiles([Tile((0, 0, 2))])
eq_(self.file_cache.stored_tiles,
set([(0, 0, 2), (0, 1, 2), (1, 0, 2), (1, 1, 2)]))
eq_(sorted(self.client.requested),
[((-180.0, -90.0, 3.515625, 90.0), (522, 512), SRS(4326))])
def test_create_tile_multiple(self):
self.tile_mgr.creator().create_tiles([Tile((4, 0, 3)), Tile((4, 1, 3)), Tile((4, 2, 3))])
eq_(self.file_cache.stored_tiles,
set([(4, 0, 3), (4, 1, 3), (4, 2, 3)]))
eq_(sorted(self.client.requested),
[((-1.7578125, -90, 46.7578125, 46.7578125), (276, 778), SRS(4326))])
def test_create_tile_multiple_fragmented(self):
self.tile_mgr.creator().create_tiles([Tile((4, 0, 3)), Tile((5, 2, 3))])
eq_(self.file_cache.stored_tiles,
set([(4, 0, 3), (4, 1, 3), (4, 2, 3), (5, 0, 3), (5, 1, 3), (5, 2, 3)]))
eq_(sorted(self.client.requested),
[((-1.7578125, -90, 91.7578125, 46.7578125), (532, 778), SRS(4326))])
开发者ID:atrawog,项目名称:mapproxy,代码行数:30,代码来源:test_cache.py
示例14: TestTileManagerStaleTiles
class TestTileManagerStaleTiles(object):
def setup(self):
self.cache_dir = tempfile.mkdtemp()
self.file_cache = FileCache(cache_dir=self.cache_dir, file_ext='png')
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.client = MockTileClient()
self.source = TiledSource(self.grid, self.client)
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png')
def teardown(self):
shutil.rmtree(self.cache_dir)
def test_is_stale_missing(self):
assert not self.tile_mgr.is_stale(Tile((0, 0, 1)))
def test_is_stale_not_expired(self):
create_cached_tile(Tile((0, 0, 1)), self.file_cache)
assert not self.tile_mgr.is_stale(Tile((0, 0, 1)))
def test_is_stale_expired(self):
create_cached_tile(Tile((0, 0, 1)), self.file_cache, timestamp=time.time()-3600)
self.tile_mgr._expire_timestamp = time.time()
assert self.tile_mgr.is_stale(Tile((0, 0, 1)))
开发者ID:atrawog,项目名称:mapproxy,代码行数:22,代码来源:test_cache.py
示例15: setup
def setup(self):
self.file_cache = MockFileCache('/dev/null', 'png')
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90], origin='ul')
self.source_base = SolidColorMockSource(color='#ff0000')
self.source_base.supports_meta_tiles = False
self.source_overlay = MockSource()
self.source_overlay.supports_meta_tiles = False
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
meta_size=[2, 2], meta_buffer=0,
locker=self.locker,
bulk_meta_tiles=True,
)
开发者ID:LKajan,项目名称:mapproxy,代码行数:14,代码来源:test_cache.py
示例16: TestTileManagerMultipleSourcesWithMetaTiles
class TestTileManagerMultipleSourcesWithMetaTiles(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.source_base = SolidColorMockSource(color='#ff0000')
self.source_base.supports_meta_tiles = True
self.source_overlay = MockSource()
self.source_overlay.supports_meta_tiles = True
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
meta_size=[2, 2], meta_buffer=0,
locker=self.locker,
)
def test_merged_tiles(self):
tiles = 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.source_base.requested,
[((-180.0, -90.0, 180.0, 90.0), (512, 256), SRS(4326))])
eq_(self.source_overlay.requested,
[((-180.0, -90.0, 180.0, 90.0), (512, 256), SRS(4326))])
hist = tiles[0].source.as_image().histogram()
# lots of red (base), but not everything (overlay)
assert 55000 < hist[255] < 60000 # red = 0xff
assert 55000 < hist[256] # green = 0x00
assert 55000 < hist[512] # blue = 0x00
@raises(ValueError)
def test_sources_with_mixed_support_for_meta_tiles(self):
self.source_base.supports_meta_tiles = False
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
meta_size=[2, 2], meta_buffer=0,
locker=self.locker)
def test_sources_with_no_support_for_meta_tiles(self):
self.source_base.supports_meta_tiles = False
self.source_overlay.supports_meta_tiles = False
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(self.grid, self.file_cache,
[self.source_base, self.source_overlay], 'png',
meta_size=[2, 2], meta_buffer=0,
locker=self.locker)
assert self.tile_mgr.meta_grid is None
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:50,代码来源:test_cache.py
示例17: test_sources_with_no_support_for_meta_tiles
def test_sources_with_no_support_for_meta_tiles(self):
self.source_base.supports_meta_tiles = False
self.source_overlay.supports_meta_tiles = False
self.locker = TileLocker(tmp_lock_dir, 10, "id")
self.tile_mgr = TileManager(
self.grid,
self.file_cache,
[self.source_base, self.source_overlay],
"png",
meta_size=[2, 2],
meta_buffer=0,
locker=self.locker,
)
assert self.tile_mgr.meta_grid is None
开发者ID:olt,项目名称:mapproxy,代码行数:16,代码来源:test_cache.py
示例18: TestTileManagerRemoveTiles
class TestTileManagerRemoveTiles(object):
def setup(self):
self.cache_dir = tempfile.mkdtemp()
self.file_cache = FileCache(cache_dir=self.cache_dir, file_ext='png')
self.grid = TileGrid(SRS(4326), bbox=[-180, -90, 180, 90])
self.client = MockTileClient()
self.source = TiledSource(self.grid, self.client)
self.image_opts = ImageOptions(format='image/png')
self.tile_mgr = TileManager(self.grid, self.file_cache, [self.source], 'png',
image_opts=self.image_opts)
def teardown(self):
shutil.rmtree(self.cache_dir)
def test_remove_missing(self):
self.tile_mgr.remove_tile_coords([(0, 0, 0), (0, 0, 1)])
def test_remove_existing(self):
create_cached_tile(Tile((0, 0, 1)), self.file_cache)
assert self.tile_mgr.is_cached(Tile((0, 0, 1)))
self.tile_mgr.remove_tile_coords([(0, 0, 0), (0, 0, 1)])
assert not self.tile_mgr.is_cached(Tile((0, 0, 1)))
开发者ID:atrawog,项目名称:mapproxy,代码行数:21,代码来源:test_cache.py
注:本文中的mapproxy.cache.tile.TileManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论