Package mapproxy :: Package core :: Module grid :: Class MetaGrid
[hide private]
[frames] | no frames]

Class MetaGrid

source code

object --+
         |
        MetaGrid

This class contains methods to calculate bbox, etc. of metatiles.
Instance Methods [hide private]
 
__init__(self, grid, meta_size, meta_buffer=0)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
meta_bbox(self, tile_coord)
Returns the bbox of the metatile that contains tile_coord.
source code
 
tiles(self, tile_coord)
Returns all tiles that belong to the same metatile as tile_coord.
source code
 
tile_size(self, level)
Returns the size of a metatile (includes meta_buffer if present).
source code
 
meta_size(self, level) source code
bbox, (xs, yz), [(x, y, z), ...]
get_affected_level_tiles(self, bbox, level)
Get a list with all affected tiles for a bbox in the given level.
source code
 
_tile_iter(self, x0, y0, x1, y1, level, inverse=False) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, grid, meta_size, meta_buffer=0)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Parameters:
  • grid - the grid to use for the metatiles
  • meta_size ((x_size, y_size)) - the number of tiles a metatile consist
  • meta_buffer (pixel) - the buffer size in pixel that is added to each metatile. the number is added to all four borders. this buffer may improve the handling of lables overlapping (meta)tile borders.
Overrides: object.__init__
(inherited documentation)

meta_bbox(self, tile_coord)

source code 

Returns the bbox of the metatile that contains tile_coord.

>>> mgrid = MetaGrid(grid=TileGrid(), meta_size=(2, 2))
>>> [round(x, 2) for x in mgrid.meta_bbox((0, 0, 2))]
[-20037508.34, -20037508.34, 0.0, 0.0]
>>> mgrid = MetaGrid(grid=TileGrid(), meta_size=(2, 2))
>>> [round(x, 2) for x in mgrid.meta_bbox((0, 0, 0))]
[-20037508.34, -20037508.34, 20037508.34, 20037508.34]
Parameters:
  • tile_coord ((x, y, z))

tiles(self, tile_coord)

source code 

Returns all tiles that belong to the same metatile as tile_coord. The result contains for each tile the tile_coord and the upper-left pixel coordinate of the tile in the meta tile image.

>>> mgrid = MetaGrid(grid=TileGrid(), meta_size=(2, 2))
>>> tiles = list(mgrid.tiles((0, 1, 1)))
>>> tiles[0], tiles[-1]
(((0, 1, 1), (0, 0)), ((1, 0, 1), (256, 256)))
>>> list(mgrid.tiles((0, 0, 0)))
[((0, 0, 0), (0, 0))]

tile_size(self, level)

source code 

Returns the size of a metatile (includes meta_buffer if present).

>>> mgrid = MetaGrid(grid=TileGrid(), meta_size=(2, 2), meta_buffer=10)
>>> mgrid.tile_size(2)
(532, 532)
>>> mgrid.tile_size(0)
(256, 256)
Parameters:
  • level - the zoom level

get_affected_level_tiles(self, bbox, level)

source code 

Get a list with all affected tiles for a bbox in the given level.

>>> grid = MetaGrid(TileGrid(), (2, 2))
>>> bbox = (-20037508.34, -20037508.34, 20037508.34, 20037508.34)
>>> grid.get_affected_level_tiles(bbox, 0)
... #doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
((-20037508.342789244, -20037508.342789244,          20037508.342789244, 20037508.342789244), (1, 1),          <generator object ...>)
Returns: bbox, (xs, yz), [(x, y, z), ...]
the bbox, the size and a list with tile coordinates, sorted row-wise