SubsetOp extends Operator { public void setBandNames(String[] bandNames) { this.bandNames = bandNames != null ? bandNames.clone() : null; } SubsetOp(); String[] getTiePointGridNames(); void setTiePointGridNames(String[] tiePointGridNames); String[] getBandNames(); void setBandNames(String[] bandNames); void setCopyMetadata(boolean copyMetadata); Rectangle getRegion(); void setRegion(Rectangle region); void setSubSamplingX(int subSamplingX); void setSubSamplingY(int subSamplingY); Geometry getGeoRegion(); void setGeoRegion(Geometry geoRegion); @Override void initialize(); @Override void computeTile(Band band, Tile targetTile, ProgressMonitor pm); static Rectangle computePixelRegion(Product product, Geometry geoRegion, int numBorderPixels);  }
@Test public void testReferencedRastersAreIncluded() throws Exception { final Product sp = createTestProduct(100, 100); sp.getBand("radiance_1").setValidPixelExpression("radiance_2 > 0"); final String[] bandNames = {"radiance_1", "radiance_3"}; SubsetOp op = new SubsetOp(); op.setSourceProduct(sp); op.setBandNames(bandNames); Product tp = op.getTargetProduct(); assertEquals(3, tp.getNumBands()); assertNotNull(tp.getBand("radiance_1")); assertEquals("radiance_2 > 0", tp.getBand("radiance_1").getValidPixelExpression()); assertNotNull(tp.getBand("radiance_2")); assertNotNull(tp.getBand("radiance_3")); }
@Test public void testAutoGrouping() throws Exception { final Product sp = createTestProduct(100, 100); sp.setAutoGrouping("radiance"); final String[] bandNames = {"radiance_1", "radiance_3"}; SubsetOp op = new SubsetOp(); op.setSourceProduct(sp); op.setBandNames(bandNames); Product tp = op.getTargetProduct(); assertEquals(2, tp.getNumBands()); Product.AutoGrouping autoGrouping = tp.getAutoGrouping(); assertNotNull(autoGrouping); assertEquals(1, autoGrouping.size()); assertArrayEquals(new String[]{"radiance"}, autoGrouping.get(0)); }