VectorLayer layer = configurationService.getVectorLayer(layerId);
RasterizingContainer rasterizeContainer = cacheManagerService.get(layer, CacheCategory.RASTER, key,
RasterizingContainer.class);
// if not in cache, try the rebuild cache and invoke the pipeline directly
if (rasterizeContainer == null) {
GetTileContainer tileContainer = new GetTileContainer();
PipelineContext context = pipelineService.createContext();
context.put(RasterizingPipelineCode.IMAGE_ID_KEY, key);
context.put(PipelineCode.LAYER_ID_KEY, layerId);
context.put(PipelineCode.LAYER_KEY, layer);
// get data from rebuild cache
RebuildCacheContainer rebuildCacheContainer = cacheManagerService.get(layer, CacheCategory.REBUILD, key,
RebuildCacheContainer.class);
if (null == rebuildCacheContainer) {
log.error("Data to rebuild the raster image is no longer available for key " + key);
response.sendError(HttpServletResponse.SC_NO_CONTENT);
return;
}
recorder.record(CacheCategory.REBUILD, "Got rebuild info from cache");
TileMetadata tileMetadata = rebuildCacheContainer.getMetadata();
context.put(PipelineCode.TILE_METADATA_KEY, tileMetadata);
Crs crs = geoService.getCrs2(tileMetadata.getCrs());
context.put(PipelineCode.CRS_KEY, crs);
CrsTransform layerToMap = geoService.getCrsTransform(layer.getCrs(), crs);
context.put(PipelineCode.CRS_TRANSFORM_KEY, layerToMap);
Envelope layerExtent = dtoConverterService.toInternal(layer.getLayerInfo().getMaxExtent());
Envelope tileExtent = geoService.transform(layerExtent, layerToMap);
context.put(PipelineCode.TILE_MAX_EXTENT_KEY, tileExtent);
// can't stop here, we have only prepared the context, not built the tile !
InternalTile tile = new InternalTileImpl(tileMetadata.getCode(), tileExtent, tileMetadata.getScale());
tileContainer.setTile(tile);
securityContextAdder.restoreSecurityContext(rebuildCacheContainer.getContext());
pipelineService.execute(RasterizingPipelineCode.PIPELINE_GET_VECTOR_TILE_RASTERIZING, layerId, context,
tileContainer);
rasterizeContainer = context.get(RasterizingPipelineCode.CONTAINER_KEY, RasterizingContainer.class);