@Test public void testReadBandRasterData() { Date startDate = Calendar.getInstance().getTime(); // Product product = new Product("name", "desc", 100, 200); File file = TestUtil.getTestFile( productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP"); // File rasterFile = TestUtil.getTestFile(productsFolder + "mediumImage.tif"); System.setProperty("snap.dataio.reader.tileWidth", "100"); System.setProperty("snap.dataio.reader.tileHeight", "200"); try { Product finalProduct = reader.readProductNodes(file, null); ProductData data = ProductData.createInstance(ProductData.TYPE_UINT16, 20000); data.setElemFloatAt(3, 5); reader.readBandRasterData( finalProduct.getBandAt(0), 2000, 2000, 100, 200, data, new NullProgressMonitor()); assertNotEquals(0, data.getElemFloatAt(0)); assertNotEquals(-1000, data.getElemFloatAt(0)); assertNotEquals(0, data.getElemFloatAt(1999)); assertNotEquals(-1000, data.getElemFloatAt(1999)); assertNotEquals(5, data.getElemFloatAt(3)); Date endDate = Calendar.getInstance().getTime(); assertTrue( "The load time for the product is too big!", (endDate.getTime() - startDate.getTime()) / (60 * 1000) < 30); } catch (IOException e) { e.printStackTrace(); assertTrue(e.getMessage(), false); } }
@Test public void testReadProductNodes() { Date startDate = Calendar.getInstance().getTime(); Product product = new Product("name", "desc", 100, 100); File file = TestUtil.getTestFile( productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP"); System.setProperty("snap.dataio.reader.tileWidth", "100"); System.setProperty("snap.dataio.reader.tileHeight", "100"); try { Product finalProduct = reader.readProductNodes(file, null); assertEquals(4, finalProduct.getBands().length); assertEquals("WGS84(DD)", finalProduct.getSceneGeoCoding().getGeoCRS().getName().toString()); assertEquals("SPOTView", finalProduct.getProductType()); assertEquals(0, finalProduct.getMaskGroup().getNodeCount()); assertEquals(2713, finalProduct.getSceneRasterWidth()); assertEquals(2568, finalProduct.getSceneRasterHeight()); Date endDate = Calendar.getInstance().getTime(); assertTrue( "The load time for the product is too big!", (endDate.getTime() - startDate.getTime()) / (60 * 1000) < 30); } catch (IOException e) { e.printStackTrace(); assertTrue(e.getMessage(), false); } }
@Test public void testGetProductComponentsOnFileInput() { File file = TestUtil.getTestFile( productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL/metadata.xml"); System.setProperty("snap.dataio.reader.tileWidth", "100"); System.setProperty("snap.dataio.reader.tileHeight", "100"); try { reader.readProductNodes(file, null); TreeNode<File> components = reader.getProductComponents(); assertEquals(3, components.getChildren().length); String[] expectedIds = new String[] {"metadata.dim", "metadata.xml", "geolayer.bil"}; int componentsAsExpected = 0; for (TreeNode<File> component : components.getChildren()) { for (String expectedValue : expectedIds) { if (component.getId().toLowerCase().equals(expectedValue.toLowerCase())) { componentsAsExpected++; } } } assertEquals(3, componentsAsExpected); } catch (IOException e) { e.printStackTrace(); assertTrue(e.getMessage(), false); } }
@Test public void testGetProductComponentsOnArchiveInput() { File file = TestUtil.getTestFile( productsFolder + "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP"); System.setProperty("snap.dataio.reader.tileWidth", "100"); System.setProperty("snap.dataio.reader.tileHeight", "100"); try { reader.readProductNodes(file, null); TreeNode<File> components = reader.getProductComponents(); assertEquals(1, components.getChildren().length); assertEquals( "SP04_HRI1_X__1O_20050605T090007_20050605T090016_DLR_70_PREU.BIL.ZIP", components.getChildren()[0].getId()); } catch (IOException e) { e.printStackTrace(); assertTrue(e.getMessage(), false); } }