/** * Adds all tie point grids the the product */ private void addTiePointGrids(Product prodRet) { for (int n = 0; n < _file.getNumTiePointGrids(); n++) { prodRet.addTiePointGrid(_file.getTiePointGridAt(n)); } }
private TiePointGrid addTiePointGrid(Product product, String name, String units, int height, float[] data, int discontinuity) { final TiePointGrid grid = new TiePointGrid(name, TIE_POINT_GRID_WIDTH, height, TIE_POINT_OFFSET_X + 0.5f, 0.5f, TIE_POINT_SAMPLING_X, 1, data, discontinuity); grid.setUnit(units); product.addTiePointGrid(grid); return grid; }
/** * Copies all tie point grids from one product to another. * * @param sourceProduct the source product * @param targetProduct the target product */ public static void copyTiePointGrids(Product sourceProduct, Product targetProduct) { for (int i = 0; i < sourceProduct.getNumTiePointGrids(); i++) { TiePointGrid srcTPG = sourceProduct.getTiePointGridAt(i); targetProduct.addTiePointGrid(srcTPG.cloneTiePointGrid()); } }
private void addTiePointGridsToProduct(Product product) throws IOException { BandLineReader[] bandLineReaders = getProductFile().getBandLineReaders(); for (BandLineReader bandLineReader : bandLineReaders) { if (bandLineReader.isTiePointBased()) { TiePointGrid tiePointGrid = createTiePointGrid(bandLineReader); product.addTiePointGrid(tiePointGrid); } } }
private static void addTiePointGrids(Product product) { final int sceneRasterWidth = product.getSceneRasterWidth(); final int sceneRasterHeight = product.getSceneRasterHeight(); product.addTiePointGrid(createTiePointGrid("tpg1", sceneRasterWidth, sceneRasterHeight, 32, 32, 0, 0)); product.addTiePointGrid(createTiePointGrid("tpg2", sceneRasterWidth, sceneRasterHeight, 16, 32, 21, 14)); }
private static void addRasterDataNodeToProduct(final Product product, final RasterDataNode rasterDataNode) { if (rasterDataNode instanceof Band) { product.addBand((Band) rasterDataNode); } else if (rasterDataNode instanceof TiePointGrid) { product.addTiePointGrid((TiePointGrid) rasterDataNode); } else { fail("couldn't add RasterDataNode to product. Node is of unknown type."); } } }
private static void setTiePointGeoCoding(final Product product) { final TiePointGrid latGrid = new TiePointGrid("lat", 3, 3, 0.5f, 0.5f, 5, 5, new float[]{ 85, 84, 83, 75, 74, 73, 65, 64, 63 }); final TiePointGrid lonGrid = new TiePointGrid("lon", 3, 3, 0.5f, 0.5f, 5, 5, new float[]{ -15, -5, 5, -16, -6, 4, -17, -7, 3 }); product.addTiePointGrid(latGrid); product.addTiePointGrid(lonGrid); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, org.esa.beam.framework.dataop.maptransf.Datum.WGS_84)); }
private Product createSourceProduct() { final Product sourceProduct = new Product("sp", "spt", 4, 4); sourceProduct.addBand("b1", ProductData.TYPE_INT32); sourceProduct.addTiePointGrid(new TiePointGrid("tpg1", 3, 3, 0, 0, 2, 2, new float[]{ 0.1f, 0.2f, 0.3f, 0.2f, 0.3f, 0.4f, 0.3f, 0.4f, 0.5f, })); return sourceProduct; }
@Test public void testThatAddTiePointGridThrowExceptionIfNameIsNotUnique() { final Product product = new Product("p", "t", 1, 1); product.addBand("band1", ProductData.TYPE_FLOAT32); product.addTiePointGrid(new TiePointGrid("grid", 1, 1, 0, 0, 1, 1, new float[]{0.0f})); try { product.addTiePointGrid(new TiePointGrid("grid", 1, 1, 0, 0, 1, 1, new float[]{0.0f})); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("name")); } try { product.addTiePointGrid(new TiePointGrid("band1", 1, 1, 0, 0, 1, 1, new float[]{0.0f})); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("name")); } }
static Product createSourceProduct(int sourceProductCounter, float value) { final Product p = new Product("P" + sourceProductCounter, "T", 2, 2); final TiePointGrid latitude = new TiePointGrid("latitude", 2, 2, 0.5F, 0.5F, 1.0F, 1.0F, new float[]{ 1.0F, 1.0F, 0.0F, 0.0F, }); final TiePointGrid longitude = new TiePointGrid("longitude", 2, 2, 0.5F, 0.5F, 1.0F, 1.0F, new float[]{ 0.0F, 1.0F, 0.0F, 1.0F, }); p.addTiePointGrid(latitude); p.addTiePointGrid(longitude); p.setGeoCoding(new TiePointGeoCoding(latitude, longitude)); p.addBand("chl", value + ""); return p; }
protected void addTiePointGrids() throws IOException { int tpSubsampling = avhrrFile.getTiePointSubsampling(); final int gridHeight = avhrrFile.getProductHeight() / tpSubsampling + 1; String[] tiePointNames = avhrrFile.getTiePointNames(); float[][] tiePointData = avhrrFile.getTiePointData(); final int numGrids = tiePointNames.length; TiePointGrid grid[] = new TiePointGrid[numGrids]; for (int i = 0; i < grid.length; i++) { grid[i] = createTiePointGrid(tiePointNames[i], TP_GRID_WIDTH, gridHeight, TP_OFFSET_X, TP_OFFSET_Y, tpSubsampling, tpSubsampling, tiePointData[i]); grid[i].setUnit(UNIT_DEG); product.addTiePointGrid(grid[i]); } GeoCoding geoCoding = new TiePointGeoCoding(grid[numGrids - 2], grid[numGrids - 1], Datum.WGS_72); product.setGeoCoding(geoCoding); }
@Test public void testThatAddBandThrowExceptionIfNameIsNotUnique() { final Product product = new Product("p", "t", 1, 1); product.addBand("band1", ProductData.TYPE_FLOAT32); product.addTiePointGrid(new TiePointGrid("grid", 1, 1, 0, 0, 1, 1, new float[]{0.0f})); try { product.addBand("band1", ProductData.TYPE_FLOAT32); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().indexOf("name") > -1); } try { product.addBand("grid", ProductData.TYPE_FLOAT32); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().indexOf("name") > -1); } }
@Before public void setUp() throws Exception { product = new Product("p", "t", PRODUCT_WIDTH, PRODUCT_HEIGHT); TiePointGrid lat = new TiePointGrid("t1", 3, 3, 0, 0, 5, 5, new float[]{ 2.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f}); product.addTiePointGrid(lat); TiePointGrid lon = new TiePointGrid("t2", 3, 3, 0, 0, 5, 5, new float[]{ 0.0f, 1.0f, 2.0f, 0.0f, 1.0f, 2.0f, 0.0f, 1.0f, 2.0f}); product.addTiePointGrid(lon); product.setGeoCoding(new TiePointGeoCoding(lat, lon, Datum.WGS_84)); attachIndexCodedBand(); attachColoredBand(); }
private static Product createProduct() throws Exception { Product product = new Product("p", "t", 32, 256); final TiePointGrid lat = new TiePointGrid("lat", 2, 2, 0f, 0f, 32f, 256f, new float[]{+40f, +40f, -40f, -40f}); final TiePointGrid lon = new TiePointGrid("lon", 2, 2, 0f, 0f, 32f, 256f, new float[]{-80f, +80f, -80f, +80f}); product.addTiePointGrid(lat); product.addTiePointGrid(lon); product.setGeoCoding(new TiePointGeoCoding(lat, lon)); product.setPreferredTileSize(32, 16); product.setStartTime(ProductData.UTC.parse("2003-01-01", "yyyy-MM-dd")); product.setEndTime(ProductData.UTC.parse("2003-01-02", "yyyy-MM-dd")); return product; }
private void addTiePointGrids(Product product) { final int sceneRasterWidth = product.getSceneRasterWidth(); final int sceneRasterHeight = product.getSceneRasterHeight(); final TiePointGrid tiePointGrid = createTiePointGrid("tpg1", sceneRasterWidth, sceneRasterHeight, 21.1f, 14.2f, 16.3f, 32.004f, false); product.addTiePointGrid(tiePointGrid); tiePointGrid.getOverlayMaskGroup().add(product.getMaskGroup().get("name2")); tiePointGrid.getOverlayMaskGroup().add(product.getMaskGroup().get("name3")); product.addTiePointGrid( createTiePointGrid("tpg2", sceneRasterWidth, sceneRasterHeight, 21.1f, 14.2f, 16.3f, 32.004f, true)); }
private Product createProduct() { Product product = new Product("test", "test", PW, PH); TiePointGrid latGrid = new TiePointGrid("latGrid", GW, GH, 0.5f, 0.5f, S, S, createLatGridData()); TiePointGrid lonGrid = new TiePointGrid("lonGrid", GW, GH, 0.5f, 0.5f, S, S, createLonGridData()); product.addTiePointGrid(latGrid); product.addTiePointGrid(lonGrid); Band latBand = product.addBand("latBand", ProductData.TYPE_FLOAT32); Band lonBand = product.addBand("lonBand", ProductData.TYPE_FLOAT32); latBand.setRasterData(ProductData.createInstance(createBandData(latGrid))); lonBand.setRasterData(ProductData.createInstance(createBandData(lonGrid))); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84)); return product; }
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); }
private Product createSourceProduct(int w, int h) throws ParseException { Product sourceProduct = new Product("TEST.N1", "MER_RR__1P", w, h); sourceProduct.setStartTime(ProductData.UTC.parse("17-Jan-2008 12:13:27")); sourceProduct.setEndTime(ProductData.UTC.parse("17-Jan-2008 13:16:28")); Band rad08 = sourceProduct.addBand("radiance_8", ProductData.TYPE_INT16); Band rad10 = sourceProduct.addBand("radiance_10", ProductData.TYPE_INT16); rad08.setSourceImage(ConstantDescriptor.create(1.0f * w, 1.0f * h, new Short[]{2000}, null)); rad10.setSourceImage(ConstantDescriptor.create(1.0f * w, 1.0f * h, new Short[]{3000}, null)); rad08.setScalingFactor(0.01); rad10.setScalingFactor(0.01); TiePointGrid lat = new TiePointGrid("latitude", w, h, 0, 0, 1, 1, new float[w * h]); TiePointGrid lon = new TiePointGrid("longitude", w, h, 0, 0, 1, 1, new float[w * h]); sourceProduct.addTiePointGrid(lat); sourceProduct.addTiePointGrid(lon); sourceProduct.setGeoCoding(new TiePointGeoCoding(lat, lon)); return sourceProduct; }
public void testWriteProductNodes_TiePointGrid() { Product product = new Product("name", BeamConstants.MERIS_FR_L1B_PRODUCT_TYPE_NAME, 50, 25); float[] expectedArray = getTiePointData(10, 5); TiePointGrid tiePointGrid = new TiePointGrid("name", 10, 5, 0, 0, 5, 5, expectedArray); product.addTiePointGrid(tiePointGrid); try { _productWriter.writeProductNodes(product, _outputFile); _productWriter.close(); } catch (IOException e) { fail("IOException not expected"); } float[] currentArray = getCurrentByteArray(tiePointGrid); assertEquals(expectedArray.length, currentArray.length); for (int i = 0; i < expectedArray.length; i++) { assertEquals(expectedArray[i], currentArray[i], 1e-8f); } }
private Product createProduct() { Product product = new Product("test", "test", PW, PH); TiePointGrid latGrid = new TiePointGrid("latGrid", GW, GH, 0.5f, 0.5f, S, S, createLatGridData()); TiePointGrid lonGrid = new TiePointGrid("lonGrid", GW, GH, 0.5f, 0.5f, S, S, createLonGridData()); product.addTiePointGrid(latGrid); product.addTiePointGrid(lonGrid); Band latBand = product.addBand("latBand", ProductData.TYPE_FLOAT32); Band lonBand = product.addBand("lonBand", ProductData.TYPE_FLOAT32); latBand.setRasterData(ProductData.createInstance(createBandData(latGrid))); lonBand.setRasterData(ProductData.createInstance(createBandData(lonGrid))); final FlagCoding flagCoding = new FlagCoding("flags"); flagCoding.addFlag("valid", 0, "valid pixel"); product.getFlagCodingGroup().add(flagCoding); Band flagomatBand = product.addBand("flagomat", ProductData.TYPE_UINT8); flagomatBand.setRasterData(ProductData.createInstance(ProductData.TYPE_UINT8, PW * PH)); flagomatBand.setSampleCoding(flagCoding); product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, Datum.WGS_84)); return product; }