Get the Projected tile bounding box from the Google Maps API tile grid
and zoom level

@param projection
projection
@param tileGrid
tile grid
@param zoom
zoom level
@return bounding box
977483
public static BoundingBox getProjectedBoundingBox(Projection projection,
			TileGrid tileGrid, int zoom) {

		BoundingBox boundingBox = getWebMercatorBoundingBox(tileGrid, zoom);

		if (projection != null) {
			ProjectionTransform transform = webMercator
					.getTransformation(projection);
			boundingBox = boundingBox.transform(transform);
		}

		return boundingBox;
	}
371300
public static Long getZoomLevel(double[] widths, double[] heights,
			List<TileMatrix> tileMatrices, double length) {
		return getZoomLevel(widths, heights, tileMatrices, length, true);
	}
45302
public BoundingBox getBoundingBox(Projection projection, String table) {

		BoundingBox boundingBox = null;

		try {
			Contents contents = queryForId(table);
			boundingBox = contents.getBoundingBox(projection);
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to query for contents of table: " + table, e);
		}

		return boundingBox;
	}
295298
def grid_tiles(self, bbox, zoomlevel):
        
        tiles = self.tileslist(bbox, [zoomlevel])
        grid = {}
        for (z, x, y) in tiles:
            if not grid.get(y):
                grid[y] = []
            grid[y].append(x)
        sortedgrid = []
        for y in sorted(grid.keys(), reverse=self.tile_scheme == 'tms'):
            sortedgrid.append([(x, y) for x in sorted(grid[y])])
        return sortedgrid
425126
function zoomed () {
    // Get the height and width
    height = el.clientHeight
    width = el.clientWidth

    // Set the map tile size
    tile.size([width, height])

    // Get the current display bounds
    var bounds = display.llBounds()

    // Project the bounds based on the current projection
    var psw = projection(bounds[0])
    var pne = projection(bounds[1])

    // Based the new scale and translation vector off the current one
    var scale = projection.scale() * 2 * Math.PI
    var translate = projection.translate()

    var dx = pne[0] - psw[0]
    var dy = pne[1] - psw[1]

    scale = scale * (1 / Math.max(dx / width, dy / height))
    projection
      .translate([width / 2, height / 2])
      .scale(scale / 2 / Math.PI)

    // Reproject the bounds based on the new scale and translation vector
    psw = projection(bounds[0])
    pne = projection(bounds[1])
    var x = (psw[0] + pne[0]) / 2
    var y = (psw[1] + pne[1]) / 2
    translate = [width - x, height - y]

    // Update the Geo tiles
    tile
      .scale(scale)
      .translate(translate)

    // Get the new set of tiles and render
    renderTiles(tile())
  }
918113
public TileResultSet queryForTilesInRow(long row, long zoomLevel) {

		Map<String, Object> fieldValues = new HashMap<String, Object>();
		fieldValues.put(TileTable.COLUMN_TILE_ROW, row);
		fieldValues.put(TileTable.COLUMN_ZOOM_LEVEL, zoomLevel);

		return queryForFieldValues(fieldValues);
	}
648567
public static BoundingBox boundDegreesBoundingBoxWithWebMercatorLimits(
			BoundingBox boundingBox) {
		BoundingBox bounded = new BoundingBox(boundingBox);
		if (bounded.getMinLatitude() < ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE) {
			bounded.setMinLatitude(ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE);
		}
		if (bounded.getMaxLatitude() < ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE) {
			bounded.setMaxLatitude(ProjectionConstants.WEB_MERCATOR_MIN_LAT_RANGE);
		}
		if (bounded.getMaxLatitude() > ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE) {
			bounded.setMaxLatitude(ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE);
		}
		if (bounded.getMinLatitude() > ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE) {
			bounded.setMinLatitude(ProjectionConstants.WEB_MERCATOR_MAX_LAT_RANGE);
		}
		return bounded;
	}
