@Test public void testManyTilesTwoBands() { Product sourceProduct = createSourceProduct(); Band bandB = sourceProduct.addBand("b", ProductData.TYPE_INT8); bandB.setRasterData(createDataFor(bandB)); bandB.setSynthetic(true); sourceProduct.setPreferredTileSize(50, 50); Operator op = new TestOP(sourceProduct); OperatorExecutor operatorExecutor = OperatorExecutor.create(op); operatorExecutor.execute(ProgressMonitor.NULL); assertEquals(17, recordingTileScheduler.recordedCalls.size()); assertEquals(8, recordingTileScheduler.requestedTileIndices.size()); assertEquals(new Point(0, 0), recordingTileScheduler.requestedTileIndices.get(0)); assertEquals(new Point(1, 0), recordingTileScheduler.requestedTileIndices.get(1)); assertEquals(new Point(0, 0), recordingTileScheduler.requestedTileIndices.get(2)); assertEquals(new Point(1, 0), recordingTileScheduler.requestedTileIndices.get(3)); assertEquals(new Point(0, 1), recordingTileScheduler.requestedTileIndices.get(4)); assertEquals(new Point(1, 1), recordingTileScheduler.requestedTileIndices.get(5)); assertEquals(new Point(0, 1), recordingTileScheduler.requestedTileIndices.get(6)); assertEquals(new Point(1, 1), recordingTileScheduler.requestedTileIndices.get(7)); }
private Product createSourceProduct() { Product product = new Product("source", "source", 100, 100); Band bandA = product.addBand("a", ProductData.TYPE_INT8); bandA.setRasterData(createDataFor(bandA)); bandA.setSynthetic(true); return product; }
@Test public void testManyTilesTwoBands_ColumnBandOrder() { Product sourceProduct = createSourceProduct(); Band bandB = sourceProduct.addBand("b", ProductData.TYPE_INT8); bandB.setRasterData(createDataFor(bandB)); bandB.setSynthetic(true); sourceProduct.setPreferredTileSize(50, 50); Operator op = new TestOP(sourceProduct); OperatorExecutor operatorExecutor = OperatorExecutor.create(op); operatorExecutor.execute(OperatorExecutor.ExecutionOrder.SCHEDULE_ROW_COLUMN_BAND, ProgressMonitor.NULL); assertEquals(13, recordingTileScheduler.recordedCalls.size()); assertEquals(4, recordingTileScheduler.requestedTileIndices.size()); assertEquals(new Point(0, 0), recordingTileScheduler.requestedTileIndices.get(0)); assertEquals(new Point(1, 0), recordingTileScheduler.requestedTileIndices.get(1)); assertEquals(new Point(0, 1), recordingTileScheduler.requestedTileIndices.get(2)); assertEquals(new Point(1, 1), recordingTileScheduler.requestedTileIndices.get(3)); }
private static void addGeoPosBands(Product product, ElevationModel dem, String latitudeBandName, String longitudeBandName) { final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); final Orthorectifier orthorectifier = new Orthorectifier2(width, height, product.getBandAt(0).getPointing(), dem, 25); final Band latitudeBand = product.addBand(latitudeBandName, ProductData.TYPE_FLOAT32); latitudeBand.setSynthetic(true); latitudeBand.setNoDataValue(Double.NaN); latitudeBand.setUnit("deg"); latitudeBand.setDescription("DEM-corrected latitude"); latitudeBand.setSourceImage(createLatitudeSourceImage(orthorectifier, latitudeBand)); final Band longitudeBand = product.addBand(longitudeBandName, ProductData.TYPE_FLOAT32); longitudeBand.setSynthetic(true); longitudeBand.setNoDataValue(Double.NaN); longitudeBand.setUnit("deg"); longitudeBand.setDescription("DEM-corrected longitude"); longitudeBand.setSourceImage(createLongitudeSourceImage(orthorectifier, longitudeBand)); }
private static void addElevationBand(Product product, ElevationModel dem, String elevationBandName) { final GeoCoding geoCoding = product.getGeoCoding(); ElevationModelDescriptor demDescriptor = dem.getDescriptor(); final float noDataValue = dem.getDescriptor().getNoDataValue(); final Band elevationBand = product.addBand(elevationBandName, ProductData.TYPE_INT16); elevationBand.setSynthetic(true); elevationBand.setNoDataValue(noDataValue); elevationBand.setUnit("m"); elevationBand.setDescription(demDescriptor.getName()); elevationBand.setSourceImage(createElevationSourceImage(dem, geoCoding, elevationBand)); }
@Test public void testCreateTransectProfileText_Float() throws IOException { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_FLOAT32); node.setSynthetic(true); final float[] data = new float[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, 1.0f); data[0] = Float.NaN; // no data node.setData(ProductData.createInstance(data)); final Line2D.Float shape = new Line2D.Float(0.5f, 0.5f, 1.5f, 0.5f); final TransectProfileData profileData = node.createTransectProfileData(shape); final String profileDataString = StatisticsUtils.TransectProfile.createTransectProfileText(node, profileData); assertTrue(profileDataString.contains("NaN")); assertFalse(profileDataString.toLowerCase().contains("no data")); } }
@Test public void testCreateTransectProfileText_Byte() throws IOException { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_INT8); node.setSynthetic(true); node.setNoDataValue(0); node.setNoDataValueUsed(true); final byte[] data = new byte[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, (byte) 1); data[0] = 0; // no data node.setData(ProductData.createInstance(data)); final Line2D.Float shape = new Line2D.Float(0.5f, 0.5f, 1.5f, 0.5f); final TransectProfileData profileData = node.createTransectProfileData(shape); final String profileDataString = StatisticsUtils.TransectProfile.createTransectProfileText(node, profileData); assertTrue(profileDataString.contains("NaN")); assertFalse(profileDataString.toLowerCase().contains("no data")); }
@Test public void testGetPixelString_Float() { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_FLOAT32); node.setSynthetic(true); final float[] data = new float[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, 1.0f); data[0] = Float.NaN; // no data node.setData(ProductData.createInstance(data)); assertEquals("NaN", node.getPixelString(0, 0)); assertEquals("1.0", node.getPixelString(1, 0)); }
private void createSourceProduct() throws Exception { sourceProduct = new Product("source", "t", 50, 50); final TiePointGrid latGrid = new TiePointGrid("latGrid", 2, 2, 0.5f, 0.5f, 49, 49, LATS); final TiePointGrid lonGrid = new TiePointGrid("lonGrid", 2, 2, 0.5f, 0.5f, 49, 49, LONS); sourceProduct.addTiePointGrid(latGrid); sourceProduct.addTiePointGrid(lonGrid); sourceProduct.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid)); sourceProduct.setStartTime(ProductData.UTC.parse("02-Jan-2008 10:15:10")); sourceProduct.setEndTime(ProductData.UTC.parse("02-Jan-2008 10:45:50")); Band floatDataBand = sourceProduct.addBand(FLOAT_BAND_NAME, ProductData.TYPE_FLOAT32); floatDataBand.setRasterData(createDataFor(floatDataBand)); floatDataBand.setSynthetic(true); Band intDataBand = sourceProduct.addBand(INT_BAND_NAME, ProductData.TYPE_INT16); intDataBand.setRasterData(createDataFor(intDataBand)); intDataBand.setSynthetic(true); }
@Test public void testGetPixelString_Byte() { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_INT8); node.setSynthetic(true); node.setNoDataValue(0); node.setNoDataValueUsed(true); final byte[] data = new byte[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, (byte) 1); data[0] = 0; // no data node.setData(ProductData.createInstance(data)); assertEquals("NaN", node.getPixelString(0, 0)); assertEquals("1", node.getPixelString(1, 0)); }