code: public static TileGrid getTileGrid(BoundingBox totalBox, long matrixWidth,
  			long matrixHeight, BoundingBox boundingBox) {
  
  		long minColumn = getTileColumn(totalBox, matrixWidth,
  				boundingBox.getMinLongitude());
  		long maxColumn = getTileColumn(totalBox, matrixWidth,
  				boundingBox.getMaxLongitude());
  
  		if (minColumn < matrixWidth && maxColumn >= 0) {
  			if (minColumn < 0) {
  				minColumn = 0;
  			}
  			if (maxColumn >= matrixWidth) {
  				maxColumn = matrixWidth - 1;
  			}
  		}
  
  		long maxRow = getTileRow(totalBox, matrixHeight,
  				boundingBox.getMinLatitude());
  		long minRow = getTileRow(totalBox, matrixHeight,
  				boundingBox.getMaxLatitude());
  
  		if (minRow < matrixHeight && maxRow >= 0) {
  			if (minRow < 0) {
  				minRow = 0;
  			}
  			if (maxRow >= matrixHeight) {
  				maxRow = matrixHeight - 1;
  			}
  		}
  
  		TileGrid tileGrid = new TileGrid(minColumn, minRow, maxColumn, maxRow);
  
  		return tileGrid;
  	}
docs: Get the tile grid
  
  @param totalBox
  total bounding box
  @param matrixWidth
  matrix width
  @param matrixHeight
  matrix height
  @param boundingBox
  bounding box
  @return tile grid