@Override public boolean transferGeoCoding(final Scene srcScene, final Scene destScene, final ProductSubsetDef subsetDef) { final Band srcLatBand = getLatBand(); final Product destProduct = destScene.getProduct(); Band latBand = destProduct.getBand(srcLatBand.getName()); if (latBand == null) { latBand = GeoCodingFactory.createSubset(srcLatBand, destScene, subsetDef); destProduct.addBand(latBand); } final Band srcLonBand = getLonBand(); Band lonBand = destProduct.getBand(srcLonBand.getName()); if (lonBand == null) { lonBand = GeoCodingFactory.createSubset(srcLonBand, destScene, subsetDef); destProduct.addBand(lonBand); } String validMaskExpression = getValidMask(); try { if (validMaskExpression != null) { GeoCodingFactory.copyReferencedRasters(validMaskExpression, srcScene, destScene, subsetDef); } } catch (ParseException ignored) { validMaskExpression = null; } destScene.setGeoCoding(new PixelGeoCoding2(latBand, lonBand, validMaskExpression)); return true; }
Band latBand = destProduct.getBand(srcLatBand.getName()); if (latBand == null) { latBand = GeoCodingFactory.createSubset(srcLatBand, destScene, subsetDef); destProduct.addBand(latBand); Band lonBand = destProduct.getBand(srcLonBand.getName()); if (lonBand == null) { lonBand = GeoCodingFactory.createSubset(srcLonBand, destScene, subsetDef); destProduct.addBand(lonBand);
static void copyReferencedRasters(String validMaskExpression, Scene sourceScene, Scene targetScene, ProductSubsetDef subsetDef) throws ParseException { final Product targetProduct = targetScene.getProduct(); final RasterDataNode[] nodes = BandArithmetic.getRefRasters(validMaskExpression, sourceScene.getProduct()); for (RasterDataNode node : nodes) { if (!targetProduct.containsRasterDataNode(node.getName())) { if (node instanceof TiePointGrid) { TiePointGrid tpg = TiePointGrid.createSubset((TiePointGrid) node, subsetDef); targetProduct.addTiePointGrid(tpg); } if (node instanceof Band) { final Band sourceBand = (Band) node; final Band band = createSubset(sourceBand, targetScene, subsetDef); targetProduct.addBand(band); setFlagCoding(band, sourceBand.getFlagCoding()); } } } }