477969
public List<TileCoordinate> translateToZoomLevel(byte zoomlevelNew) {
        List<TileCoordinate> tiles = null;
        int zoomlevelDistance = zoomlevelNew - this.zoomlevel;

        int factor = (int) Math.pow(2, Math.abs(zoomlevelDistance));
        if (zoomlevelDistance > 0) {
            tiles = new ArrayList<>((int) Math.pow(4, Math.abs(zoomlevelDistance)));
            int tileUpperLeftX = this.x * factor;
            int tileUpperLeftY = this.y * factor;
            for (int i = 0; i < factor; i++) {
                for (int j = 0; j < factor; j++) {
                    tiles.add(new TileCoordinate(tileUpperLeftX + j, tileUpperLeftY + i, zoomlevelNew));
                }
            }
        } else {
            tiles = new ArrayList<>(1);
            tiles.add(new TileCoordinate(this.x / factor, this.y / factor, zoomlevelNew));
        }
        return tiles;
    }
761820
public static long getTileColumn(BoundingBox totalBox, long matrixWidth,
			double longitude) {

		double minX = totalBox.getMinLongitude();
		double maxX = totalBox.getMaxLongitude();

		long tileId;
		if (longitude < minX) {
			tileId = -1;
		} else if (longitude >= maxX) {
			tileId = matrixWidth;
		} else {
			double matrixWidthMeters = totalBox.getMaxLongitude()
					- totalBox.getMinLongitude();
			double tileWidth = matrixWidthMeters / matrixWidth;
			tileId = (long) ((longitude - minX) / tileWidth);
		}

		return tileId;
	}
557213
public long tileFeatureCount(LatLng latLng, int zoom) {
        Point point = new Point(latLng.longitude, latLng.latitude);
        long tileFeaturesCount = tileFeatureCount(point, zoom);
        return tileFeaturesCount;
    }
1061554
public BoundingBox overlap(BoundingBox projectedCoverage) {
		BoundingBox overlap = null;
		if (point) {
			overlap = projectedBoundingBox;
		} else {
			overlap = projectedBoundingBox.overlap(projectedCoverage);
		}
		return overlap;
	}
96080
public BoundingBox boundingBoxFromWebMercator(BoundingBox boundingBox) {
        if (projection == null) {
            throw new GeoPackageException("Shape Converter projection is null");
        }
        return boundingBox.transform(fromWebMercator);
    }
1173484
public static Rect getTilesRect(final BoundingBox pBB,
                                    final int pZoomLevel){
        final int mapTileUpperBound = 1 << pZoomLevel;
        final int right = MapView.getTileSystem().getTileXFromLongitude(pBB.getLonEast(), pZoomLevel);
        final int bottom = MapView.getTileSystem().getTileYFromLatitude(pBB.getLatSouth(), pZoomLevel);
        final int left = MapView.getTileSystem().getTileXFromLongitude(pBB.getLonWest(), pZoomLevel);
        final int top = MapView.getTileSystem().getTileYFromLatitude(pBB.getLatNorth(), pZoomLevel);
        int width = right - left + 1; // handling the modulo
        if (width <= 0) {
            width += mapTileUpperBound;
        }
        int height = bottom - top + 1; // handling the modulo
        if (height <= 0) {
            height += mapTileUpperBound;
        }
        return new Rect(left, top, left + width - 1, top + height - 1);
    }
480533
public BoundingBox transform(ProjectionTransform transform) {
		BoundingBox transformed = this;
		if (transform.isSameProjection()) {
			transformed = new BoundingBox(transformed);
		} else {
			if (transform.getFromProjection().isUnit(Units.DEGREES)) {
				transformed = TileBoundingBoxUtils
						.boundDegreesBoundingBoxWithWebMercatorLimits(transformed);
			}
			GeometryEnvelope envelope = buildEnvelope(transformed);
			GeometryEnvelope transformedEnvelope = transform
					.transform(envelope);
			transformed = new BoundingBox(transformedEnvelope);
		}
		return transformed;
	}
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)
838936
public int[] GoogleTile( double lat, double lon, int zoom ) {
        double[] meters = LatLonToMeters(lat, lon);
        int[] tile = MetersToTile(meters[0], meters[1], zoom);
        return this.GoogleTile(tile[0], tile[1], zoom);
    }
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]