Print Tile bounds.
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'])
    )
366709
def getWindowBounds(self):
        """"""

        fn = self.function_table.getWindowBounds
        pnX = c_int32()
        pnY = c_int32()
        pnWidth = c_uint32()
        pnHeight = c_uint32()
        fn(byref(pnX), byref(pnY), byref(pnWidth), byref(pnHeight))
        return pnX.value, pnY.value, pnWidth.value, pnHeight.value
1227093
private static Tile checkTile(MapTile map, ImageBuffer tileSprite, Integer sheet, int x, int y)
    {
        final int tw = map.getTileWidth();
        final int th = map.getTileHeight();
        final SpriteTiled tileSheet = map.getSheet(sheet);
        final ImageBuffer sheetImage = tileSheet.getSurface();
        final int tilesInX = tileSheet.getWidth() / tw;
        final int tilesInY = tileSheet.getHeight() / th;

        for (int surfaceCurrentTileY = 0; surfaceCurrentTileY < tilesInY; surfaceCurrentTileY++)
        {
            for (int surfaceCurrentTileX = 0; surfaceCurrentTileX < tilesInX; surfaceCurrentTileX++)
            {
                // Tile number on tile sheet
                final int number = surfaceCurrentTileX + surfaceCurrentTileY * tilesInX;

                // Compare tiles between sheet and image map
                final int xa = x * tw;
                final int ya = y * th;
                final int xb = surfaceCurrentTileX * tw;
                final int yb = surfaceCurrentTileY * th;

                if (TilesExtractor.compareTile(tw, th, tileSprite, xa, ya, sheetImage, xb, yb))
                {
                    return map.createTile(sheet, number, xa, (map.getInTileHeight() - 1.0 - y) * th);
                }
            }
        }
        return null;
    }
1103001
def _get_bounds(self):
        
        from fontTools.pens.boundsPen import BoundsPen
        pen = BoundsPen(self.layer)
        self.draw(pen)
        return pen.bounds
1214483
function (bounds) {
        bounds = this.adjustBounds(bounds);
        var mapRes = this.map.getResolution();
        var scale = Math.round((this.map.getScale() * 10000)) / 10000;
        var pX = Math.round(bounds.left / mapRes);
        var pY = -Math.round(bounds.top / mapRes);

        var metaX = Math.floor(pX / this.tileSize.w / this.params.metaTileSize.w) * this.tileSize.w * this.params.metaTileSize.w;
        var metaY = Math.floor(pY / this.tileSize.h / this.params.metaTileSize.h) * this.tileSize.h * this.params.metaTileSize.h;
    
        var components = [
            "/",
            this.params.map,
            "/",
            scale,
            "/",
            this.params.g.replace(/\s/g, '_'),
            "/def/t", 
            metaY,
            "/l",
            metaX,
            "/t",
            pY,
            "l",
            pX,
            ".",
            this.extension
          ];

        var url = this.url;

        if (OpenLayers.Util.isArray(url)) {
            url = this.selectUrl(components.join(''), url);
        }
        return url + components.join("");
    }
367921
public static BoundingBox getBoundingBox(int x, int y, int zoom) {

		int tilesPerSide = tilesPerSide(zoom);
		double tileWidthDegrees = tileWidthDegrees(tilesPerSide);
		double tileHeightDegrees = tileHeightDegrees(tilesPerSide);

		double minLon = -180.0 + (x * tileWidthDegrees);
		double maxLon = minLon + tileWidthDegrees;

		double maxLat = 90.0 - (y * tileHeightDegrees);
		double minLat = maxLat - tileHeightDegrees;

		BoundingBox box = new BoundingBox(minLon, minLat, maxLon, maxLat);

		return box;
	}
402835
public static void getTile (int width, int height, int tileWidth, int tileHeight, int tileIndex,
                                Rectangle bounds)
    {
        // figure out from whence to crop the tile
        int tilesPerRow = width / tileWidth;

        // if we got a bogus region, return bogus tile bounds
        if (tilesPerRow == 0) {
            bounds.setBounds(0, 0, width, height);

        } else {
            int row = tileIndex / tilesPerRow;
            int col = tileIndex % tilesPerRow;
            // crop the tile-sized image chunk from the full image
            bounds.setBounds(tileWidth*col, tileHeight*row, tileWidth, tileHeight);
        }
    }
