## Batch Upload Operations

### Uploading Multiple Layers

Q2G can upload multiple layers in a single operation:

1. Select multiple layers by checking their checkboxes
2. Configure upload options
3. Click "Upload Layers"
4. Monitor progress in the upload log

### Batch Upload Optimization

- Sequential Processing: Layers are uploaded one at a time
- Error Handling: Failure of one layer doesn't stop others
- Progress Tracking: See which layer is being processed
- Summary Report: Final report shows success/failure counts

### Best Practices for Batch Upload

- Start with 5-10 layers to test
- Ensure all layers have valid CRS
- Check layer names don't conflict
- Monitor the upload log for errors
- Verify results before uploading more

## PostGIS Integration

### Working with PostGIS Layers

Q2G has special support for PostGIS layers:

- Automatic datastore creation
- Direct layer registration
- Credential management
- Q2G connection pooling

### Uploading PostGIS Layers

1. Load a PostGIS layer in QGIS
2. Select the layer in Q2G
3. Click "Upload Layers"
4. The plugin will:
   - Detect it's a PostGIS layer
   - Create or use existing datastore
   - Register the layer in GeoServer
   - Publish the layer

### PostGIS Credentials

Manage PostGIS credentials:

- Credentials are stored locally in `postgis.ini`
- Credentials are saved for future use
- You can update credentials in the PostGIS dialog
- Credentials are never sent to GeoServer

### Advanced PostGIS Features

- Q2G Connection Pooling: Reuse database connections
- SSL Connections: Secure database connections
- Schema Support: Upload layers from specific schemas
- View Support: Register database views as layers

## GeoPackage Support

### Working with GeoPackages

GeoPackages are modern, efficient containers for geospatial data:

- Single file format (no .shx, .dbf files needed)
- Support for multiple layers
- Built-in compression
- Better performance than Shapefiles

### Uploading GeoPackage Layers

1. Load a GeoPackage layer in QGIS
2. Select the layer in Q2G
3. Click "Upload Layers"
4. The plugin will:
   - Detect the GeoPackage source
   - Create a GeoPackage datastore
   - Register the specific layer
   - Publish the layer

### Multi-Layer GeoPackages

If your GeoPackage contains multiple layers:

- Load each layer individually in QGIS
- Select all layers in Q2G
- Upload them together
- They will be registered in the same datastore

## Raster Data Handling

### Uploading Raster Layers

Q2G supports various raster formats:

- GeoTIFF (most common)
- JPEG2000
- PNG with georeferencing
- Other georeferenced formats

### Raster Upload Process

1. Load a raster layer in QGIS
2. Ensure the layer has valid georeferencing
3. Select the layer in Q2G
4. Click "Upload Layers"
5. The plugin will:
   - Create a coverage store
   - Upload the raster file
   - Publish the coverage
   - Upload and apply styles

### Raster Style Management

Raster layers can have SLD styles applied:

- Color maps for single-band rasters
- RGB rendering for multi-band rasters
- Transparency settings
- Contrast enhancement

## Advanced Style Management

### Custom SLD Editing

For advanced users, edit SLD directly:

1. View the layer's SLD using the "..." button
2. Copy the SLD code
3. Edit it in a text editor
4. Upload the modified SLD

### SLD Best Practices

- Use standard OGC SLD syntax
- Test styles in a development environment first
- Keep styles simple for better performance
- Document complex styles
- Version your styles

### Style Sharing

Share styles between layers:

- Export a style from one layer
- Upload it with a different name
- Associate it with other layers
- Update all layers at once by updating the shared style

### Conditional Styling

Use rule-based styling for complex conditions:

- Different colors based on attribute values
- Different symbols based on geometry type
- Scale-dependent rendering
- Complex filter expressions

## Workspace Organization

### Multi-Project Setup

Organize multiple projects on a single GeoServer:

- Create separate workspaces for each project
- Use consistent naming conventions
- Document workspace purposes
- Manage access by workspace

### Datastore Management

Optimize datastore usage:

- Group related layers in datastores
- Use meaningful datastore names
- Monitor datastore performance
- Archive old datastores

### Workspace Backup and Recovery

Protect your data:

- Regular backups of GeoServer data
- Export workspace configurations
- Document layer sources
- Keep version history

## Performance Optimization

### Upload Optimization

- File Compression: Use GeoPackage or compressed formats
- Batch Size: Upload 5-10 layers at a time
- Network: Use wired connection for large uploads
- Timing: Upload during off-peak hours

### GeoServer Performance

- Monitor GeoServer memory usage
- Optimize database connections
- Use indexes on frequently queried columns
- Archive old layers

### Style Performance

- Keep styles simple
- Avoid complex filters
- Use appropriate zoom levels
- Cache rendered tiles

## Reset All Caches (GeoWebCache)

### What is GeoWebCache?

GeoWebCache (GWC) is a tile caching system integrated with GeoServer. It pre-renders map tiles and stores them for faster delivery. When you request a WMS layer, GeoServer can serve cached tiles instead of rendering them on-the-fly, significantly improving performance.

### When to Reset Caches

You should reset the tile cache when:

- Style Changes: After updating a layer's SLD style, cached tiles still show the old styling
- Data Updates: When underlying data has changed but tiles show old data
- Color Issues: When map colors don't match your expected styling
- Testing: During development when you need to see immediate changes

### How to Reset All Caches

In Q2G, use the "Reset All Caches" button in the Others section:

1. Ensure you have valid GeoServer connection credentials
2. Click the "Others" section to expand it
3. Click the "Reset All Caches" button
4. Confirm the action when prompted
5. Wait for the success message
6. Refresh your browser/application to see updated tiles

Warning: This action deletes ALL cached tiles for every layer on the GeoServer. This cannot be undone. Tiles will be re-rendered on the next WMS request, which may temporarily increase server load.

### Technical Details

The Reset All Caches function calls the GeoWebCache REST API:

- Endpoint: `{geoserver_url}/gwc/rest/masstruncate`
- Method: POST
- Payload: `<truncateAll></truncateAll>`
- Content-Type: text/xml

### Alternative: Reset Specific Layer Cache

If you only need to reset cache for a specific layer, you can do this directly in GeoServer:

1. Open GeoServer Admin Console
2. Go to Tile Caching → Tile Layers
3. Find the layer you want to reset
4. Click on the layer name
5. Click "Truncate" or "Seed/Truncate"
6. Select truncate options and execute

### Best Practices

- Only reset caches when necessary to avoid unnecessary server load
- Consider resetting during off-peak hours for production servers
- After resetting, allow time for tiles to regenerate before heavy usage
- For frequent style changes during development, consider disabling caching temporarily

## Troubleshooting Advanced Issues

### Complex Upload Failures

- Check GeoServer logs for detailed errors
- Verify layer properties and CRS
- Test with simpler layers first
- Check available disk space

### Performance Issues

- Monitor GeoServer resource usage
- Optimize database queries
- Use caching strategies
- Consider load balancing

## Next Steps

- FAQ - Check frequently asked questions
- Troubleshooting - Solve specific issues
- Layer Upload - Apply advanced techniques

↑