};
}
LayerInfo createLayer(String groupName, EoCoverageSelection selection, CatalogBuilder builder) {
String coverageName = selection.getCoverageName();
EoLayerType layerType = selection.getType();
String name = coverageName;
if(groupName != null) {
name = groupName + "_" + name;
}
try {
// build the coverage and enable its dimensions
CoverageInfo resource = builder.buildCoverage(coverageName);
boolean dimensionsPresent = enableDimensions(resource, layerType);
if (!dimensionsPresent) {
if(layerType == EoLayerType.BAND_COVERAGE) {
error(new ParamResourceModel("EoLayerGroupError.invalidBandCoverage", null, coverageName).getString());
} else {
error(new ParamResourceModel("EoLayerGroupError.invalidLayer", null, coverageName).getString());
}
return null;
}
// update the name and save the coverage
resource.setName(name);
resource.setTitle(name);
getCatalog().add(resource);
// save the layer too
LayerInfo layer = builder.buildLayer(resource);
layer.setName(name);
layer.setTitle(name);
layer.setEnabled(true);
layer.setQueryable(true);
layer.setType(LayerInfo.Type.RASTER);
layer.getMetadata().put(EoLayerType.KEY, layerType.name());
if(layerType == EoLayerType.BITMASK) {
StyleInfo red = getCatalog().getStyleByName("red");
if(red != null) {
layer.setDefaultStyle(red);
} else {