Return a tuple of tile height and width.

        - pixelbuffer: tile buffer in pixels
14681
def shape(self, pixelbuffer=0):
        
        # apply pixelbuffers
        height = self._base_shape.height + 2 * pixelbuffer
        width = self._base_shape.width + 2 * pixelbuffer
        if pixelbuffer and self.tp.grid.is_global:
            # on first and last row, remove pixelbuffer on top or bottom
            matrix_height = self.tile_pyramid.matrix_height(self.zoom)
            if matrix_height == 1:
                height = self._base_shape.height
            elif self.row in [0, matrix_height - 1]:
                height = self._base_shape.height + pixelbuffer
        return Shape(height=height, width=width)
1265803
def tileBounds(self, zoom, tileCol, tileRow):
        ""
        assert zoom in range(0, len(self.RESOLUTIONS))

        # 0,0 at top left: y axis down and x axis right
        tileSize = self.tileSize(zoom)
        minX = self.MINX + tileCol * tileSize
        maxX = self.MINX + (tileCol + 1) * tileSize
        if self.originCorner == 'bottom-left':
            minY = self.MINY + tileRow * tileSize
            maxY = self.MINY + (tileRow + 1) * tileSize
        elif self.originCorner == 'top-left':
            minY = self.MAXY - (tileRow + 1) * tileSize
            maxY = self.MAXY - tileRow * tileSize
        return [minX, minY, maxX, maxY]
1285593
def get_tile_dims(tile_dims, imshape):
    

    if tile_dims is None:
        td = None
    else:
        td = numpy.array(tile_dims, dtype='i8')
        nd = len(imshape)
        if td.size != nd:
            msg = "expected tile_dims to have %d dims, got %d" % (td.size, nd)
            raise ValueError(msg)

    return td
641205
def _tile_image(self, data):
        
        image = Image.open(BytesIO(data))
        return image.convert('RGBA')
564174
public static int getDpFromPixel(Context context, int pixel) {
		float scale = context.getResources().getDisplayMetrics().density; // get display density

		return (int)(pixel / scale);
	}
1314141
def pick_tile_size(self, seg_size, data_lengths, valid_chunks, valid_lengths):
        

        if len(valid_lengths) == 1:
            return data_lengths[0], valid_chunks[0], valid_lengths[0]
        else:
            # Pick the tile size that is closest to 1/3 of the science segment
            target_size = seg_size / 3
            pick, pick_diff = 0, abs(valid_lengths[0] - target_size)
            for i, size in enumerate(valid_lengths):
                if abs(size - target_size) < pick_diff:
                    pick, pick_diff  = i, abs(size - target_size)
            return data_lengths[pick], valid_chunks[pick], valid_lengths[pick]
887620
public static int pixelYToTileY(double pixelY, byte zoomLevel, int tileSize) {
        return (int) Math.min(Math.max(pixelY / tileSize, 0), Math.pow(2, zoomLevel) - 1);
    }
182958
def tile(self, username, style_id, z, x, y, tile_size=512, retina=False):
        ""
        if tile_size not in (256, 512):
            raise errors.ImageSizeError('tile_size must be 256 or 512 pixels')

        pth = '/{username}/{style_id}/tiles/{tile_size}/{z}/{x}/{y}'

        values = dict(username=username, style_id=style_id,
                      tile_size=tile_size, z=z, x=x, y=y)

        uri = URITemplate(self.baseuri + pth).expand(**values)
        if retina:
            uri += '@2x'
        res = self.session.get(uri)
        self.handle_http_error(res)
        return res
712082
def get_size(self):
        """"""
        attr = self._get_console_info()
        cols = attr['window']['right'] - attr['window']['left'] + 1
        lines = attr['window']['bottom'] - attr['window']['top'] + 1
        return cols, lines
546483
def getBuffer(x):
    
    b = bytes(x)
    return (c_ubyte * len(b)).from_buffer_copy(bytes(x))
1067645
public static int[] metersToTile( double mx, double my, int zoom, int tileSize ) {
        int[] p = metersToPixels(mx, my, zoom, tileSize);
        return pixelsToTile(p[0], p[1], tileSize);
    }
217441
async def tile(tile_number):
    
    try:
        tile = get_tile(tile_number)
    except TileOutOfBoundsError:
        abort(404)

    buf = BytesIO(tile.tobytes())
    tile.save(buf, 'JPEG')

    content = buf.getvalue()
    response = await make_response(content)
    response.headers['Content-Type'] = 'image/jpg'
    response.headers['Accept-Ranges'] = 'bytes'
    response.headers['Content-Length'] = str(len(content))
    return response
50284
def calc_buffered_bounds(
        format, bounds, meters_per_pixel_dim, layer_name, geometry_type,
        buffer_cfg):
    

    if not buffer_cfg:
        return bounds

    format_buffer_cfg = buffer_cfg.get(format.extension)
    if format_buffer_cfg is None:
        return bounds

    geometry_type = normalize_geometry_type(geometry_type)

    per_layer_cfg = format_buffer_cfg.get('layer', {}).get(layer_name)
    if per_layer_cfg is not None:
        layer_geom_pixels = per_layer_cfg.get(geometry_type)
        if layer_geom_pixels is not None:
            assert isinstance(layer_geom_pixels, Number)
            result = bounds_buffer(
                bounds, meters_per_pixel_dim * layer_geom_pixels)
            return result

    by_geometry_pixels = format_buffer_cfg.get('geometry', {}).get(
        geometry_type)
    if by_geometry_pixels is not None:
        assert isinstance(by_geometry_pixels, Number)
        result = bounds_buffer(
            bounds, meters_per_pixel_dim * by_geometry_pixels)
        return result

    return bounds
1097381
def _tiles_from_cleaned_bounds(tp, bounds, zoom):
    """"""
    lb = _tile_from_xy(tp, bounds.left, bounds.bottom, zoom, on_edge_use="rt")
    rt = _tile_from_xy(tp, bounds.right, bounds.top, zoom, on_edge_use="lb")
    for tile_id in product([zoom], range(rt.row, lb.row + 1), range(lb.col, rt.col + 1)):
        yield tp.tile(*tile_id)
277391
public int[] PixelsToTile( int px, int py ) {
        int tx = (int) Math.ceil(px / ((double) tileSize) - 1);
        int ty = (int) Math.ceil(py / ((double) tileSize) - 1);
        return new int[]{tx, ty};
    }
1159329
def pixel_to_size_ratio(self):
        
        left, right, _, _ = self.get_view_coordinates()
        width = right - left
        display_width = self.get_allocation().width
        return display_width / float(width)
423471
def bounds(ctx, tile):
    """"""
    click.echo(
        '%s %s %s %s' % TilePyramid(
            ctx.obj['grid'],
            tile_size=ctx.obj['tile_size'],
            metatiling=ctx.obj['metatiling']
        ).tile(*tile).bounds(pixelbuffer=ctx.obj['pixelbuffer'])
    )