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


Python TileGrid.closest_level方法代码示例

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


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

示例1: test_above_first_res

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
 def test_above_first_res(self):
     grid = TileGrid(res=[1000, 500, 250, 100, 50], threshold_res=[1100, 750])
     grid.stretch_factor = 1.1
     eq_(grid.closest_level(1200), 0)
     eq_(grid.closest_level(1100), 0)
     eq_(grid.closest_level(1000), 0)
     eq_(grid.closest_level(800), 0)
     eq_(grid.closest_level(750.1), 0)
     eq_(grid.closest_level(750), 1)
开发者ID:LKajan,项目名称:mapproxy,代码行数:11,代码来源:test_grid.py

示例2: TestFixedResolutionsTileGrid

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
class TestFixedResolutionsTileGrid(TileGridTest):
    def setup(self):
        self.res = [1000.0, 500.0, 200.0, 100.0, 50.0, 20.0, 5.0]
        bbox = (3250000, 5230000, 3930000, 6110000)
        self.grid = TileGrid(SRS(31467), bbox=bbox, res=self.res)

    def test_resolution(self):
        for level, res in enumerate(self.res):
            assert res == self.grid.resolution(level)

    def test_closest_level(self):
        assert self.grid.closest_level(2000) == 0
        assert self.grid.closest_level(1000) == 0
        assert self.grid.closest_level(950) == 0
        assert self.grid.closest_level(210) == 2

    def test_affected_tiles(self):
        req_bbox = (3250000, 5230000, 3930000, 6110000)
        self.grid.max_shrink_factor = 10
        bbox, grid_size, tiles = \
            self.grid.get_affected_tiles(req_bbox, (256, 256))
        assert bbox == (req_bbox[0], req_bbox[1],
                        req_bbox[0]+1000*256*3, req_bbox[1]+1000*256*4)
        assert grid_size == (3, 4)
        tiles = list(tiles)
        assert tiles == [(0, 3, 0), (1, 3, 0), (2, 3, 0),
                         (0, 2, 0), (1, 2, 0), (2, 2, 0),
                         (0, 1, 0), (1, 1, 0), (2, 1, 0),
                         (0, 0, 0), (1, 0, 0), (2, 0, 0),
                         ]

    def test_affected_tiles_2(self):
        req_bbox = (3250000, 5230000, 3930000, 6110000)
        self.grid.max_shrink_factor = 2.0
        try:
            bbox, grid_size, tiles = \
                self.grid.get_affected_tiles(req_bbox, (256, 256))
        except NoTiles:
            pass
        else:
            assert False, 'got no exception'
    def test_grid(self):
        for level, grid_size in [(0, (3, 4)), (1, (6, 7)), (2, (14, 18))]:
            yield self.check_grid, level, grid_size

    def test_tile_bbox(self):
        tile_bbox = self.grid.tile_bbox((0, 0, 0)) # w: 1000x256
        assert tile_bbox == (3250000.0, 5230000.0, 3506000.0, 5486000.0)
        tile_bbox = self.grid.tile_bbox((0, 0, 1)) # w: 500x256
        assert tile_bbox == (3250000.0, 5230000.0, 3378000.0, 5358000.0)
        tile_bbox = self.grid.tile_bbox((0, 0, 2)) # w: 200x256
        assert tile_bbox == (3250000.0, 5230000.0, 3301200.0, 5281200.0)
开发者ID:deleted,项目名称:mapproxy,代码行数:54,代码来源:test_grid.py

示例3: TestGKTileGridUL

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
class TestGKTileGridUL(TileGridTest):
    """
    Custom grid with ul origin.
    """
    def setup(self):
        self.grid = TileGrid(SRS(31467),
            bbox=(3300000, 5300000, 3900000, 6000000), origin='ul',
            res=[1500, 1000, 500, 300, 150, 100])

    def test_bbox(self):
        assert self.grid.bbox == (3300000, 5300000, 3900000, 6000000)

    def test_tile_bbox(self):
        eq_(self.grid.tile_bbox((0, 0, 0)),
            (3300000.0, 5616000.0, 3684000.0, 6000000.0))
        eq_(self.grid.tile_bbox((1, 0, 0)),
            (3684000.0, 5616000.0, 4068000.0, 6000000.0))
        eq_(self.grid.tile_bbox((1, 1, 0)),
            (3684000.0, 5232000.0, 4068000.0, 5616000.0))

    def test_tile(self):
        x, y = 3310000, 5990000
        eq_(self.grid.tile(x, y, 0), (0, 0, 0))
        eq_(self.grid.tile(x, y, 1), (0, 0, 1))
        eq_(self.grid.tile(x, y, 2), (0, 0, 2))

        x, y = 3890000, 5310000
        eq_(self.grid.tile(x, y, 0), (1, 1, 0))
        eq_(self.grid.tile(x, y, 1), (2, 2, 1))
        eq_(self.grid.tile(x, y, 2), (4, 5, 2))

    def test_grids(self):
        assert_grid_size(self.grid, 0, (2, 2))
        assert_grid_size(self.grid, 1, (3, 3))
        assert_grid_size(self.grid, 2, (5, 6))

    def test_closest_level(self):
        assert self.grid.closest_level(1500) == 0
        assert self.grid.closest_level(1000) == 1
        assert self.grid.closest_level(900) == 1
        assert self.grid.closest_level(600) == 2

    def test_adjacent_tile_bbox(self):
        t1 = self.grid.tile_bbox((0, 0, 1))
        t2 = self.grid.tile_bbox((1, 0, 1))
        t3 = self.grid.tile_bbox((0, 1, 1))
        assert t1[1] == t2[1]
        assert t1[3] == t2[3]
        assert t1[2] == t2[0]
        assert t1[0] == t3[0]
        assert t1[1] == t3[3]
