// see if we can merge this layer with the previous one
boolean merged = false;
if (mapContent.layers().size() > 0) {
org.geotools.map.Layer lastLayer = mapContent.layers().get(mapContent.layers().size() - 1);
if (lastLayer instanceof WMSLayer) {
WMSLayer lastWMS = (WMSLayer) lastLayer;
WebMapServer otherWMS = lastWMS.getWebMapServer();
if (otherWMS.equals(wms)) {
lastWMS.addLayer(gt2Layer);
merged = true;
}
}
}
if (!merged) {
WMSLayer Layer = new WMSLayer(wms, gt2Layer);
Layer.setTitle(wmsLayer.prefixedName());
mapContent.addLayer(Layer);
}
} else {
throw new IllegalArgumentException("Unkown layer type " + layerType);
}