/** * Tests whether or not this raster data node uses a data-mask in order to determine valid pixels. The method returns * true if either {@link #isValidPixelExpressionSet()} or {@link #isNoDataValueUsed()} returns true. * <p>The data-mask is used to determine valid pixels. For more information * on valid pixels, please refer to the documentation of the {@link #isPixelValid(int, int, javax.media.jai.ROI)} * method. * * @return true, if so */ public boolean isValidMaskUsed() { return isValidPixelExpressionSet() || isNoDataValueUsed(); }
private boolean mustReplaceNaN(RasterDataNode sourceRaster, int targetDataType, double targetNoDataValue) { final boolean isFloat = ProductData.isFloatingPointType(targetDataType); final boolean isNoDataGiven = sourceRaster.isNoDataValueUsed() || noDataValue != null; final boolean isNoDataNaN = Double.isNaN(targetNoDataValue); return isFloat && isNoDataGiven && !isNoDataNaN; }
private static boolean isNoDataValue(RasterDataNode raster, int sample) { return !raster.isNoDataValueUsed() && sample == raster.getNoDataValue(); }
private static boolean isNoDataValue(RasterDataNode raster, float sample) { return !raster.isNoDataValueUsed() && sample == raster.getNoDataValue(); }
private Number getTargetNoDataValue(RasterDataNode sourceRaster, int targetDataType) { double targetNoDataValue = Double.NaN; if (noDataValue != null) { targetNoDataValue = noDataValue; } else if (sourceRaster.isNoDataValueUsed()) { targetNoDataValue = sourceRaster.getNoDataValue(); } Number targetNoDataNumber; if (targetDataType == ProductData.TYPE_INT8) { targetNoDataNumber = (byte) targetNoDataValue; } else if (targetDataType == ProductData.TYPE_INT16 || targetDataType == ProductData.TYPE_UINT8) { targetNoDataNumber = (short) targetNoDataValue; } else if (targetDataType == ProductData.TYPE_INT32 || targetDataType == ProductData.TYPE_UINT16) { targetNoDataNumber = (int) targetNoDataValue; } else if (targetDataType == ProductData.TYPE_FLOAT32) { targetNoDataNumber = (float) targetNoDataValue; } else { targetNoDataNumber = targetNoDataValue; } return targetNoDataNumber; }
/** * 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 boolean isNoDataValue(double sample) { final RasterDataNode rasterDataNode = tile.getRasterDataNode(); if (rasterDataNode.isNoDataValueUsed()) { if (rasterDataNode.isScalingApplied()) { return rasterDataNode.getGeophysicalNoDataValue() == sample; } else { return rasterDataNode.getNoDataValue() == sample; } } return false; } }
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; }
private void initNoDataValueUsedParam() { final ParamProperties properties = new ParamProperties(Boolean.class); properties.setLabel("Use no-data value:"); /*I18N*/ properties.setDescription("Indicates that the no-data value is used"); /*I18N*/ paramNoDataValueUsed = new Parameter("noDataValueUsed", rasterDataNode.isNoDataValueUsed(), properties); paramNoDataValueUsed.addParamChangeListener(new ParamChangeListener() { @Override public void parameterValueChanged(final ParamChangeEvent event) { paramNoDataValue.getEditor().setEnabled( (Boolean) paramNoDataValueUsed.getValue()); } }); }
@Override public RenderedImage createImage(int level) { return VirtualBandOpImage.create(expression, associatedNode.getDataType(), associatedNode.isNoDataValueUsed() ? associatedNode.getGeophysicalNoDataValue() : null, associatedNode.getProduct(), ResolutionLevel.create(getModel(), level)); } };
if (isNoDataValueUsed()) { resetValidMask(); if (isNoDataValueUsed()) { fireProductNodeDataChanged();
private void initNoDataValueParam() { final Double noDataValue = rasterDataNode.getGeophysicalNoDataValue(); final ParamProperties properties = new ParamProperties(Double.class); properties.setLabel("No-data value"); /*I18N*/ properties.setDescription("The value used to indicate no-data"); /*I18N*/ properties.setNumCols(13); paramNoDataValue = new Parameter("noDataValue", noDataValue, properties); paramNoDataValue.getEditor().setEnabled(rasterDataNode.isNoDataValueUsed()); }
if (rasterDataNode.isNoDataValueUsed()) { Number fillValue = DataTypeUtils.convertTo(noDataValue, variable.getDataType()); variable.addAttribute(Constants.FILL_VALUE_ATT_NAME, fillValue);
targetRaster.setScalingOffset(sourceRaster.getScalingOffset()); targetRaster.setLog10Scaled(sourceRaster.isLog10Scaled()); targetRaster.setNoDataValueUsed(sourceRaster.isNoDataValueUsed()); targetRaster.setNoDataValue(sourceRaster.getNoDataValue()); targetRaster.setValidPixelExpression(sourceRaster.getValidPixelExpression());