733071
protected List<TileCode> calcCodesForBounds(Bbox bounds) {
		// Calculate tile width and height for tileLevel=currentTileLevel
		double div = Math.pow(2, currentTileLevel); // tile level must be correct!
		double scale = layer.getMapModel().getMapView().getCurrentScale();
		double tileWidth = Math.ceil((scale * layerBounds.getWidth()) / div) / scale;
		double tileHeight = Math.ceil((scale * layerBounds.getHeight()) / div) / scale;

		// For safety (to prevent division by 0):
		List<TileCode> codes = new ArrayList<TileCode>();
		if (tileWidth == 0 || tileHeight == 0) {
			return codes;
		}

		// Calculate bounds relative to extents:
		Bbox clippedBounds = bounds.intersection(layerBounds);
		if (clippedBounds == null) {
			Log.logError("Map bounds outside of layer extents, check the server configuration, it is incorrect.");
			return codes;
		}
		double relativeBoundX = Math.abs(clippedBounds.getX() - layerBounds.getX());
		double relativeBoundY = Math.abs(clippedBounds.getY() - layerBounds.getY());
		currentMinX = (int) Math.floor(relativeBoundX / tileWidth);
		currentMinY = (int) Math.floor(relativeBoundY / tileHeight);
		currentMaxX = (int) Math.ceil((relativeBoundX + clippedBounds.getWidth()) / tileWidth) - 1;
		currentMaxY = (int) Math.ceil((relativeBoundY + clippedBounds.getHeight()) / tileHeight) - 1;

		// Now fill the list with the correct codes:
		for (int x = currentMinX; x <= currentMaxX; x++) {
			for (int y = currentMinY; y <= currentMaxY; y++) {
				codes.add(new TileCode(currentTileLevel, x, y));
			}
		}
		return codes;
	}
143127
function(bounds) {
        this.events.triggerEvent("retile");

        //determine new tile bounds
        var center = bounds.getCenterLonLat();
        var tileWidth = bounds.getWidth() * this.ratio;
        var tileHeight = bounds.getHeight() * this.ratio;
                                       
        var tileBounds = 
            new OpenLayers.Bounds(center.lon - (tileWidth/2),
                                  center.lat - (tileHeight/2),
                                  center.lon + (tileWidth/2),
                                  center.lat + (tileHeight/2));
  
        var px = this.map.getLayerPxFromLonLat({
            lon: tileBounds.left,
            lat: tileBounds.top
        });

        if (!this.grid.length) {
            this.grid[0] = [];
        }

        var tile = this.grid[0][0];
        if (!tile) {
            tile = this.addTile(tileBounds, px);
            
            this.addTileMonitoringHooks(tile);
            tile.draw();
            this.grid[0][0] = tile;
        } else {
            tile.moveTo(tileBounds, px);
        }           
        
        //remove all but our single tile
        this.removeExcessTiles(1,1);

        // store the resolution of the grid
        this.gridResolution = this.getServerResolution();
    }
747748
function printBoard(floorMap, warriorStatus, offset) {
  if (offset > 0) {
    const floorMapRows = floorMap.length;
    print(ansiEscapes.cursorUp(offset + floorMapRows + warriorStatusRows));
  }

  printWarriorStatus(warriorStatus);
  printFloorMap(floorMap);

  if (offset > 0) {
    print(ansiEscapes.cursorDown(offset));
  }
}
1186598
def bounds(self, pixelbuffer=0):
        
        left = self._left
        bottom = self._bottom
        right = self._right
        top = self._top
        if pixelbuffer:
            offset = self.pixel_x_size * float(pixelbuffer)
            left -= offset
            bottom -= offset
            right += offset
            top += offset
        # on global grids clip at northern and southern TilePyramid bound
        if self.tp.grid.is_global:
            top = min([top, self.tile_pyramid.top])
            bottom = max([bottom, self.tile_pyramid.bottom])
        return Bounds(left, bottom, right, top)
33527
def bounds(self):
        """"""
        google_x, google_y = self.google
        pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE
        pixel_x_east, pixel_y_south = (google_x + 1) * TILE_SIZE, (google_y + 1) * TILE_SIZE

        point_min = Point.from_pixel(pixel_x=pixel_x_west, pixel_y=pixel_y_south, zoom=self.zoom)
        point_max = Point.from_pixel(pixel_x=pixel_x_east, pixel_y=pixel_y_north, zoom=self.zoom)
        return point_min, point_max
1233975
def updateRasterBounds(self):
        """"""
        yrange = self.viewRange()[1]
        yrange_size = yrange[1] - yrange[0]
        rmax = self.rasterTop*yrange_size + yrange[0]
        rmin = self.rasterBottom*yrange_size + yrange[0]
        self.rasterYslots = np.linspace(rmin, rmax, self.nreps)
        self.rasterBoundsUpdated.emit((self.rasterBottom, self.rasterTop), self.getTitle())
774389
def bounds(self) -> Tuple[float, float, float, float]:
        
        return self.shape.bounds