开发者ID:deleted,项目名称:mapproxy,代码行数:53,代码来源:test_grid.py

示例4: TestClosestLevelTinyResFactor

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
class TestClosestLevelTinyResFactor(object):
    def setup(self):
        self.grid = TileGrid(SRS(31467),
            bbox=[420000,30000,900000,350000], origin='ul',
            res=[4000,3750,3500,3250,3000,2750,2500,2250,2000,1750,1500,1250,1000,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,0.5],
        )

    def test_closest_level(self):
        eq_(self.grid.closest_level(5000), 0)
        eq_(self.grid.closest_level(4000), 0)
        eq_(self.grid.closest_level(3750), 1)
        eq_(self.grid.closest_level(3500), 2)
        eq_(self.grid.closest_level(3250), 3)
        eq_(self.grid.closest_level(3000), 4)
开发者ID:LKajan,项目名称:mapproxy,代码行数:16,代码来源:test_grid.py

示例5: test_explicit_grid

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
    def test_explicit_grid(self):
        grid = TileGrid(res=[0.1, 0.05, 0.01])
        eq_(grid.resolution(0), 0.1)
        eq_(grid.resolution(1), 0.05)
        eq_(grid.resolution(2), 0.01)

        eq_(grid.closest_level(0.00001), 2)
开发者ID:deleted,项目名称:mapproxy,代码行数:9,代码来源:test_grid.py

示例6: TestGKTileGrid

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
class TestGKTileGrid(TileGridTest):
    def setup(self):
        self.grid = TileGrid(SRS(31467), bbox=(3250000, 5230000, 3930000, 6110000))

    def test_bbox(self):
        assert self.grid.bbox == (3250000, 5230000, 3930000, 6110000)

    def test_resolution(self):
        res = self.grid.resolution(0)
        width = self.grid.bbox[2] - self.grid.bbox[0]
        height = self.grid.bbox[3] - self.grid.bbox[1]
        assert height == 880000.0 and width == 680000.0
        assert res == 880000.0/256

    def test_tile_bbox(self):
        tile_bbox = self.grid.tile_bbox((0, 0, 0))
        assert tile_bbox == (3250000.0, 5230000.0, 4130000.0, 6110000.0)

    def test_tile(self):
        x, y = 3450000, 5890000
        assert [self.grid.tile(x, y, level) for level in range(5)] == \
            [(0, 0, 0), (0, 1, 1), (0, 3, 2), (1, 6, 3), (3, 12, 4)]

    def test_grids(self):
        for level, grid_size in [(0, (1, 1)), (1, (2, 2)), (2, (4, 4)), (3, (7, 8))]:
            yield self.check_grid, level, grid_size

    def test_closest_level(self):
        assert self.grid.closest_level(880000.0/256) == 0
        assert self.grid.closest_level(600000.0/256) == 1
        assert self.grid.closest_level(440000.0/256) == 1
        assert self.grid.closest_level(420000.0/256) == 1

    def test_adjacent_tile_bbox(self):
        t1 = self.grid.tile_bbox((0, 0, 1))
        t2 = self.grid.tile_bbox((1, 0, 1))
        t3 = self.grid.tile_bbox((0, 1, 1))
        assert t1[1] == t2[1]
        assert t1[3] == t2[3]
        assert t1[2] == t2[0]
        assert t1[0] == t3[0]
        assert t1[3] == t3[1]
开发者ID:deleted,项目名称:mapproxy,代码行数:44,代码来源:test_grid.py

示例7: test_upper_bound

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
 def test_upper_bound(self):
     # thresholds near the next upper res value (within threshold)
     grid = TileGrid(res=[1000, 500, 250, 100, 50], threshold_res=[495, 240])
     grid.stretch_factor = 1.1
     eq_(grid.closest_level(1100), 0)
     # regular transition (w/stretchfactor)
     eq_(grid.closest_level(950), 0)
     eq_(grid.closest_level(800), 1)
     eq_(grid.closest_level(500), 1)
     # transition at threshold
     eq_(grid.closest_level(496), 1)
     eq_(grid.closest_level(495), 2)
     eq_(grid.closest_level(250), 2)
     # transition at threshold (within strechfactor)
     eq_(grid.closest_level(241), 2)
     eq_(grid.closest_level(240), 3)
     eq_(grid.closest_level(100), 3)
     # regular transition (w/stretchfactor)
     eq_(grid.closest_level(92), 3)
     eq_(grid.closest_level(90), 4)
开发者ID:deleted,项目名称:mapproxy,代码行数:22,代码来源:test_grid.py

示例8: test_lower_bound

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import closest_level [as 别名]
 def test_lower_bound(self):
     # thresholds near the next lower res value
     grid = TileGrid(res=[1000, 500, 250, 100, 50], threshold_res=[300, 110])
     grid.stretch_factor = 1.1
     eq_(grid.closest_level(1100), 0)
     # regular transition (w/stretchfactor)
     eq_(grid.closest_level(950), 0)
     eq_(grid.closest_level(800), 1)
     eq_(grid.closest_level(500), 1)
     # transition at threshold
     eq_(grid.closest_level(301), 1)
     eq_(grid.closest_level(300), 2)
     eq_(grid.closest_level(250), 2)
     # transition at threshold
     eq_(grid.closest_level(111), 2)
     eq_(grid.closest_level(110), 3)
     eq_(grid.closest_level(100), 3)
     # regular transition (w/stretchfactor)
     eq_(grid.closest_level(92), 3)
     eq_(grid.closest_level(90), 4)
开发者ID:deleted,项目名称:mapproxy,代码行数:22,代码来源:test_grid.py


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