public static boolean isValidSentinel2(Product sourceProduct) { for (String bandName : S2IdepixConstants.S2_MSI_REFLECTANCE_BAND_NAMES) { if (!sourceProduct.containsBand(bandName)) { return false; } } return true; }
private static void setValidBandName(Property property, Product product) { String bandName = (String) property.getValue(); String bandNameStub = bandName; for (int i = 2; product.containsBand(bandName); i++) { bandName = String.format("%s_%d", bandNameStub, i); } try { property.setValue(bandName); } catch (ValidationException e) { throw new IllegalStateException(e); } }
@Override public void validateValue(Property property, Object value) throws ValidationException { final String bandName = value.toString().trim(); if (!ProductNode.isValidNodeName(bandName)) { throw new ValidationException(MessageFormat.format("The band name ''{0}'' appears not to be valid.\n" + "Please choose another one.", bandName)); } else if (product.containsBand(bandName)) { throw new ValidationException(MessageFormat.format("The selected product already contains a band named ''{0}''.\n" + "Please choose another one.", bandName)); } } }
@Override public void validateValue(Property property, Object value) throws ValidationException { final String bandName = value.toString().trim(); if (!ProductNode.isValidNodeName(bandName)) { throw new ValidationException(MessageFormat.format("The band name ''{0}'' appears not to be valid.\n" + "Please choose another one.", bandName )); } else if (product.containsBand(bandName)) { throw new ValidationException(MessageFormat.format("The selected product already contains a band named ''{0}''.\n" + "Please choose another one.", bandName )); } } }
@Override public boolean accept(Product product) { String productType = productDescriptor.getProductType(); if (productType != null && !product.getProductType().matches(productType)) { return false; } for (String bandName : productDescriptor.getBands()) { if (!product.containsBand(bandName)) { return false; } } return true; } }
@Override protected boolean verifyUserInput() { String message = null; final String targetBandName = filterSetsForm.getTargetBandName(); if (targetBandName.equals("")) { message = "Please enter a name for the new filtered band."; /*I18N*/ } else if (!ProductNode.isValidNodeName(targetBandName)) { message = MessageFormat.format("The band name ''{0}'' appears not to be valid.\n" + "Please choose a different band name.", targetBandName); /*I18N*/ } else if (product.containsBand(targetBandName)) { message = MessageFormat.format("The selected product already contains a band named ''{0}''.\n" + "Please choose a different band name.", targetBandName); /*I18N*/ } else if (filterSetsForm.getSelectedFilter() == null) { message = "Please select an image filter."; /*I18N*/ } if (message != null) { Dialogs.showError(TITLE, message); return false; } return true; }
private void copyBandWithFeatures(Product sourceProduct, String oldBandName, String newBandName) { Band sourceBand = sourceProduct.getBand(oldBandName); if (sourceBand == null) { final String msg = String.format("Source product [%s] does not contain a band with name [%s]", sourceProduct.getName(), oldBandName); throw new OperatorException(msg); } if (targetProduct.containsBand(newBandName)) { return; } ProductUtils.copyBand(oldBandName, sourceProduct, newBandName, targetProduct, true); }
@Override public void undo() throws CannotUndoException { super.undo(); for (Band displacementBand : displacementBands) { if (product.containsBand(displacementBand.getName())) { product.removeBand(displacementBand); } } }
@Override protected boolean verifyUserInput() { String uncertaintyExpression = targetExprArea.getText(); if (uncertaintyExpression == null || uncertaintyExpression.trim().isEmpty()) { Dialogs.showError("Uncertainty expression is empty."); return false; } if (uncertaintyExpression.startsWith(ERROR_PREFIX)) { Dialogs.showError(uncertaintyExpression.substring(ERROR_PREFIX.length())); return false; } if (sourceBand.getProduct().containsBand(getBandName())) { Dialogs.showError("A raster with name '" + getBandName() + "' already exists."); return false; } return super.verifyUserInput(); }
public void extendTargetProduct() throws OperatorException { if (copyToaReflectances) { copyReflectances(); } for (String s2MsiAnnotationBandName : S2IdepixConstants.S2_MSI_ANNOTATION_BAND_NAMES) { Band b = ProductUtils.copyBand(s2MsiAnnotationBandName, sourceProduct, targetProduct, true); b.setUnit("dl"); } Band b = ProductUtils.copyBand(S2IdepixConstants.ELEVATION_BAND_NAME, elevationProduct, targetProduct, true); b.setUnit("m"); if (sourceProduct.containsBand("lat") && !targetProduct.containsBand("lat")) { Band latBand = ProductUtils.copyBand("lat", sourceProduct, targetProduct, true); latBand.setUnit("deg"); } if (sourceProduct.containsBand("lon") && !targetProduct.containsBand("lon")) { Band latBand = ProductUtils.copyBand("lon", sourceProduct, targetProduct, true); latBand.setUnit("deg"); } if (copyNNValue) { targetProduct.addBand("nn_value", ProductData.TYPE_FLOAT32); } }
private static String getExpression(RasterDataNode raster) { Product product = raster.getProduct(); if (product != null) { if (product.containsBand(raster.getName())) { return raster.getName(); } else { if (raster instanceof VirtualBand) { return ((VirtualBand) raster).getExpression(); } } } return null; }
private boolean doUsedVariablesStillExist(AggregatorConfig[] aggregatorConfigs) { Product contextProduct = formModel.getContextProduct(); // assuming that the variables are defined in the context product TypedDescriptorsRegistry registry = TypedDescriptorsRegistry.getInstance(); for (AggregatorConfig aggregatorConfig : aggregatorConfigs) { String aggregatorConfigName = aggregatorConfig.getName(); AggregatorDescriptor descriptor = registry.getDescriptor(AggregatorDescriptor.class, aggregatorConfigName); String[] sourceVarNames = descriptor.getSourceVarNames(aggregatorConfig); for (String sourceVarName : sourceVarNames) { if (Objects.isNull(contextProduct) || !contextProduct.containsBand(sourceVarName)) { String msg = String.format( "Source band name '%s' of aggregator '%s' is unknown.\nIt is neither one of the bands of the source products,\n" + "nor is it defined by an intermediate source band.", sourceVarName, aggregatorConfigName ); showErrorDialog(msg); return false; } } } return true; }
@Override public void redo() throws CannotRedoException { super.redo(); for (Band displacementBand : displacementBands) { if (!product.containsBand(displacementBand.getName())) { product.addBand(displacementBand); product.fireProductNodeChanged(displacementBand.getName()); } } }
targetBandNameToSourceBandName.put(targetBandName, srcBandName); if (!targetProduct.containsBand(srcBandName)) { final Band targetBand = ProductUtils.copyBand(srcBandName, sourceProduct, targetProduct, true);
return false; if (newVariable && contextProduct.containsBand(variableName)) { String message = String.format("A source band or band with the name '%s' is already defined", variableName); AbstractDialog.showInformationDialog(getParent(), message, "Information");
private Band addBand(final Product product, String name, final int w, final int h, final ImageIOFile img, final int bandIndex, final String unit) throws IOException { File bandFile = getFile(img.getName()); ProductReader reader = geotiffPlugIn.createReaderInstance(); Product bandProduct = reader.readProductNodes(bandFile, null); if (bandProduct != null) { bandProducts.add(bandProduct); Band srcBand = bandProduct.getBandAt(bandIndex); if (product.containsBand(name)) { name += "2"; } Band band = new Band(name, srcBand.getDataType(), w, h); band.setNoDataValue(0); band.setNoDataValueUsed(true); band.setUnit(unit); band.setSourceImage(srcBand.getSourceImage()); product.addBand(band); return band; } return null; }
final String sourceBandName = sourceBand.getName(); final boolean copyBand = (copyToaReflBands && !targetProduct.containsBand(sourceBandName) && sourceBand.getSpectralWavelength() > 0); final String sourceBandName = sourceBand.getName(); final boolean copyBand = (copyGeometryBands && !targetProduct.containsBand(sourceBandName) && AerosolUtils.isS2GeometryBand(sourceBand)); if (!sourceBand.isFlagBand() && !targetProduct.containsBand(sourceBandName)) { ProductUtils.copyBand(sourceBandName, aotOriginalResolutionProduct, targetProduct, true); if (!sourceBand.isFlagBand() && !targetProduct.containsBand(sourceBandName)) { ProductUtils.copyBand(sourceBandName, reflProduct, targetProduct, true);
private void copyBands(Product sourceProduct, Product targetProduct) { Guardian.assertNotNull("source", sourceProduct); Guardian.assertNotNull("target", targetProduct); ProductNodeGroup<FlagCoding> targetFCG = targetProduct.getFlagCodingGroup(); for (int iBand = 0; iBand < sourceProduct.getNumBands(); iBand++) { Band sourceBand = sourceProduct.getBandAt(iBand); if (!targetProduct.containsBand(sourceBand.getName())) { Band targetBand = copyBandScl(sourceBand.getName(), sourceProduct, sourceBand.getName(), targetProduct); if (sourceBand.isFlagBand()) { FlagCoding flgCoding = sourceBand.getFlagCoding(); if (!targetFCG.contains(flgCoding.getName())) { ProductUtils.copyFlagCoding(flgCoding, targetProduct); } if (targetBand != null) { targetBand.setSampleCoding(targetFCG.get(flgCoding.getName())); } } } } }
if (sourceProduct.containsBand(S2IdepixConstants.ELEVATION_BAND_NAME)) { elevationProduct = sourceProduct; } else {
if (!clonedProduct.containsBand(b.getName())) { ProductUtils.copyBand(b.getName(), sourceProduct, clonedProduct, true); if (isIdepixSpectralBand(b)) {