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


Python TileGrid.get_affected_tiles方法代码示例

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


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

示例1: test_broken_bbox

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import get_affected_tiles [as 别名]
 def test_broken_bbox(self):
     grid = TileGrid()
     # broken request from "ArcGIS Client Using WinInet"
     req_bbox = (-10000855.0573254,2847125.18913603,-9329367.42767611,4239924.78564583)
     try:
         grid.get_affected_tiles(req_bbox, (256, 256), req_srs=SRS(31467))
     except TransformationError:
         pass
     else:
         assert False, 'Expected TransformationError'
开发者ID:deleted,项目名称:mapproxy,代码行数:12,代码来源:test_grid.py

示例2: TestFixedResolutionsTileGrid

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import get_affected_tiles [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: TestWGS83TileGridUL

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import get_affected_tiles [as 别名]
class TestWGS83TileGridUL(object):
    def setup(self):
        self.grid = TileGrid(4326, bbox=(-180, -90, 180, 90), origin='ul')

    def test_resolution(self):
        assert_almost_equal(self.grid.resolution(0), 1.40625)
        assert_almost_equal(self.grid.resolution(1), 1.40625/2)

    def test_bbox(self):
        eq_(self.grid.bbox, (-180.0, -90.0, 180.0, 90.0))

    def test_tile_bbox(self):
        eq_(self.grid.tile_bbox((0, 0, 0)), (-180.0, -270.0, 180.0, 90.0))
        eq_(self.grid.tile_bbox((0, 0, 0), limit=True), (-180.0, -90.0, 180.0, 90.0))
        eq_(self.grid.tile_bbox((0, 0, 1)), (-180.0, -90.0, 0.0, 90.0))

    def test_tile(self):
        eq_(self.grid.tile(-170, -80, 0), (0, 0, 0))
        eq_(self.grid.tile(-170, -80, 1), (0, 0, 1))
        eq_(self.grid.tile(-170, -80, 2), (0, 1, 2))

    def test_grid_size(self):
        eq_(self.grid.grid_sizes[0], (1, 1))
        eq_(self.grid.grid_sizes[1], (2, 1))
        eq_(self.grid.grid_sizes[2], (4, 2))

    def test_affected_tiles(self):
        bbox, grid, tiles = self.grid.get_affected_tiles((-180,-90,180,90), (512,256))
        eq_(bbox, (-180.0, -90.0, 180.0, 90.0))
        eq_(grid, (2, 1))
        eq_(list(tiles), [(0, 0, 1), (1, 0, 1)])

        bbox, grid, tiles = self.grid.get_affected_tiles((-180,-90,0,90), (512, 512))
        eq_(bbox, (-180.0, -90.0, 0.0, 90.0))
        eq_(grid, (2, 2))
        eq_(list(tiles), [(0, 0, 2), (1, 0, 2), (0, 1, 2), (1, 1, 2)])

    def test_affected_level_tiles(self):
        bbox, grid, tiles = self.grid.get_affected_level_tiles((-180,-90,180,90), 1)
        eq_(grid, (2, 1))
        eq_(bbox, (-180.0, -90.0, 180.0, 90.0))
        eq_(list(tiles), [(0, 0, 1), (1, 0, 1)])
        bbox, grid, tiles = self.grid.get_affected_level_tiles((0,0,180,90), 2)
        eq_(grid, (2, 1))
        eq_(list(tiles), [(2, 0, 2), (3, 0, 2)])
        eq_(bbox, (0.0, 0.0, 180.0, 90.0))
        bbox, grid, tiles = self.grid.get_affected_level_tiles((0,-90,180,90), 2)
        eq_(grid, (2, 2))
        eq_(list(tiles), [(2, 0, 2), (3, 0, 2), (2, 1, 2), (3, 1, 2)])
        eq_(bbox, (0.0, -90.0, 180.0, 90.0))
开发者ID:deleted,项目名称:mapproxy,代码行数:52,代码来源:test_grid.py

示例4: TestWGS84TileGrid

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import get_affected_tiles [as 别名]
class TestWGS84TileGrid(object):
    def setup(self):
        self.grid = TileGrid(is_geodetic=True)

    def test_resolution(self):
        assert_almost_equal(self.grid.resolution(0), 1.40625)
        assert_almost_equal(self.grid.resolution(1), 1.40625/2)

    def test_bbox(self):
        eq_(self.grid.bbox, (-180.0, -90.0, 180.0, 90.0))

    def test_grid_size(self):
        eq_(self.grid.grid_sizes[0], (1, 1))
        eq_(self.grid.grid_sizes[1], (2, 1))
        eq_(self.grid.grid_sizes[2], (4, 2))

    def test_affected_tiles(self):
        bbox, grid, tiles = self.grid.get_affected_tiles((-180,-90,180,90), (512,256))
        eq_(bbox, (-180.0, -90.0, 180.0, 90.0))
        eq_(grid, (2, 1))
        eq_(list(tiles), [(0, 0, 1), (1, 0, 1)])

    def test_affected_level_tiles(self):
        bbox, grid, tiles = self.grid.get_affected_level_tiles((-180,-90,180,90), 1)
        eq_(grid, (2, 1))
        eq_(bbox, (-180.0, -90.0, 180.0, 90.0))
        eq_(list(tiles), [(0, 0, 1), (1, 0, 1)])
        bbox, grid, tiles = self.grid.get_affected_level_tiles((0,0,180,90), 2)
        eq_(grid, (2, 1))
        eq_(bbox, (0.0, 0.0, 180.0, 90.0))
        eq_(list(tiles), [(2, 1, 2), (3, 1, 2)])
开发者ID:deleted,项目名称:mapproxy,代码行数:33,代码来源:test_grid.py

示例5: test_affected_tiles_out_of_grid_bounds

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import get_affected_tiles [as 别名]
 def test_affected_tiles_out_of_grid_bounds(self):
     grid = TileGrid()
     #bbox from open layers
     req_bbox = (-30056262.509599999, -10018754.170400001, -20037508.339999996, -0.00080000050365924835)
     bbox, grid_size, tiles = \
         grid.get_affected_tiles(req_bbox, (256, 256))
     assert_almost_equal_bbox(bbox, req_bbox)
     eq_(grid_size, (1, 1))
     tiles = list(tiles)
     eq_(tiles, [None])
开发者ID:deleted,项目名称:mapproxy,代码行数:12,代码来源:test_grid.py

示例6: TestGeodeticTileGrid

# 需要导入模块: from mapproxy.grid import TileGrid [as 别名]
# 或者: from mapproxy.grid.TileGrid import get_affected_tiles [as 别名]
class TestGeodeticTileGrid(TileGridTest):
    def setup(self):
        self.grid = TileGrid(is_geodetic=True, )
    def test_auto_resolution(self):
        grid = TileGrid(is_geodetic=True, bbox=(-10, 30, 10, 40), tile_size=(20, 20))
        tile_bbox = grid.tile_bbox((0, 0, 0))
        assert tile_bbox == (-10, 30, 10, 50)
        assert grid.resolution(0) == 1.0

    def test_grid(self):
        for level, grid_size in [(0, (1, 1)), (1, (2, 1)), (2, (4, 2))]:
            yield self.check_grid, level, grid_size

    def test_adjacent_tile_bbox(self):
        grid = TileGrid(is_geodetic=True, bbox=(-10, 30, 10, 40), tile_size=(20, 20))
        t1 = grid.tile_bbox((0, 0, 2))
        t2 = grid.tile_bbox((1, 0, 2))
        t3 = grid.tile_bbox((0, 1, 2))
        assert t1[1] == t2[1]
        assert t1[3] == t2[3]
        assert t1[2] == t2[0]
        assert t1[0] == t3[0]
        assert t1[2] == t3[2]
        assert t1[3] == t3[1]

    def test_w_resolution(self):
        res = [1, 0.5, 0.2]
        grid = TileGrid(is_geodetic=True, bbox=(-10, 30, 10, 40), tile_size=(20, 20), res=res)
        assert grid.grid_sizes[0] == (1, 1)
        assert grid.grid_sizes[1] == (2, 1)
        assert grid.grid_sizes[2] == (5, 3)

    def test_tile(self):
        assert self.grid.tile(-180, -90, 0) == (0, 0, 0)
        assert self.grid.tile(-180, -90, 1) == (0, 0, 1)
        assert self.grid.tile(-180, -90, 2) == (0, 0, 2)
        assert self.grid.tile(180-0.001, 90-0.001, 0) == (0, 0, 0)
        assert self.grid.tile(10, 50, 1) == (1, 0, 1)

    def test_affected_tiles(self):
        bbox, grid_size, tiles = \
            self.grid.get_affected_tiles((-45,-45,45,45), (512,512))
        assert self.grid.grid_sizes[3] == (8, 4)
        assert bbox == (-45.0, -45.0, 45.0, 45.0)
        assert grid_size == (2, 2)
        tiles = list(tiles)
        assert tiles == [(3, 2, 3), (4, 2, 3), (3, 1, 3), (4, 1, 3)]
开发者ID:deleted,项目名称:mapproxy,代码行数:49,代码来源:test_grid.py


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