本文整理汇总了Python中tilecloud.BoundingPyramid.metatilecoords方法的典型用法代码示例。如果您正苦于以下问题:Python BoundingPyramid.metatilecoords方法的具体用法?Python BoundingPyramid.metatilecoords怎么用?Python BoundingPyramid.metatilecoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tilecloud.BoundingPyramid
的用法示例。
在下文中一共展示了BoundingPyramid.metatilecoords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_tilecoords
# 需要导入模块: from tilecloud import BoundingPyramid [as 别名]
# 或者: from tilecloud.BoundingPyramid import metatilecoords [as 别名]
def init_tilecoords(self, layer):
resolutions = layer['grid_ref']['resolutions']
if self.options.time is not None and self.options.zoom is None:
if 'min_resolution_seed' in layer: # pragma: no cover
self.options.zoom = [resolutions.index(
layer['min_resolution_seed']
)]
else:
self.options.zoom = [len(resolutions) - 1]
if self.options.zoom is not None:
zoom_max = len(resolutions) - 1
for zoom in self.options.zoom:
if zoom > zoom_max:
logger.warning(
"zoom %i is greater than the maximum zoom %i"
" of grid %s of layer %s, ignored." % (
zoom, zoom_max, layer['grid'], layer['name']
)
)
self.options.zoom = [z for z in self.options.zoom if z <= zoom_max]
if 'min_resolution_seed' in layer:
if self.options.zoom is None:
self.options.zoom = []
for z, resolution in enumerate(resolutions):
if resolution >= layer['min_resolution_seed']:
self.options.zoom.append(z)
else:
for zoom in self.options.zoom:
resolution = resolutions[zoom]
if resolution < layer['min_resolution_seed']:
logger.warning(
"zoom %i corresponds to resolution %s is smaller"
" than the 'min_resolution_seed' %s of layer %s, ignored." %
(
zoom, resolution, layer['min_resolution_seed'], layer['name']
)
)
self.options.zoom = [
z for z in self.options.zoom if
resolutions[z] >= layer['min_resolution_seed']
]
if self.options.zoom is None:
self.options.zoom = [z for z, r in enumerate(resolutions)]
# fill the bounding pyramid
tilegrid = layer['grid_ref']['obj']
bounding_pyramid = BoundingPyramid(tilegrid=tilegrid)
for zoom in self.options.zoom:
if zoom in self.geoms:
extent = self.geoms[zoom].bounds
if len(extent) == 0:
logger.warning("bounds empty for zoom {}".format(zoom))
else:
minx, miny, maxx, maxy = extent
px_buffer = layer['px_buffer']
m_buffer = px_buffer * resolutions[zoom]
minx -= m_buffer
miny -= m_buffer
maxx += m_buffer
maxy += m_buffer
bounding_pyramid.add(tilegrid.tilecoord(
zoom,
max(minx, tilegrid.max_extent[0]),
max(miny, tilegrid.max_extent[1]),
))
bounding_pyramid.add(tilegrid.tilecoord(
zoom,
min(maxx, tilegrid.max_extent[2]),
min(maxy, tilegrid.max_extent[3]),
))
if layer.get('meta', False):
self.set_tilecoords(bounding_pyramid.metatilecoords(layer['meta_size']), layer)
else:
self.set_tilecoords(bounding_pyramid, layer)
示例2: test_hash_metatile
# 需要导入模块: from tilecloud import BoundingPyramid [as 别名]
# 或者: from tilecloud.BoundingPyramid import metatilecoords [as 别名]
def test_hash_metatile(self):
bp = BoundingPyramid({4: (Bounds(0, 16), Bounds(0, 16))})
metatilecoords = list(bp.metatilecoords(2))
hashes = map(hash, metatilecoords)
self.assertEqual(len(metatilecoords), len(set(hashes)))