@Override public void extendNamespace(WritableNamespace namespace, Product product, String namePrefix) { final int numBands = product.getNumBands(); for (int i = 0; i < numBands; i++) { final Band band = product.getBandAt(i); MoreFuncs.registerBandProperties(namespace, band); } } });
private CachingObjectArray.ObjectFactory getLineFactory() { final Band band = _product.getBandAt(0); final int width = _product.getSceneRasterWidth(); return new CachingObjectArray.ObjectFactory() { public Object createObject(int index) throws Exception { _dem.updateCache(GETASSE30ElevationTile.this); return band.readPixels(0, index, width, 1, new float[width], ProgressMonitor.NULL); } }; }
private ArrayList<Band> getBandsToExport(Product sourceProduct) { final int nodeCount = sourceProduct.getNumBands(); final ArrayList<Band> bandsToWrite = new ArrayList<>(); for (int i = 0; i < nodeCount; i++) { final Band band = sourceProduct.getBandAt(i); if (shouldWrite(band)) { bandsToWrite.add(band); } } return bandsToWrite; }
private static void addBandNameRefs(Product product, String namePrefix, List<String> list) { for (int j = 0; j < product.getNumBands(); j++) { Band band = product.getBandAt(j); list.add(namePrefix + band.getName()); } }
@Override public void initialize() throws OperatorException { bandMap = new HashMap<Band, Band>(3); dataMap = new HashMap<Band, ProductData>(3); rgbChannelNodes = new RasterDataNode[3]; final int height = sourceProduct.getSceneRasterHeight(); final int width = sourceProduct.getSceneRasterWidth(); targetProduct = new Product("RGB", "RGB", width, height); prepareTargetBand(0, sourceProduct.getBandAt(red), "red", width, height); prepareTargetBand(1, sourceProduct.getBandAt(green), "green", width, height); prepareTargetBand(2, sourceProduct.getBandAt(blue), "blue", width, height); }
private ExpectedBand[] createExpectedBands(Product product, Random random) { final ExpectedBand[] expectedBands = new ExpectedBand[product.getNumBands()]; for (int i = 0; i < expectedBands.length; i++) { expectedBands[i] = new ExpectedBand(product.getBandAt(i), random); } return expectedBands; }
/** * Checks whether or not this product can be orthorectified. * * @return true if {@link Band#canBeOrthorectified()} returns true for all bands, false otherwise */ public boolean canBeOrthorectified() { for (int i = 0; i < getNumBands(); i++) { if (!getBandAt(i).canBeOrthorectified()) { return false; } } return true; }
private PlanarImage createExpressionImage(final String expression, Product product) { final MultiLevelImage sourceImage = product.getBandAt(0).getSourceImage(); final ResolutionLevel resolutionLevel = ResolutionLevel.create(sourceImage.getModel(), 0); final float fillValue = 0.0f; return VirtualBandOpImage.create(expression, ProductData.TYPE_FLOAT32, fillValue, product, resolutionLevel); }
private static void performBandTest(String filePath) throws IOException { Product product = ProductIO.readProduct(filePath); Band band0 = product.getBandAt(0); double[] times = computeStx(band0); System.out.println(product.getProductType()); System.out.println("band width : " + band0.getSceneRasterWidth()); System.out.println("band height: " + band0.getSceneRasterHeight()); System.out.println(); for (int i = 0; i < times.length; i++) { System.out.println("stx" + i + " : " + times[i]); } System.out.println(); }
private void resetBandTableModel() { bandModel.clear(); if (currentRaster != null) { final int numBands = currentProduct.getNumBands(); for (int i = 0; i < numBands; i++) { final Band band = currentProduct.getBandAt(i); if (shouldDisplayBand(band)) { bandModel.addRow(band.getName(), "", band.getUnit()); } } } }
private static void registerBandSymbols(WritableNamespace namespace, Product product, String namePrefix) { for (int i = 0; i < product.getNumBands(); i++) { final Band band = product.getBandAt(i); final String symbolName = namePrefix + band.getName(); namespace.registerSymbol(new RasterDataSymbol(symbolName, band, RasterDataSymbol.GEOPHYSICAL)); namespace.registerSymbol(new RasterDataSymbol(symbolName + ".raw", band, RasterDataSymbol.RAW)); } }
private void updateTilingParameter() { if (writeParam.getTilingMode() != TIFFImageWriteParam.MODE_EXPLICIT) { final Product sourceProduct = getSourceProduct(); final MultiLevelImage firstSourceImage = sourceProduct.getBandAt(0).getSourceImage(); final int tileWidth = firstSourceImage.getTileWidth(); final int tileHeight = firstSourceImage.getTileHeight(); writeParam.setTilingMode(TIFFImageWriteParam.MODE_EXPLICIT); writeParam.setTiling(tileWidth, tileHeight, 0, 0); } }
public void testWriteToStream_WithIllegalOffset() throws Exception { _product.addBand("b1", ProductData.TYPE_UINT16); fillBandWithData(_product.getBandAt(0), 20); final MemoryCacheImageOutputStream stream = new MemoryCacheImageOutputStream(new ByteArrayOutputStream()); final TiffIFD ifd = new TiffIFD(_product); final int illegalOffset = -1; try { ifd.write(stream, illegalOffset, 0); fail("IllegalArgumentException expected because the ifd offset is illegal"); } catch (IllegalArgumentException expected) { } catch (Exception notExpected) { fail("IllegalArgumentException expected but was [" + notExpected.getClass().getName() + "]"); } }
@Test public void testWriteReadUTMProjection() throws IOException, TransformException, FactoryException { setGeoCoding(outProduct, WGS_84_UTM_ZONE_28S); final Product inProduct = writeReadProduct(); assertEquals(outProduct.getName(), inProduct.getName()); assertEquals(outProduct.getProductType(), inProduct.getProductType()); assertEquals(outProduct.getNumBands(), inProduct.getNumBands()); assertEquals(outProduct.getBandAt(0).getName(), inProduct.getBandAt(0).getName()); assertEquals(outProduct.getBandAt(0).getDataType(), inProduct.getBandAt(0).getDataType()); assertEquals(outProduct.getBandAt(0).getScalingFactor(), inProduct.getBandAt(0).getScalingFactor(), 1.0e-6); assertEquals(outProduct.getBandAt(0).getScalingOffset(), inProduct.getBandAt(0).getScalingOffset(), 1.0e-6); assertEquals(location, inProduct.getFileLocation()); assertNotNull(inProduct.getGeoCoding()); assertEquality(outProduct.getGeoCoding(), inProduct.getGeoCoding(), 2.0e-5f); }
@Override protected Layer createLayer(LayerType layerType) throws Exception { final PropertySet configuration = layerType.createLayerConfig(null); final Band raster = getProductManager().getProduct(0).getBandAt(0); configuration.setValue(RasterImageLayerType.PROPERTY_NAME_RASTER, raster); return layerType.createLayer(null, configuration); } }
public void testGetStripOffsets_AfterWrite() throws IOException { final long firstIFDOffset = 10; _product.addBand("b1", ProductData.TYPE_UINT16); fillBandWithData(_product.getBandAt(0), 20); final MemoryCacheImageOutputStream stream = new MemoryCacheImageOutputStream(new ByteArrayOutputStream()); final TiffIFD ifd = new TiffIFD(_product); ifd.write(stream, firstIFDOffset, 0); final TiffLong[] stripOffsets = (TiffLong[]) ifd.getEntry(TiffTag.STRIP_OFFSETS).getValues(); assertNotNull(stripOffsets); assertEquals(1, stripOffsets.length); assertEquals(ifd.getRequiredIfdSize() + firstIFDOffset + ifd.getRequiredReferencedValuesSize(), stripOffsets[0].getValue()); }
private void performTest(float accuracy) throws IOException { final Product inProduct = writeReadProduct(); assertEquals(outProduct.getName(), inProduct.getName()); assertEquals(outProduct.getProductType(), inProduct.getProductType()); assertEquals(outProduct.getNumBands(), inProduct.getNumBands()); for (int i = 0; i < outProduct.getNumBands(); i++) { assertEquality(outProduct.getBandAt(i), inProduct.getBandAt(i)); } assertEquals(location, inProduct.getFileLocation()); assertNotNull(inProduct.getGeoCoding()); assertEquality(outProduct.getGeoCoding(), inProduct.getGeoCoding(), accuracy); }
@Override public void initialize() { int width = sourceProduct.getSceneRasterWidth(); int height = sourceProduct.getSceneRasterHeight(); PlanarImage constImage = ConstantDescriptor.create((float) width, (float) height, new Float[]{66.6f}, null); targetProduct = new Product("name", "desc", width, height); targetProduct.addBand("OperatorBand", ProductData.TYPE_INT8); targetProduct.addBand("ConstantBand", ProductData.TYPE_FLOAT32).setSourceImage(constImage); targetProduct.addBand(new VirtualBand("VirtualBand", ProductData.TYPE_FLOAT32, width, height, "OperatorBand + ConstantBand")); ProductUtils.copyBand(sourceProduct.getBandAt(0).getName(), sourceProduct, targetProduct, true); }