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


Python TileManager.creator方法代码示例

本文整理汇总了Python中mapproxy.cache.tile.TileManager.creator方法的典型用法代码示例。如果您正苦于以下问题:Python TileManager.creator方法的具体用法?Python TileManager.creator怎么用?Python TileManager.creator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mapproxy.cache.tile.TileManager的用法示例。


在下文中一共展示了TileManager.creator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestTileManagerLocking

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:35,代码来源:test_cache.py

示例2: TestTileManagerBulkMetaTiles

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:53,代码来源:test_cache.py

示例3: TestTileManagerTiledSource

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:16,代码来源:test_cache.py

示例4: TestTileManagerSource

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:20,代码来源:test_cache.py

示例5: TestTileManagerMultipleSources

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:21,代码来源:test_cache.py

示例6: TestTileManagerDifferentSourceGrid

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:23,代码来源:test_cache.py

示例7: TestTileManagerWMSSourceMinimalMetaRequests

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:32,代码来源:test_cache.py

示例8: TestTileManagerMultipleSourcesWithMetaTiles

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [as 别名]
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,代码行数:52,代码来源:test_cache.py

示例9: TestTileManagerWMSSource

# 需要导入模块: from mapproxy.cache.tile import TileManager [as 别名]
# 或者: from mapproxy.cache.tile.TileManager import creator [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))])
开发者ID:GeoDodo,项目名称:mapproxy,代码行数:59,代码来源:test_cache.py


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