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 writeBandRasterData(Band sourceBand, int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, ProductData sourceBuffer, ProgressMonitor pm) throws IOException { final Product sourceProduct = sourceBand.getProduct(); final int numBands = sourceProduct.getNumBands(); boolean shouldFinalize = numBands == processedCount.get(); if (!shouldFinalize) { if (!this.processedBands.containsKey(sourceBand)) { this.processedBands.put(sourceBand, getScaledImage(sourceBand)); processedCount.incrementAndGet(); shouldFinalize = numBands == processedCount.get(); } if (shouldFinalize) { finalizeWrite(); } } }
private static boolean isOrtorectifiable(Product product) { return product.getNumBands() > 0 && product.getBandAt(0).canBeOrthorectified(); }
private void setEnableState() { ProductNode productNode = lkp.lookup(ProductNode.class); boolean state = false; if (productNode != null) { Product product = productNode.getProduct(); if (product != null) { final boolean hasPixelGeoCoding = product.getSceneGeoCoding() instanceof BasicPixelGeoCoding; final boolean hasSomeBands = product.getNumBands() >= 2; state = !hasPixelGeoCoding && hasSomeBands; } } setEnabled(state); }
private static List<RasterDataNode> getReferencedVirtualBands(final RasterDataNode node) { final Product product = node.getProduct(); final List<RasterDataNode> rasterList = new ArrayList<RasterDataNode>(); if (product != null) { for (int i = 0; i < product.getNumBands(); i++) { final Band band = product.getBandAt(i); if (band instanceof VirtualBand) { final VirtualBand virtualBand = (VirtualBand) band; if (isNodeReferencedByExpression(node, virtualBand.getExpression())) { rasterList.add(virtualBand); } } } } return rasterList; }
/** * Add the user selected bands to target product. * * @throws OperatorException The exceptions. */ private void addSelectedBands() throws OperatorException { final Band[] bands = sourceProduct.getBands(); final List<String> bandNameList = new ArrayList<>(sourceProduct.getNumBands()); for (Band band : bands) { bandNameList.add(band.getName()); } final String[] sourceBandNames = bandNameList.toArray(new String[bandNameList.size()]); final Band[] sourceBands = OperatorUtils.getSourceBands(sourceProduct, sourceBandNames, false); for (Band srcBand : sourceBands) { final String srcBandName = srcBand.getName(); if (!srcBandName.contains(OilSpillDetectionOp.OILSPILLMASK_NAME)) { final Band targetBand = ProductUtils.copyBand(srcBandName, sourceProduct, targetProduct, true); } else { ProductUtils.copyBand(srcBandName, sourceProduct, targetProduct, false); } } }
private void generateProductLists( Set<String> selectedProductFiles, List<TileMetadata>tileMetadataList) throws IOException{ for (TileMetadata tileMetadata : tileMetadataList) { TileComponent tileComponent = tileMetadata.getTileComponent(); for (int filesIndex = 0; filesIndex < tileComponent.getNumOfTiles(); filesIndex++) { String filePath = null; for (String filePaths : selectedProductFiles) { if (filePaths.contains(tileComponent.getTileNames()[filesIndex])) { filePath = filePaths; } } Product p = ProductIO.readProduct(Paths.get(productDirectory.getBasePath()).resolve(filePath).toFile()); this.bandDataType = p.getBandAt(0).getDataType(); if (tileComponent.getBandID().equals("P")) { this.tilesPanchromatic.put(p, tileComponent.getTileNames()[filesIndex]); } else { this.tilesMultiSpectral.put(p, tileComponent.getTileNames()[filesIndex]); if (this.numMultiSpectralBands ==0) { this.numMultiSpectralBands = p.getNumBands(); } } } } }
/** * Add bands to the target product. * * @throws OperatorException The exception. */ private void addSelectedBands() throws OperatorException { final String[] targetBandNames = getTargetBandNames(); for (PolBandUtils.PolSourceBand bandList : srcBandList) { final Band[] targetBands = OperatorUtils.addBands(targetProduct, targetBandNames, bandList.suffix); bandList.addTargetBands(targetBands); } if (targetProduct.getNumBands() == 0) { throw new OperatorException("No output bands selected"); } }
private void getMasterBands() { String mstBandName = sourceProduct.getBandAt(0).getName(); // find co-pol bands final String[] masterBandNames = StackUtils.getMasterBandNames(sourceProduct); for (String bandName : masterBandNames) { final String mstPol = OperatorUtils.getPolarizationFromBandName(bandName); if (mstPol != null && (mstPol.equals("hh") || mstPol.equals("vv"))) { mstBandName = bandName; break; } } masterBand = sourceProduct.getBand(mstBandName); if (masterBand.getUnit() != null && masterBand.getUnit().equals(Unit.REAL)) { int mstIdx = sourceProduct.getBandIndex(mstBandName); if (sourceProduct.getNumBands() > mstIdx + 1) { complexCoregistration = true; } } }
@Override protected void writeProductNodesImpl() throws IOException { this.outputFile = null; Product sourceProduct = getSourceProduct(); if (sourceProduct.getNumBands() > 4) { String message = "Source product " + sourceProduct.getName() + " has more than 4 bands. The product can not be exported due to OpenJpeg library limitations"; throw new IOException(message); } final File file; if (getOutput() instanceof String) { file = new File((String) getOutput()); } else { file = (File) getOutput(); } this.outputFile = FileUtils.ensureExtension(file, JP2Constants.FILE_EXTENSIONS[0]); deleteOutput(); ensureNamingConvention(); this.metadata = new GmlFeatureCollection(); this.metadata.setNumBands(getSourceProduct().getNumBands()); }
private RasterDataNode[] createAvailableBandList(final Product product, boolean considerReferenceSize) { final List<RasterDataNode> availableBandList = new ArrayList<>(17); if (product != null) { for (int i = 0; i < product.getNumBands(); i++) { final Band band = product.getBandAt(i); if (!considerReferenceSize || band.getRasterSize().equals(referenceSize)) { availableBandList.add(band); } } if (!considerReferenceSize || product.getSceneRasterSize().equals(referenceSize)) { for (int i = 0; i < product.getNumTiePointGrids(); i++) { availableBandList.add(product.getTiePointGridAt(i)); } } } // if raster is only bound to the product and does not belong to it final RasterDataNode raster = getRaster(); if (raster != null && raster.getProduct() == product && (!considerReferenceSize || raster.getRasterSize().equals(raster.getProduct().getSceneRasterSize()))) { if (!availableBandList.contains(raster)) { availableBandList.add(raster); } } return availableBandList.toArray(new RasterDataNode[availableBandList.size()]); }
private static List<RasterDataNode> getReferencedValidMasks(final RasterDataNode node) { final Product product = node.getProduct(); final List<RasterDataNode> rasterList = new ArrayList<RasterDataNode>(); if (product != null) { for (int i = 0; i < product.getNumBands(); i++) { final Band band = product.getBandAt(i); if (band != node) { if (isNodeReferencedByExpression(node, band.getValidPixelExpression())) { rasterList.add(band); } } } for (int i = 0; i < product.getNumTiePointGrids(); i++) { final TiePointGrid tiePointGrid = product.getTiePointGridAt(i); if (tiePointGrid != node) { if (isNodeReferencedByExpression(node, tiePointGrid.getValidPixelExpression())) { rasterList.add(tiePointGrid); } } } } return rasterList; }
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 double[] computeSourceProductMaximumResolution(Product sourceProduct) { AffineTransform affTransform = sourceProduct.getBandAt(0).getSourceImage().getModel().getImageToModelTransform(0); double[] productResolution = new double[] {affTransform.getScaleX(),Math.abs(affTransform.getScaleY())}; for(int index = 0;index<sourceProduct.getNumBands();index++) { affTransform = sourceProduct.getBandAt(index).getSourceImage().getModel().getImageToModelTransform(0); if(( affTransform.getScaleX() < productResolution[0])||(Math.abs(affTransform.getScaleY()) < productResolution[1])){ productResolution[0] = affTransform.getScaleX(); productResolution[1] = Math.abs(affTransform.getScaleY()); } } return productResolution; }
private void getMasterBands() { String mstBandName = sourceProduct.getBandAt(0).getName(); // find co-pol bands masterBandNames = StackUtils.getMasterBandNames(sourceProduct); for (String bandName : masterBandNames) { final String mstPol = OperatorUtils.getPolarizationFromBandName(bandName); if (mstPol != null && (mstPol.equals("hh") || mstPol.equals("vv"))) { mstBandName = bandName; break; } } masterBand1 = sourceProduct.getBand(mstBandName); if(masterBand1 == null) { mstBandName = sourceProduct.getBandAt(0).getName(); masterBand1 = sourceProduct.getBand(mstBandName); } if (masterBand1.getUnit() != null && masterBand1.getUnit().equals(Unit.REAL)) { int mstIdx = sourceProduct.getBandIndex(mstBandName); if (sourceProduct.getNumBands() > mstIdx + 1) { masterBand2 = sourceProduct.getBandAt(mstIdx + 1); complexCoregistration = true; } } }
@Test public void testdIntensityToAmplitude() { final Product product = createTestProduct("Intensity", Unit.INTENSITY, 16, 4); final Band band1 = product.getBandAt(0); AmplitudeToIntensityAction.convert(product, band1, true); assertTrue(product.getNumBands() == 2); final Band band2 = product.getBandAt(1); assertTrue(band2.getUnit().equals(Unit.AMPLITUDE)); assertTrue(band2.getName().equals("Amplitude")); }
@Test public void testLinearTodB() { final Product product = createTestProduct(16, 4); final Band band1 = product.getBandAt(0); LinearTodBAction.convert(product, band1, true); assertTrue(product.getNumBands() == 2); final Band band2 = product.getBandAt(1); assertTrue(band2.getUnit().endsWith(dBStr)); assertTrue(band2.getName().endsWith(dBStr)); }
@Test public void testAmplitudeToIntensity() { final Product product = createTestProduct("Amplitude", Unit.AMPLITUDE, 16, 4); final Band band1 = product.getBandAt(0); AmplitudeToIntensityAction.convert(product, band1, false); assertTrue(product.getNumBands() == 2); final Band band2 = product.getBandAt(1); assertTrue(band2.getUnit().contains(Unit.INTENSITY)); assertTrue(band2.getName().endsWith("Intensity")); }
@Test public void testdBToLinear() { final Product product = createTestProduct(16, 4); final Band band1 = product.getBandAt(0); band1.setName(band1.getName() + dBStr); band1.setUnit(band1.getUnit() + dBStr); LinearTodBAction.convert(product, band1, false); assertTrue(product.getNumBands() == 2); final Band band2 = product.getBandAt(1); assertTrue(band2.getUnit().equals(Unit.AMPLITUDE)); assertTrue(band2.getName().equals("Amplitude")); }
private void copyBands(Product sourceProduct, Product targetProduct) { Guardian.assertNotNull("source", sourceProduct); Guardian.assertNotNull("target", targetProduct); ProductNodeGroup<FlagCoding> targetFCG = targetProduct.getFlagCodingGroup(); for (int iBand = 0; iBand < sourceProduct.getNumBands(); iBand++) { Band sourceBand = sourceProduct.getBandAt(iBand); if (!targetProduct.containsBand(sourceBand.getName())) { Band targetBand = copyBandScl(sourceBand.getName(), sourceProduct, sourceBand.getName(), targetProduct); if (sourceBand.isFlagBand()) { FlagCoding flgCoding = sourceBand.getFlagCoding(); if (!targetFCG.contains(flgCoding.getName())) { ProductUtils.copyFlagCoding(flgCoding, targetProduct); } if (targetBand != null) { targetBand.setSampleCoding(targetFCG.get(flgCoding.getName())); } } } } }