private boolean isValidPixelExpressionSet() { return getValidPixelExpression() != null && getValidPixelExpression().trim().length() > 0; }
private static boolean isValidPixelExpressionUsed(RasterDataNode sourceRaster) { final String validPixelExpression = sourceRaster.getValidPixelExpression(); return validPixelExpression != null && !validPixelExpression.trim().isEmpty(); }
private void checkRaster(RasterDataNode raster, String type) { final String validExpr = raster.getValidPixelExpression(); if (validExpr != null && !product.isCompatibleBandArithmeticExpression(validExpr)) { raster.setValidPixelExpression(null); String pattern = "Valid pixel expression ''{0}'' removed from output {1} ''{2}'' " + "because it is not applicable."; /*I18N*/ messages.add(MessageFormat.format(pattern, validExpr, type, raster.getName())); } } });
private void collectReferencedRasters(String nodeName, ArrayList<String> referencedNodeNames) { RasterDataNode rasterDataNode = sourceProduct.getRasterDataNode(nodeName); if (rasterDataNode == null) { throw new OperatorException(String.format("Source product does not contain a raster named '%s'.", nodeName)); } final String validPixelExpression = rasterDataNode.getValidPixelExpression(); collectReferencedRastersInExpression(validPixelExpression, referencedNodeNames); if (rasterDataNode instanceof VirtualBand) { VirtualBand vBand = (VirtualBand) rasterDataNode; collectReferencedRastersInExpression(vBand.getExpression(), referencedNodeNames); } }
public static MultiLevelImage createMaskedGeophysicalImage(final RasterDataNode node, Number maskValue) { MultiLevelImage varImage = node.getGeophysicalImage(); if (node.getValidPixelExpression() != null) { varImage = replaceInvalidValuesByNaN(node, varImage, node.getValidMaskImage(), maskValue); } else if (node.isNoDataValueSet() && node.isNoDataValueUsed() && Double.compare(maskValue.doubleValue(), node.getGeophysicalNoDataValue()) != 0) { varImage = replaceNoDataValueByNaN(node, varImage, node.getGeophysicalNoDataValue(), maskValue); } return varImage; }
if (product != null) { final List<String> expressions = new ArrayList<String>(10); if (node.getValidPixelExpression() != null) { expressions.add(node.getValidPixelExpression());
/** * Gets the expression used for the computation of the mask which identifies valid pixel values. * It recognizes the value of the {@link #getNoDataValue() noDataValue} and the * {@link #getValidPixelExpression() validPixelExpression} properties, if any. * The method returns {@code null}, if none of these properties are set. * * @return The expression used for the computation of the mask which identifies valid pixel values, * or {@code null}. * @see #getValidPixelExpression() * @see #getNoDataValue() * @since BEAM 4.2 */ public String getValidMaskExpression() { String dataMaskExpression = null; if (isValidPixelExpressionSet()) { dataMaskExpression = getValidPixelExpression(); if (isNoDataValueUsed()) { final String dataMaskExpression2 = createValidMaskExpressionForNoDataValue(); if (!dataMaskExpression2.equals(dataMaskExpression)) { dataMaskExpression = "(" + dataMaskExpression + ") && " + dataMaskExpression2; } } } else if (isNoDataValueUsed()) { dataMaskExpression = createValidMaskExpressionForNoDataValue(); } return dataMaskExpression; }
private void initValidPixelExpressionParam() { final ParamProperties properties = new ParamProperties(String.class); properties.setNullValueAllowed(true); properties.setLabel("Valid pixel expression"); /*I18N*/ properties.setDescription("Boolean expression which is used to identify valid pixels"); /*I18N*/ properties.setNumRows(2); properties.setEditorClass(BooleanExpressionEditor.class); // todo setting namespace as property to the ExpressionEditor for validating the expression properties.setPropertyValue(BooleanExpressionEditor.PROPERTY_KEY_SELECTED_PRODUCT, rasterDataNode.getProduct()); properties.setPropertyValue(BooleanExpressionEditor.PROPERTY_KEY_INPUT_PRODUCTS, getCompatibleProducts(rasterDataNode)); paramValidPixelExpr = new Parameter("validMaskExpr", rasterDataNode.getValidPixelExpression(), properties); paramName.addParamChangeListener(new ParamChangeListener() { @Override public void parameterValueChanged(final ParamChangeEvent event) { final String expresion = paramValidPixelExpr.getValueAsText(); final String newExpression = StringUtils.replaceWord(expresion, (String) event.getOldValue(), paramName.getValueAsText()); paramValidPixelExpr.setValueAsText(newExpression, null); } }); }
product.setModified(false); assertFalse(node.isModified()); assertEquals(initialExpression, node.getValidPixelExpression()); assertEquals(renamedExpression, node.getValidPixelExpression());
public void testValidMaskExpressionIsAdjustedIfNodeNameChanged() { final RasterDataNode rasterDataNode = createRasterDataNode(); rasterDataNode.setValidPixelExpression("flagsBand.f1 || not flagsBand.f2"); final Product product = new Product("p", "NoType", rasterDataNode.getRasterWidth(), rasterDataNode.getRasterHeight()); addRasterDataNodeToProduct(product, rasterDataNode); final FlagCoding flagCoding = new FlagCoding("f"); flagCoding.addFlag("f1", 0x01, "descr"); flagCoding.addFlag("f2", 0x02, "descr"); final Band flagsBand = product.addBand("flagsBand", ProductData.TYPE_INT8); flagsBand.setSampleCoding(flagCoding); product.getFlagCodingGroup().add(flagCoding); flagsBand.setName("flags"); final String currentExpression = rasterDataNode.getValidPixelExpression(); final String expectedExpression = "flags.f1 || not flags.f2"; assertEquals("name is not changed", expectedExpression, currentExpression); }
final String sourceExpression = sourceNode.getValidPixelExpression(); if (sourceExpression != null && !targetProduct.isCompatibleBandArithmeticExpression(sourceExpression)) { targetBand.setValidPixelExpression(sourceExpression);
targetRaster.setNoDataValueUsed(sourceRaster.isNoDataValueUsed()); targetRaster.setNoDataValue(sourceRaster.getNoDataValue()); targetRaster.setValidPixelExpression(sourceRaster.getValidPixelExpression()); if (sourceRaster instanceof Band && targetRaster instanceof Band) { Band sourceBand = (Band) sourceRaster;