throw new ServiceException(new StringBuffer(
"Internal error : unable to get reader for this coverage layer ")
.append(mapLayerInfo.toString()).toString());
}
} else if (layerType == MapLayerInfo.TYPE_WMS) {
WMSLayerInfo wmsLayer = (WMSLayerInfo) mapLayerInfo.getResource();
WebMapServer wms = wmsLayer.getStore().getWebMapServer(null);
Layer gt2Layer = wmsLayer.getWMSLayer(null);
// see if we can merge this layer with the previous one
boolean merged = false;
if (mapContext.getLayerCount() > 0) {
MapLayer lastLayer = mapContext.getLayer(mapContext.getLayerCount() - 1);
if (lastLayer instanceof WMSMapLayer) {
WMSMapLayer lastWMS = (WMSMapLayer) lastLayer;
WebMapServer otherWMS = lastWMS.getWebMapServer();
if (otherWMS.equals(wms)) {
lastWMS.addLayer(gt2Layer);
merged = true;
}
}
}
if (!merged) {
WMSMapLayer mapLayer = new WMSMapLayer(wms, gt2Layer);
mapLayer.setTitle(wmsLayer.getPrefixedName());
mapContext.addLayer(mapLayer);
}
} else {
throw new IllegalArgumentException("Unkown layer type " + layerType);
}