// Retrieves the output product name from request private String getOutputProductNameSafe() throws ProcessorException { Request request = getRequest(); ProductRef prod = request.getOutputProductAt(0); if (prod == null) { throw new ProcessorException(ProcessorConstants.LOG_MSG_NO_OUTPUT_IN_REQUEST); } File prodFile = new File(prod.getFilePath()); return FileUtils.getFilenameWithoutExtension(prodFile); }
// Creates the output product for the given request. private void createOutputProduct(ProgressMonitor pm) throws IOException, ProcessorException { // take only the first output product. There might be more but we will ignore // these in SMAC. ProductRef prod = getRequest().getOutputProductAt(0); checkParamNotNull(prod, "output product"); String productType = _inputProduct.getProductType() + "_SMAC"; String productName = getOutputProductNameSafe(); int sceneWidth = _inputProduct.getSceneRasterWidth(); int sceneHeight = _inputProduct.getSceneRasterHeight(); _outputProduct = new Product(productName, productType, sceneWidth, sceneHeight); ProductWriter writer = ProcessorUtils.createProductWriter(prod); _outputProduct.setProductWriter(writer); // loop over bands and create them // ------------------------------- if (ObjectUtils.equalObjects(_sensorType, SensorCoefficientManager.MERIS_NAME)) { addBandsToOutput("Atmosphere corrected MERIS band ", true); } else { addBandsToOutput("Atmosphere corrected band "); } ProductUtils.copyTiePointGrids(_inputProduct, _outputProduct); copyRequestMetaData(_outputProduct); copyFlagBands(_inputProduct, _outputProduct); // for MERIS FSG / FRG products copyBand( EnvisatConstants.MERIS_AMORGOS_L1B_CORR_LATITUDE_BAND_NAME, _inputProduct, _outputProduct); copyBand( EnvisatConstants.MERIS_AMORGOS_L1B_CORR_LONGITUDE_BAND_NAME, _inputProduct, _outputProduct); copyBand(EnvisatConstants.MERIS_AMORGOS_L1B_ALTIUDE_BAND_NAME, _inputProduct, _outputProduct); copyGeoCoding(_inputProduct, _outputProduct); // and initialize the disk represenation writer.writeProductNodes(_outputProduct, new File(prod.getFilePath())); copyBandData(getBandNamesToCopy(), _inputProduct, _outputProduct, pm); }