@Override protected Product doInBackground() throws Exception { for (String inputPath : inputPaths) { if (inputPath == null || inputPath.trim().length() == 0) { continue; } try { final TreeSet<File> fileSet = new TreeSet<>(); WildcardMatcher.glob(inputPath, fileSet); for (File file : fileSet) { final Product product = ProductIO.readProduct(file); if (product != null) { return product; } } } catch (IOException e) { Logger logger = SystemUtils.LOG; logger.severe("I/O problem occurred while scanning source product files: " + e.getMessage()); } } return null; }
private Product openFirstProduct(String[] inputPaths) { if (inputPaths != null) { final Logger logger = SystemUtils.LOG; for (String inputPath : inputPaths) { if (inputPath == null || inputPath.trim().length() == 0) { continue; } try { final TreeSet<File> fileSet = new TreeSet<>(); WildcardMatcher.glob(inputPath, fileSet); for (File file : fileSet) { final Product product = ProductIO.readProduct(file); if (product != null) { return product; } } } catch (IOException e) { logger.severe("I/O problem occurred while scanning source product files: " + e.getMessage()); } } } return null; }
public static void main(String[] args) throws Exception { final JFrame jFrame = new JFrame("Output parameter Definition Form"); Container contentPane = jFrame.getContentPane(); if (args.length == 0) { throw new IllegalArgumentException("Missing argument to product file."); } Product sourceProduct = ProductIO.readProduct(args[0]); CoordinateReferenceSystem targetCrs = CRS.decode("EPSG:32632"); OutputGeometryFormModel model = new OutputGeometryFormModel(sourceProduct, targetCrs); OutputGeometryForm form = new OutputGeometryForm(model); contentPane.add(form); jFrame.setSize(400, 600); jFrame.setLocationRelativeTo(null); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jFrame.setVisible(true); } }); } }
@Override protected void addGeoCoding(final Product product) { try { Product imageProduct = ProductIO.readProduct(imageFile); if (imageProduct != null) { product.setSceneGeoCoding(imageProduct.getSceneGeoCoding()); } } catch (IOException e) { //e.printStackTrace(); } }
@Override protected Product doInBackground() throws Exception { Product product = null; try { defaultCursor = window.getCursor(); window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); file = chooser.getSelectedFile(); product = ProductIO.readProduct(file); } catch (IOException e) { handleError(e.getMessage()); } return product; }
/** * Get GIM product. */ private void getGIMProduct() { try { if(sourceProduct.getFileLocation() == null) { useIncidenceAngleFromGIM = false; return; } File sourceGIMFile = new File(sourceProduct.getFileLocation().getParentFile(), "AUXRASTER" + File.separator + "GIM.tif"); if (sourceGIMFile.exists()) { sourceGIMProduct = ProductIO.readProduct(sourceGIMFile); } else { useIncidenceAngleFromGIM = false; } } catch (Exception e) { throw new OperatorException("TerraSARXCalibrator: " + e); } }
return ProductIO.readProduct(newFile[0]); } catch (IOException e) {
Product product = sourceProductMap.get(file); if (product == null) { product = ProductIO.readProduct(file); sourceProductMap.put(file, product); if (Boolean.TRUE.equals(getPropertyValue(PROPERTY_SHOW_SOURCE_PRODUCTS))) {
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(); } } } } }
@Override public void run() { try { ph.start(); ph.switchToIndeterminate(); Product product = ProductIO.readProduct(file, formatName); boolean interrupted = Thread.interrupted(); if (!interrupted) { if (product == null) { SwingUtilities.invokeLater( () -> Dialogs.showError(Bundle.LBL_NoReaderFoundText() + String.format("%nFile '%s' can not be opened.", file))); } else { OpenProductAction.getRecentProductPaths().add(file.getPath()); SwingUtilities.invokeLater(() -> SnapApp.getDefault().getProductManager().addProduct(product)); } } } catch (IOException problem) { SwingUtilities.invokeLater(() -> Dialogs.showError(Bundle.CTL_OpenProductActionName(), problem.getMessage())); } finally { ph.finish(); } }
product = ProductIO.readProduct(productFile);
Product previousExternalMaskProduct = null; if (this.currentProductSourceMaskFile != null) { currentExternalMaskProduct = ProductIO.readProduct(this.currentProductSourceMaskFile); if (currentExternalMaskProduct.getNumBands() != 1) { throw new IllegalArgumentException("The current mask product '"+currentExternalMaskProduct.getName()+"' must contain only one raster."); previousExternalMaskProduct = ProductIO.readProduct(this.previousProductSourceMaskFile); if (previousExternalMaskProduct.getNumBands() != 1) { throw new IllegalArgumentException("The previous mask product '"+previousExternalMaskProduct.getName()+"' must contain only one raster.");
GPF.writeProduct(operatorTargetProduct, targetFile, formatName, false, false, ProgressMonitor.NULL); productToReturn = ProductIO.readProduct(targetFile);
private static BufferedImage getImage(final ProductEntry productEntry) { if (productEntry.quickLookExists()) { final Quicklook quicklook = productEntry.getQuickLook(); if (!quicklook.hasProduct() && !quicklook.hasCachedImage() && quicklook.getProductFile() != null) { try { quicklook.setProduct(ProductIO.readProduct(quicklook.getProductFile())); } catch (IOException e) { SystemUtils.LOG.warning("Quicklook unable to load product " + quicklook.getProductFile()); } } return quicklook.getImage(ProgressMonitor.NULL); } return null; }
@Override protected void prepareInputs() throws OperatorException { super.prepareInputs(); final Product sourceProduct = getSourceProduct(); ensureSingleRasterSize(sourceProduct); sceneGeoCoding = sourceProduct.getSceneGeoCoding(); final double mjd = sourceProduct.getStartTime().getMJD(); int dayOfYear = ((int)(mjd % 365.25)) + 1; try { Product climatologiesProduct = null; try { if (StringUtils.isNotNullAndNotEmpty(climatologiesFile)) { climatologiesProduct = ProductIO.readProduct(climatologiesFile); } } catch(IOException e) { climatologiesProduct = null; } aerosolTypeProvider = new AerosolTypeProvider(dayOfYear, climatologiesProduct); } catch (IOException e) { throw new OperatorException("Could not determine aerosol type: " + e.getMessage()); } }
product = ProductIO.readProduct(file); if(!product.isMultiSize()){ atLeastOneUniSizeProduct = true;
product = ProductIO.readProduct(targetFile); if (product == null) { product = this.targetProduct; // todo - check - this cannot be ok!!! (nf)
targetFile = targetProduct.getFileLocation(); if (targetFile.exists()) { product = ProductIO.readProduct(targetFile); if (product == null) {
final FileFilter fileFilter = getFileFilter(); String formatName = (fileFilter instanceof SnapFileFilter) ? ((SnapFileFilter) fileFilter).getFormatName() : null; product = ProductIO.readProduct(file, formatName); if(product == null) { String msg = "The product could not be read.";
for (BandMetadata aBandMetadataList : bandMetadataList) { String imageFileName = aBandMetadataList.getImageFileName(); this.tiffProduct.add(ProductIO.readProduct(Paths.get(dirPath).resolve(dirName).resolve(imageFileName + Kompsat2Constants.IMAGE_EXTENSION).toFile())); this.tiffImageIndex++; Band band = this.tiffProduct.get(this.tiffImageIndex - 1).getBandAt(0);