public void testSetAndGetBandStatistics() { RasterDataNode rasterDataNode = createRasterDataNode(); assertEquals(null, rasterDataNode.getImageInfo()); final ImageInfo imageInfo = new ImageInfo(new ColorPaletteDef(0, 1)); rasterDataNode.setImageInfo(imageInfo); assertSame(imageInfo, rasterDataNode.getImageInfo()); }
private static void addRasterDataNodeToProduct(final Product product, final RasterDataNode rasterDataNode) { if (rasterDataNode instanceof Band) { product.addBand((Band) rasterDataNode); } else if (rasterDataNode instanceof TiePointGrid) { product.addTiePointGrid((TiePointGrid) rasterDataNode); } else { fail("couldn't add RasterDataNode to product. Node is of unknown type."); } } }
final String initialExpression = "ident_1 + oldIdent - ident_3"; final String renamedExpression = "ident_1 + newIdent - ident_3"; final RasterDataNode node = createRasterDataNode(); node.setValidPixelExpression(initialExpression); final int width = node.getSceneRasterWidth(); addRasterDataNodeToProduct(product, node); product.setModified(false); assertFalse(node.isModified()); assertEquals(initialExpression, node.getValidPixelExpression()); assertTrue(node.isModified()); 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); }