private void encodeLayerSuperOverlay(Document container, int layerIndex, Envelope bounds,
int zoomLevel) {
Layer layer = mapContent.layers().get(layerIndex);
Folder folder = container.createAndAddFolder();
folder.setName(layer.getTitle());
LookAtOptions lookAtOptions = new LookAtOptions(request.getFormatOptions());
if (bounds != null) {
LookAtDecoratorFactory lookAtFactory = new LookAtDecoratorFactory();
ReferencedEnvelope layerBounds = layer.getBounds();
CoordinateReferenceSystem layerCRS = layerBounds.getCoordinateReferenceSystem();
if(layerCRS != null && !CRS.equalsIgnoreMetadata(layerCRS, DefaultGeographicCRS.WGS84)) {
try {
layerBounds = layerBounds.transform(DefaultGeographicCRS.WGS84, true);
} catch(Exception e) {
throw new ServiceException("Failed to transform the layer bounds for "
+ layer.getTitle() + " to WGS84", e);
}
}
LookAt la = lookAtFactory.buildLookAt(layerBounds, lookAtOptions, false);
folder.setAbstractView(la);
}
encodeNetworkLinks(folder, layer, bounds, zoomLevel);
}