@Override public void visit(Product product) { if (product == event.getSourceNode()) { product.setFileLocation(null); } }
@Override protected Object doInBackground() throws Exception { final boolean incremental = false; final boolean successfullySaved = saveProductImpl(product, incremental); if (successfullySaved) { if (!isVisatExitConfirmed()) { reopenProduct(product, newFile); } } if (!successfullySaved) { product.setFileLocation(oldFile); product.setName(oldProductName); } return null; }
protected static Product createTestProduct(String name, String type) { Product product = new Product(name, type, 10, 10); product.setFileLocation(new File(String.format("out/%s.dim", name))); return product; }
static Product createProduct(int refNo, String name, String type, int w, int h) { final Product product = new Product(name, type, w, h); product.setRefNo(refNo); final File file = new File(new File(createSessionRootURI()), "out/DIMAP/" + name + ".dim"); product.setFileLocation(file); return product; }
private void handleRadianceProduct(Product product) { Product hicoProductPart = hicoProductParts.get(FileType.RAD); if (hicoProductPart != null) { copyMetadata(hicoProductPart, product, FileType.RAD.toString()); String[] bandNames = hicoProductPart.getBandNames(); for (String bandName : bandNames) { String[] bandNameSplit = bandName.split("_"); String newBandname = "radiance_" + bandNameSplit[1]; Band band = ProductUtils.copyBand(bandName, hicoProductPart, newBandname, product, true); band.setScalingFactor(1.0 / 50.0); band.setSpectralBandwidth(5.7f); } product.setAutoGrouping("radiance"); product.setFileLocation(hicoProductPart.getFileLocation()); } }
@Override protected Product readProductNodesImpl() throws IOException { final AbstractNetCdfReaderPlugIn plugIn = getReaderPlugIn(); final File fileLocation = new File(getInput().toString()); netcdfFile = NetcdfFileOpener.open(fileLocation.getPath()); if (netcdfFile == null) { throw new IOException("Failed to open file " + fileLocation.getPath()); } final ProfileReadContext context = new ProfileReadContextImpl(netcdfFile); String filename = extractProductName(fileLocation); context.setProperty(Constants.PRODUCT_FILENAME_PROPERTY, filename); plugIn.initReadContext(context); NetCdfReadProfile profile = new NetCdfReadProfile(); configureProfile(plugIn, profile); final Product product = profile.readProduct(context); product.setFileLocation(fileLocation); product.setProductReader(this); product.setModified(false); return product; }
private void initProduct() { final File productFile = new File(getInput().toString()); final String productName = FileUtils.getFilenameWithoutExtension(productFile); String productType = "BINNED"; Attribute titleAttribute = netcdfFile.findGlobalAttribute("title"); if (titleAttribute != null) { productType = titleAttribute.getStringValue(); } product = new Product(productName, productType, sceneRasterWidth, sceneRasterHeight, this); product.setFileLocation(productFile); product.setAutoGrouping("adg:aph:atot:bbp:bl_Rrs:chlor_a:Rrs:water"); product.setStartTime(extractStartTime(netcdfFile)); product.setEndTime(extractEndTime(netcdfFile)); product.setPreferredTileSize(sceneRasterWidth, 64); }
Product createProduct() throws IOException, IllegalCeosFormatException { final Product product = new Product(volumeDirectoryFile.getProductName(), getProductType(), sceneWidth, sceneHeight); product.setFileLocation(baseDir); imageFileMap = new HashMap<Band, Avnir2ImageFile>(imageFiles.length); for (final Avnir2ImageFile avnir2ImageFile : imageFiles) { Band band = createBand(avnir2ImageFile); product.addBand(band); imageFileMap.put(band, avnir2ImageFile); } product.setStartTime(getScanTimeUTC(0)); product.setEndTime(getScanTimeUTC(sceneHeight - 1)); product.setDescription(getProductDescription()); addGeoCoding(product); addMetaData(product); return product; }
@Before public void setup() { Product product = new Product("P", "T", 10, 10); product.setFileLocation(new File(String.format("out/%s.dim", product.getName()))); band = new VirtualBand("V", ProductData.TYPE_INT32, 10, 10, "42"); product.addBand(band); productManager = new ProductManager(); productManager.addProduct(product); }
private Product createProduct(File inputFile) { final String name = FileUtils.getFilenameWithoutExtension(inputFile); final String type = "CHRIS_M" + chrisFile.getGlobalAttribute(ChrisConstants.ATTR_NAME_CHRIS_MODE, 0); final Product product = new Product(name, type, sceneRasterWidth, sceneRasterHeight, this); product.setFileLocation(chrisFile.getFile()); setStartAndEndTimes(product); addMetadataElements(product); addRciAndMaskBands(product); addFlagCodingsAndMasks(product); // due to mask refinement the preferred tile size has full size product.setPreferredTileSize(sceneRasterWidth, sceneRasterHeight); return product; }
Product readGeoTIFFProduct(final ImageInputStream stream, final File inputFile) throws IOException { imageReader = BigGeoTiffProductReaderPlugIn.getTiffImageReader(stream); if (imageReader == null) { throw new IOException("GeoTiff imageReader not found"); } imageReader.setInput(stream); Product product = null; final TIFFImageMetadata imageMetadata = (TIFFImageMetadata) imageReader.getImageMetadata(FIRST_IMAGE); final TIFFIFD rootIFD = imageMetadata.getRootIFD(); final TiffFileInfo tiffFileInfo = new TiffFileInfo(rootIFD); final TIFFField field = tiffFileInfo.getField(Constants.PRIVATE_BEAM_TIFF_TAG_NUMBER); if (isAsciiField(field) && isDimapField(field)) { product = createProductWithDimapHeader(field); } if (product == null) { product = createProduct(inputFile, tiffFileInfo); } product.setFileLocation(inputFile); if (tiffFileInfo.isGeotiff()) { applyGeoCoding(tiffFileInfo, imageMetadata, product); } TiffToProductMetadataConverter.addTiffTagsToMetadata(imageMetadata, tiffFileInfo, product.getMetadataRoot()); return product; }
/** * Creates a product from the product file. */ private Product createProduct() { String productName = _file.getFileName(); productName = StringUtils.createValidName(productName, new char[]{'.', '_'}, '_'); Product prodRet = new Product(productName, _file.getSensorType(), AtsrConstants.ATSR_SCENE_RASTER_WIDTH, AtsrConstants.ATSR_SCENE_RASTER_HEIGHT, this); prodRet.setFileLocation(_file.getFile()); // add all metadata if required // ---------------------------- if (!isMetadataIgnored()) { // add the metadata addMetadata(prodRet); // add the tie point grids addTiePointGrids(prodRet); addGeoCoding(prodRet); } // add the bands to the product addBandsToProduct(prodRet); addActiveFireBitmaskDefs(prodRet); return prodRet; }
/** * Creates a new product with all necessary elements (bands, geocoding, RGB-expression, metadata) */ private void initReader() { final LandsatHeader landsatHeader = landsatTM.getHeader(); final int height = landsatHeader.getImageHeight(); final int width = landsatHeader.getImageWidth(); final String formatName = landsatTM.getProductName(); final UTC startTime = landsatHeader.getAcquisitionDate(); product = new Product(formatName + " " + landsatHeader.getRawDate(), formatName, width, height, this); // @todo 3 tb/** make distinction between landsat 5 and 7 files product.setDescription(LANDSAT_TM_PRODUCT); product.setFileLocation(inputFile); product.setStartTime(startTime); product.setModified(false); addBands(landsatHeader, height, width, formatName); setMapGeoCoding(); setMetadata(); }
@Override public Product createProduct() throws ProductIOException { //todo figure out if we even need these... addGlobalAttributeSeadasMapped(); int sceneWidth = getIntAttribute("Scene_Pixels"); int sceneHeight = getIntAttribute("Scene_Lines"); String productName = getStringAttribute("Product_Name"); SeadasProductReader.ProductType productType = productReader.getProductType(); Product product = new Product(productName, productType.toString(), sceneWidth, sceneHeight); product.setDescription(productName); product.setFileLocation(productReader.getInputFile()); product.setProductReader(productReader); addGlobalMetadata(product); variableMap = addBands(product, ncFile.getVariables()); addGeocoding(product); return product; }
Product createProduct() throws IOException, IllegalCeosFormatException { final String productName = leaderFile.getProductName(); final String productType = leaderFile.getProductType(); int width = 0; final int overlap = imageFiles.length > 1 ? 32 : 0; for (final PrismImageFile imageFile : imageFiles) { width += imageFile.getWidth() - overlap; } final int sceneWidth = width; final int sceneHeight = leaderFile.getSceneHeight(); final Product product = new Product(productName, productType, sceneWidth, sceneHeight); product.setFileLocation(baseDir); addBand(product); product.setStartTime(getScanTimeUTC(0)); product.setEndTime(getScanTimeUTC(sceneHeight - 1)); product.setDescription("PRISM product Level " + productType); addGeoCoding(product); addMetadataTo(product); return product; }
@Test public void testExpressionIsChangedIfANodeNameIsChanged() { final Product product = new Product("p", "t", 10, 10); final VirtualBand virtualBand = new VirtualBand("vb", ProductData.TYPE_FLOAT32, 10, 10, "band1 + band2 - band3"); final File fileLocation = new File("dummy.dim"); product.setFileLocation(fileLocation); product.addBand(virtualBand); product.addBand("band1", ProductData.TYPE_FLOAT32); product.addBand("band2", ProductData.TYPE_FLOAT32); product.addBand("band3", ProductData.TYPE_FLOAT32); product.getBand("band1").setName("b1"); assertEquals("Name 'band1' is not changed", "b1 + band2 - band3", virtualBand.getExpression()); assertSame(fileLocation, product.getFileLocation()); }
@Test public void testNewProductIsNotDisposed() throws Exception { SourceProductSelector selector = new SourceProductSelector(appContext, "Source"); selector.initProducts(); selector.setSelectedProduct(defaultProducts[0]); Assert.assertSame(defaultProducts[0], selector.getSelectedProduct()); Product newProduct = new Product("new", "T1", 0, 0); newProduct.setFileLocation(new File("")); selector.setSelectedProduct(newProduct); Assert.assertSame(newProduct, selector.getSelectedProduct()); Assert.assertNotNull(newProduct.getFileLocation()); selector.releaseProducts(); Assert.assertNotNull(newProduct.getFileLocation()); // assert that new product is not disposed while it is selected }
@Test public void testNewProductIsDisposed() throws Exception { SourceProductSelector selector = new SourceProductSelector(appContext, "Source"); selector.initProducts(); Product newProduct = new Product("new", "T1", 0, 0); newProduct.setFileLocation(new File("")); selector.setSelectedProduct(newProduct); Assert.assertSame(newProduct, selector.getSelectedProduct()); selector.setSelectedProduct(defaultProducts[0]); Assert.assertSame(defaultProducts[0], selector.getSelectedProduct()); Assert.assertNotNull(newProduct.getFileLocation()); selector.releaseProducts(); Assert.assertNull(newProduct.getFileLocation()); // assert that new product is disposed, because it is not selected }
product.setFileLocation(productReader.getInputFile()); product.setProductReader(productReader);
@Test public void testSetSelectedProduct() throws Exception { SourceProductSelector selector = new SourceProductSelector(appContext, "Source"); selector.initProducts(); Product selectedProduct = selector.getSelectedProduct(); Assert.assertSame(appContext.getSelectedProduct(), selectedProduct); selector.setSelectedProduct(defaultProducts[1]); selectedProduct = selector.getSelectedProduct(); Assert.assertSame(defaultProducts[1], selectedProduct); Product oldProduct = new Product("new", "T1", 0, 0); oldProduct.setFileLocation(new File("")); selector.setSelectedProduct(oldProduct); selectedProduct = selector.getSelectedProduct(); Assert.assertSame(oldProduct, selectedProduct); Product newProduct = new Product("new", "T2", 0, 0); selector.setSelectedProduct(newProduct); selectedProduct = selector.getSelectedProduct(); Assert.assertSame(newProduct, selectedProduct); Assert.assertNull(oldProduct.getFileLocation()); // assert that old product is disposed }