code: 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;
  	}
docs: Saves the complete array of TileCode objects for the given bounds (and the current scale).
  
  @param bounds
  view bounds
  @return list of tiles in these bounds