1024839
def tiles(ctx, bounds, zoom):
    """"""
    tiles = TilePyramid(
        ctx.obj['grid'],
        tile_size=ctx.obj['tile_size'],
        metatiling=ctx.obj['metatiling']
    ).tiles_from_bounds(bounds, zoom=zoom)
    if ctx.obj['output_format'] == 'Tile':
        for tile in tiles:
            click.echo('%s %s %s' % tile.id)
    elif ctx.obj['output_format'] == 'WKT':
        for tile in tiles:
            click.echo(tile.bbox(pixelbuffer=ctx.obj['pixelbuffer']))
    elif ctx.obj['output_format'] == 'GeoJSON':
        click.echo(
            '{\n'
            '  "type": "FeatureCollection",\n'
            '  "features": ['
        )
        # print tiles as they come and only add comma if there is a next tile
        try:
            tile = next(tiles)
            while True:
                gj = '    %s' % geojson.Feature(
                    geometry=tile.bbox(pixelbuffer=ctx.obj['pixelbuffer']),
                    properties=dict(
                        zoom=tile.zoom,
                        row=tile.row,
                        col=tile.col
                    )
                )
                try:
                    tile = next(tiles)
                    click.echo(gj + ',')
                except StopIteration:
                    click.echo(gj)
                    raise
        except StopIteration:
            pass
        click.echo(
            '  ]\n'
            '}'
        )
1239092
function(bounds) {
        this.events.triggerEvent("retile");

        // work out mininum number of rows and columns; this is the number of
        // tiles required to cover the viewport plus at least one for panning

        var viewSize = this.map.getSize();
        
        var origin = this.getTileOrigin();
        var resolution = this.map.getResolution(),
            serverResolution = this.getServerResolution(),
            ratio = resolution / serverResolution,
            tileSize = {
                w: this.tileSize.w / ratio,
                h: this.tileSize.h / ratio
            };

        var minRows = Math.ceil(viewSize.h/tileSize.h) + 
                      2 * this.buffer + 1;
        var minCols = Math.ceil(viewSize.w/tileSize.w) +
                      2 * this.buffer + 1;

        var tileLayout = this.calculateGridLayout(bounds, origin, serverResolution);
        this.gridLayout = tileLayout;
        
        var tilelon = tileLayout.tilelon;
        var tilelat = tileLayout.tilelat;
        
        var layerContainerDivLeft = this.map.layerContainerOriginPx.x;
        var layerContainerDivTop = this.map.layerContainerOriginPx.y;

        var tileBounds = this.getTileBoundsForGridIndex(0, 0);
        var startPx = this.map.getViewPortPxFromLonLat(
            new OpenLayers.LonLat(tileBounds.left, tileBounds.top)
        );
        startPx.x = Math.round(startPx.x) - layerContainerDivLeft;
        startPx.y = Math.round(startPx.y) - layerContainerDivTop;

        var tileData = [], center = this.map.getCenter();

        var rowidx = 0;
        do {
            var row = this.grid[rowidx];
            if (!row) {
                row = [];
                this.grid.push(row);
            }
            
            var colidx = 0;
            do {
                tileBounds = this.getTileBoundsForGridIndex(rowidx, colidx);
                var px = startPx.clone();
                px.x = px.x + colidx * Math.round(tileSize.w);
                px.y = px.y + rowidx * Math.round(tileSize.h);
                var tile = row[colidx];
                if (!tile) {
                    tile = this.addTile(tileBounds, px);
                    this.addTileMonitoringHooks(tile);
                    row.push(tile);
                } else {
                    tile.moveTo(tileBounds, px, false);
                }
                var tileCenter = tileBounds.getCenterLonLat();
                tileData.push({
                    tile: tile,
                    distance: Math.pow(tileCenter.lon - center.lon, 2) +
                        Math.pow(tileCenter.lat - center.lat, 2)
                });
     
                colidx += 1;
            } while ((tileBounds.right <= bounds.right + tilelon * this.buffer)
                     || colidx < minCols);
             
            rowidx += 1;
        } while((tileBounds.bottom >= bounds.bottom - tilelat * this.buffer)
                || rowidx < minRows);
        
        //shave off exceess rows and colums
        this.removeExcessTiles(rowidx, colidx);

        var resolution = this.getServerResolution();
        // store the resolution of the grid
        this.gridResolution = resolution;

        //now actually draw the tiles
        tileData.sort(function(a, b) {
            return a.distance - b.distance; 
        });
        for (var i=0, ii=tileData.length; i<ii; ++i) {
            tileData[i].tile.draw();
        }
    }
107942
function (bounds) {
        bounds = this.adjustBounds(bounds);
        var res = this.getServerResolution();
        var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
        var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
        var z = this.getServerZoom();
        var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; 
        var url = this.url;
        if (OpenLayers.Util.isArray(url)) {
            url = this.selectUrl(path, url);
        }
        return url + path;
    }