@Override public void dispose() { try { for (Band band : bandMap.keySet()) { SubsetInfo info = bandMap.get(band); info.productWriter.close(); } } catch (IOException ignore) { } super.dispose(); }
WriterInfo(final String folderName, final String targetBandName, final Product product) { this.folderName = folderName; this.targetBandName = targetBandName.startsWith("i_") ? targetBandName.substring(2, targetBandName.length()) : targetBandName; this.product = product; productWriter = ProductIO.getProductWriter(formatName); if (productWriter == null) { throw new OperatorException("No data product writer for the '" + formatName + "' format available"); } productWriter.setIncrementalMode(false); } }
private synchronized void writeHeader(final SubsetInfo info) throws Exception { if (info.written) return; subsetInfo.productWriter.writeProductNodes(subsetInfo.subsetProduct, subsetInfo.file); info.written = true; }
throw new OperatorException("No data product writer for the '" + formatName + "' format available"); subsetInfo[n].productWriter.setIncrementalMode(false); subsetInfo[n].productWriter.setFormatName(formatName); subsetInfo[n].product.setProductWriter(subsetInfo[n].productWriter);
private synchronized void writeProjectedDEM() { if(projectedDEMWritten) return; try { writeHeader(projectedDEMInfo); final Band elevationBand = projectedDEM.getElevationBand(); final Rectangle trgRect = new Rectangle(0, 0, elevationBand.getRasterWidth(), elevationBand.getRasterHeight()); projectedDEM.computeTile(trgRect); final ProductData rawSamples = elevationBand.getData(); projectedDEMInfo.productWriter.writeBandRasterData(elevationBand, trgRect.x, trgRect.y, trgRect.width, trgRect.height, rawSamples, ProgressMonitor.NULL); } catch (Exception e) { e.printStackTrace(); } projectedDEMWritten = true; }
return null; final EncodeQualification encodeQualification = productWriter.getWriterPlugIn().getEncodeQualification(product); if (encodeQualification.getPreservation() == EncodeQualification.Preservation.UNABLE) { Dialogs.showError(getDisplayName(), MessageFormat.format("Writing this product as {0} is not possible:\n"
throw new OperatorException("No data product writer for the '" + formatName + "' format available"); subsetInfo.productWriter.setFormatName(formatName); subsetInfo.productWriter.setIncrementalMode(false); subsetInfo.subsetProduct.setProductWriter(subsetInfo.productWriter); for (int i = 0; i < bandNames.length; i++) {
@Override public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException { for (Band targetBand : tgtBandToInfoMap.keySet()) { try { final WriterInfo info = tgtBandToInfoMap.get(targetBand); final Tile targetTile = targetTiles.get(targetBand); writeHeader(info); final Rectangle trgRect = targetTile.getRectangle(); final Tile sourceTile = getSourceTile(targetBand, trgRect); final ProductData rawSamples = sourceTile.getRawSamples(); info.productWriter.writeBandRasterData(targetBand, trgRect.x, trgRect.y, trgRect.width, trgRect.height, rawSamples, ProgressMonitor.NULL); } catch (Exception e) { if (e instanceof OperatorException) { throw (OperatorException) e; } else { throw new OperatorException(e); } } } if(!projectedDEMWritten) { writeProjectedDEM(); } }
throw new OperatorException("No data product writer for the '" + formatName + "' format available"); subsetInfo.productWriter.setFormatName(formatName); subsetInfo.productWriter.setIncrementalMode(false); targetProduct.setProductWriter(subsetInfo.productWriter);
private synchronized void writeHeader(final WriterInfo info) throws Exception { if (info.written) return; final File outputFile = targetFolder.toPath().resolve(info.folderName).resolve(info.targetBandName + ".par").toFile(); info.productWriter.writeProductNodes(info.product, outputFile); if (info.folderName.equals("diff0")) { writeBaselineFile(info); } info.written = true; }
private synchronized void writeTile(final SubsetInfo info, final Rectangle trgRect) throws IOException { if (info.written) return; for(Band trgBand : info.subsetProduct.getBands()) { final String oldBandName = info.newBandNamingMap.get(trgBand.getName()); final Tile sourceTile = getSourceTile(sourceProduct.getBand(oldBandName), trgRect); final ProductData rawSamples = sourceTile.getRawSamples(); //final String newBandName = StackUtils.getBandNameWithoutDate(bandName); info.productWriter.writeBandRasterData(trgBand, 0, 0, trgBand.getRasterWidth(), trgBand.getRasterHeight(), rawSamples, ProgressMonitor.NULL); } info.written = true; }
@Override public void dispose() { try { for (SubsetInfo info : subsetInfo) { info.productWriter.close(); } } catch (IOException ignore) { } todoLists.clear(); super.dispose(); }
@Override public void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException { try { final SubsetInfo subsetInfo = bandMap.get(targetBand); if(subsetInfo == null) return; subsetInfo.productWriter.writeProductNodes(subsetInfo.subsetProduct, subsetInfo.file); final Rectangle trgRect = subsetInfo.subsetBuilder.getSubsetDef().getRegion(); if (!subsetInfo.written) { writeTile(subsetInfo, trgRect); } } catch (Exception e) { if (e instanceof OperatorException) { throw (OperatorException) e; } else { throw new OperatorException(e); } } }
private synchronized void writeTile(final SubsetInfo info, final String bandName, final Rectangle trgRect) throws IOException { final Tile sourceTile = getSourceTile(sourceProduct.getBand(bandName), trgRect); final ProductData rawSamples = sourceTile.getRawSamples(); final Band trgBand = info.product.getBand(bandName); info.productWriter.writeBandRasterData(trgBand, 0, 0, trgBand.getRasterWidth(), trgBand.getRasterHeight(), rawSamples, ProgressMonitor.NULL); }
@Override public void dispose() { try { if(subsetInfo != null) { if(subsetInfo.productWriter != null) { subsetInfo.productWriter.close(); } } } catch (IOException ignore) { } super.dispose(); }
private void markTileDone(Band targetBand, Tile targetTile) throws IOException { boolean done; synchronized (todoLists) { MultiLevelImage sourceImage = targetBand.getSourceImage(); final List<Point> currentTodoList = getTodoList(sourceImage); currentTodoList.remove(new Point(sourceImage.XToTileX(targetTile.getMinX()), sourceImage.YToTileY(targetTile.getMinY()))); done = isDone(); } if (done) { // If we get here all tiles are written for (SubsetInfo info : subsetInfo) { if (info.productWriter instanceof DimapProductWriter) { // if we can update the header (only DIMAP) rewrite it! synchronized (info.productWriter) { info.productWriter.writeProductNodes(info.product, info.file); } } } } }
@Override public synchronized void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException { try { writeHeader(subsetInfo); final Rectangle trgRect = targetTile.getRectangle(); final Tile sourceTile = getSourceTile(sourceProduct.getBand(targetBand.getName()), trgRect); final ProductData rawSamples = sourceTile.getRawSamples(); subsetInfo.productWriter.writeBandRasterData(targetBand, trgRect.x, trgRect.y, trgRect.width, trgRect.height, rawSamples, ProgressMonitor.NULL); } catch (Exception e) { if (e instanceof OperatorException) { throw (OperatorException) e; } else { throw new OperatorException(e); } } }
@Override public void dispose() { try { for (WriterInfo info : tgtBandToInfoMap.values()) { if (info != null) { if (info.productWriter != null) { info.productWriter.close(); info.productWriter = null; } } } } catch (IOException ignore) { } super.dispose(); }
@Override public void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException { try { synchronized (this) { if (!productFileWritten) { for (SubsetInfo info : subsetInfo) { info.productWriter.writeProductNodes(info.product, info.file); } productFileWritten = true; } } final Rectangle rect = targetTile.getRectangle(); for (SubsetInfo info : subsetInfo) { final Rectangle trgRect = info.subsetBuilder.getSubsetDef().getRegion(); if (rect.intersects(trgRect)) { writeTile(info, targetBand.getName(), trgRect); } } markTileDone(targetBand, targetTile); } catch (Exception e) { if (e instanceof OperatorException) { throw (OperatorException) e; } else { throw new OperatorException(e); } } }