private ProductNodeSubsetPane createTiePointGridSubsetPane() { TiePointGrid[] tiePointGrids = product.getTiePointGrids(); if (tiePointGrids.length == 0) { return null; } return new ProductNodeSubsetPane(product.getTiePointGrids(), new String[]{BeamConstants.LAT_DS_NAME, BeamConstants.LON_DS_NAME}, true); }
@Override public void preEncode(ProfileWriteContext ctx, Product p) throws IOException { CfBandPart.defineRasterDataNodes(ctx, p.getTiePointGrids()); }
private static TiePointGrid[] getTiePointGrids(Product sourceProduct, String[] names) { TiePointGrid[] tiePointGrids = sourceProduct.getTiePointGrids(); if (names != null && names.length > 0) { ArrayList<TiePointGrid> tiePointGridList = new ArrayList<TiePointGrid>(sourceProduct.getNumBands()); for (String name : names) { final TiePointGrid tiePointGrid = sourceProduct.getTiePointGrid(name); if (tiePointGrid != null) { tiePointGridList.add(tiePointGrid); } } tiePointGrids = tiePointGridList.toArray(new TiePointGrid[tiePointGridList.size()]); } return tiePointGrids; }
private static void removeGeoCodingAndTiePointGrids(Product product) { product.setGeoCoding(null); final TiePointGrid[] pointGrids = product.getTiePointGrids(); for (TiePointGrid pointGrid : pointGrids) { product.removeTiePointGrid(pointGrid); } }
private void removeGeoCodingAndTiePointGrids(Product product) { product.setGeoCoding(null); final TiePointGrid[] pointGrids = product.getTiePointGrids(); for (TiePointGrid pointGrid : pointGrids) { product.removeTiePointGrid(pointGrid); } }
/** * Copies the ROI {@link Mask}s from the source product's raster data nodes to * the target product's raster data nodes. * <p/> * IMPORTANT NOTE: This method should only be used, if it is known that all masks * in the source product will also be valid in the target product. This method does * <em>not</em> copy ROI masks, which are not contained in the target product's * mask group. * * @param sourceProduct the source product * @param targetProduct the target product * * @deprecated since BEAM 4.10 (no replacement) */ @Deprecated public static void copyRoiMasks(Product sourceProduct, Product targetProduct) { for (RasterDataNode sourceNode : sourceProduct.getTiePointGrids()) { copyRoiMasks(sourceNode, targetProduct); } for (RasterDataNode sourceNode : sourceProduct.getBands()) { copyRoiMasks(sourceNode, targetProduct); } }
/** * Copies the overlay {@link Mask}s from the source product's raster data nodes to * the target product's raster data nodes. * <p/> * IMPORTANT NOTE: This method should only be used, if it is known that all masks * in the source product will also be valid in the target product. This method does * <em>not</em> copy overlay masks, which are not contained in the target product's * mask group. * * @param sourceProduct the source product * @param targetProduct the target product */ public static void copyOverlayMasks(Product sourceProduct, Product targetProduct) { for (RasterDataNode sourceNode : sourceProduct.getTiePointGrids()) { copyOverlayMasks(sourceNode, targetProduct); } for (RasterDataNode sourceNode : sourceProduct.getBands()) { copyOverlayMasks(sourceNode, targetProduct); } }
private void writeHeader() throws IOException { final Band[] bands = getSourceProduct().getBands(); StringBuilder builder = new StringBuilder(); builder.append(getFeatureIdColumnNameFromMetadata()); for (final Band band : bands) { builder.append(separator); builder.append(band.getName()); builder.append(":"); final int dataType = band.getGeophysicalImage().getData().getDataBuffer().getDataType(); builder.append(getJavaType(dataType)); } final TiePointGrid[] tiePointGrids = getSourceProduct().getTiePointGrids(); for (final TiePointGrid tpg : tiePointGrids) { builder.append(separator); builder.append(tpg.getName()); builder.append(":"); final int dataType = tpg.getGeophysicalImage().getData().getDataBuffer().getDataType(); builder.append(getJavaType(dataType)); } writeLine(builder.toString()); }
private ProductTreeModel createTreeModel(AppContext ctx) { Product selectedProduct = ctx.getSelectedProductSceneView().getProduct(); ArrayList<CompatibleNodeList> compatibleNodeLists = new ArrayList<CompatibleNodeList>(3); List<RasterDataNode> compatibleNodes = new ArrayList<RasterDataNode>(); compatibleNodes.addAll(Arrays.asList(selectedProduct.getBands())); compatibleNodes.addAll(Arrays.asList(selectedProduct.getTiePointGrids())); if (!compatibleNodes.isEmpty()) { compatibleNodeLists.add(new CompatibleNodeList(selectedProduct.getDisplayName(), compatibleNodes)); } RasterDataNode raster = ctx.getSelectedProductSceneView().getRaster(); GeoCoding geoCoding = raster.getGeoCoding(); CoordinateReferenceSystem modelCRS = ImageManager.getModelCrs(geoCoding); final ProductManager productManager = ctx.getProductManager(); final Product[] products = productManager.getProducts(); for (Product product : products) { if (product == selectedProduct) { continue; } compatibleNodes = new ArrayList<RasterDataNode>(); collectCompatibleRasterDataNodes(modelCRS, product.getBands(), compatibleNodes); collectCompatibleRasterDataNodes(modelCRS, product.getTiePointGrids(), compatibleNodes); if (!compatibleNodes.isEmpty()) { compatibleNodeLists.add(new CompatibleNodeList(product.getDisplayName(), compatibleNodes)); } } return new ProductTreeModel(compatibleNodeLists); }
protected void writeImageDisplayElements(int indent) { final StringWriter stringWriter = new StringWriter(); final XmlWriter sXmlW = new XmlWriter(stringWriter, false); final Band[] bands = product.getBands(); final String[] idTags = createTags(indent, DimapProductConstants.TAG_IMAGE_DISPLAY); writeBandStatistics(sXmlW, indent, bands); writeMaskUsages(sXmlW, indent + 1, bands); writeMaskUsages(sXmlW, indent + 1, product.getTiePointGrids()); sXmlW.close(); final String childTags = stringWriter.toString(); if (childTags != null && childTags.length() > 0) { println(idTags[0]); print(childTags); println(idTags[1]); } }
private void handleMaskRemoved(ProductNodeEvent event) { final Mask mask = (Mask) event.getSourceNode(); final Band[] bands = getBands(); for (Band band : bands) { band.getOverlayMaskGroup().remove(mask); } final TiePointGrid[] tiePointGrids = getTiePointGrids(); for (TiePointGrid tiePointGrid : tiePointGrids) { tiePointGrid.getOverlayMaskGroup().remove(mask); } }
void applyFilteredGrids() { if (product != null) { Band[] allBands = product.getBands(); TiePointGrid[] allGrids = product.getTiePointGrids(); BandChooser bandChooser = new BandChooser(getPaneWindow(), "Available Bands And Tie Point Grids", getDescriptor().getHelpId(), false, allBands, selectedBands, allGrids, selectedGrids, true); if (bandChooser.show() == ModalDialog.ID_OK) { selectedBands = bandChooser.getSelectedBands(); selectedGrids = bandChooser.getSelectedTiePointGrids(); productToSelectedBands.put(product, selectedBands); productToSelectedGrids.put(product, selectedGrids); updateTableModel(); } } }
final TiePointGrid[] tiePointGrids = product.getTiePointGrids(); final GeoCoding geoCoding = product.getGeoCoding(); if (mustCreateHeader) {
@Override public void encode(ProfileWriteContext ctx, Product p) throws IOException { for (TiePointGrid tiePointGrid : p.getTiePointGrids()) { final int y = tiePointGrid.getRasterHeight(); final int x = tiePointGrid.getRasterWidth(); final int[] shape = new int[]{y, x}; final Array values = Array.factory(DataType.FLOAT, shape, tiePointGrid.getDataElems()); String variableName = ReaderUtils.getVariableName(tiePointGrid); ctx.getNetcdfFileWriteable().findVariable(variableName).writeFully(values); } } }
private ProductSceneView getSceneView() { final ProductSceneView selectedProductSceneView = visatApp.getSelectedProductSceneView(); if (selectedProductSceneView == null && product != null) { final Band[] bands = product.getBands(); for (Band band : bands) { final JInternalFrame internalFrame = visatApp.findInternalFrame(band); if (internalFrame != null) { final Container contentPane = internalFrame.getContentPane(); if (contentPane instanceof ProductSceneView) { return (ProductSceneView) contentPane; } } } final TiePointGrid[] tiePointGrids = product.getTiePointGrids(); for (TiePointGrid tiePointGrid : tiePointGrids) { final JInternalFrame internalFrame = visatApp.findInternalFrame(tiePointGrid); if (internalFrame != null) { final Container contentPane = internalFrame.getContentPane(); if (contentPane instanceof ProductSceneView) { return (ProductSceneView) contentPane; } } } } return selectedProductSceneView; }
@Override public void preEncode(ProfileWriteContext ctx, Product p) throws IOException { final HashMap<String, String> dimMap = new HashMap<String, String>(); final NFileWriteable ncFile = ctx.getNetcdfFileWriteable(); for (TiePointGrid tiePointGrid : p.getTiePointGrids()) { final String key = "" + tiePointGrid.getRasterHeight() + " " + tiePointGrid.getRasterWidth(); String dimString = dimMap.get(key); if (dimString == null) { final int size = dimMap.size(); final String suffix = size > 0 ? "" + (size + 1) : ""; ncFile.addDimension("tp_y" + suffix, tiePointGrid.getRasterHeight()); ncFile.addDimension("tp_x" + suffix, tiePointGrid.getRasterWidth()); dimString = "tp_y" + suffix + " " + "tp_x" + suffix; dimMap.put(key, dimString); } String variableName = ReaderUtils.getVariableName(tiePointGrid); final NVariable variable = ncFile.addVariable(variableName, DataType.FLOAT, null, dimString); variable.addAttribute(OFFSET_X, tiePointGrid.getOffsetX()); variable.addAttribute(OFFSET_Y, tiePointGrid.getOffsetY()); variable.addAttribute(SUBSAMPLING_X, tiePointGrid.getSubSamplingX()); variable.addAttribute(SUBSAMPLING_Y, tiePointGrid.getSubSamplingY()); } }
@Test public void testIncludeTiePointGrids() throws Exception { parameterMap.put("crs", WGS84_CODE); Product targetPoduct = createReprojectedProduct(); TiePointGrid[] tiePointGrids = targetPoduct.getTiePointGrids(); assertNotNull(tiePointGrids); assertEquals(0, tiePointGrids.length); Band latGrid = targetPoduct.getBand("latGrid"); assertNotNull(latGrid); parameterMap.put("includeTiePointGrids", false); targetPoduct = createReprojectedProduct(); tiePointGrids = targetPoduct.getTiePointGrids(); assertNotNull(tiePointGrids); assertEquals(0, tiePointGrids.length); latGrid = targetPoduct.getBand("latGrid"); assertNull(latGrid); }
@Override public void encode(ProfileWriteContext ctx, Product p) throws IOException { boolean doFlip = getYFlippedProperty(ctx); for (TiePointGrid tiePointGrid : p.getTiePointGrids()) { final int h = tiePointGrid.getSceneRasterHeight(); final int w = tiePointGrid.getSceneRasterWidth(); final Object data = tiePointGrid.getSourceImage().getData().getDataElements(0, 0, w, h, null); ProductData productData = ProductData.createInstance(ProductData.TYPE_FLOAT32, data); String variableName = ReaderUtils.getVariableName(tiePointGrid); ctx.getNetcdfFileWriteable().findVariable(variableName).write(0, 0, w, h, doFlip, productData); } }
deleteMaskFromGroup(band.getOverlayMaskGroup(), mask); TiePointGrid[] tiePointGrids = product.getTiePointGrids(); for (TiePointGrid tiePointGrid : tiePointGrids) { deleteMaskFromGroup(tiePointGrid.getOverlayMaskGroup(), mask);
for (TiePointGrid grid : srcProduct.getTiePointGrids()) { contextProduct.addTiePointGrid(new TiePointGrid(grid.getName(), 10, 10, 0, 0, 1, 1, new float[100]));