metaTileMap);
mapEncoder = (RenderedImageMapResponse) responseEncoder;
}
RenderedImage tile = metaTileMap.getImage();
WMSMapContent tileContext = metaTileMap.getMapContext();
if (this.tiles.length > 1 || (this.tiles.length == 1 && metaHasGutter())) {
final Rectangle tileDim = this.tiles[tileIdx];
tile = createTile(tileDim.x, tileDim.y, tileDim.width, tileDim.height);
disposeLater(tile);
{
final WMSMapContent metaTileContext = metaTileMap.getMapContext();
// do not create tileContext with metaTileContext.getLayers() as the layer list.
// It is not needed at this stage and the constructor would force a
// MapLayer.getBounds() that might fail
tileContext = new WMSMapContent();
tileContext.setRequest(metaTileContext.getRequest());
tileContext.setBgColor(metaTileContext.getBgColor());
tileContext.setMapWidth(tileDim.width);
tileContext.setMapHeight(tileDim.height);
tileContext.setPalette(metaTileContext.getPalette());
tileContext.setTransparent(tileContext.isTransparent());
long[][] tileIndexes = getTilesGridPositions();
BoundingBox tileBounds = gridSubset.boundsFromIndex(tileIndexes[tileIdx]);
ReferencedEnvelope tilebbox = new ReferencedEnvelope(
metaTileContext.getCoordinateReferenceSystem());
tilebbox.init(tileBounds.getMinX(), tileBounds.getMaxX(), tileBounds.getMinY(),
tileBounds.getMaxY());
tileContext.getViewport().setBounds(tilebbox);
}
}