private Map<Dimension, List<NodeContext>> buildTileDimensionMap(NodeContext[] outputNodeContexts) { final int mapSize = outputNodeContexts.length; Map<Dimension, List<NodeContext>> tileSizeMap = new HashMap<Dimension, List<NodeContext>>(mapSize); for (NodeContext outputNodeContext : outputNodeContexts) { Product targetProduct = outputNodeContext.getTargetProduct(); Dimension tileSize = targetProduct.getPreferredTileSize(); final int numXTiles = MathUtils.ceilInt(targetProduct.getSceneRasterWidth() / (double) tileSize.width); final int numYTiles = MathUtils.ceilInt(targetProduct.getSceneRasterHeight() / (double) tileSize.height); Dimension tileDim = new Dimension(numXTiles, numYTiles); List<NodeContext> nodeContextList = tileSizeMap.get(tileDim); if (nodeContextList == null) { nodeContextList = new ArrayList<NodeContext>(mapSize); tileSizeMap.put(tileDim, nodeContextList); } nodeContextList.add(outputNodeContext); } return tileSizeMap; }
private Rectangle[] getAllTileRectangles() { Dimension tileSize = ImageManager.getPreferredTileSize(sourceProduct); final int rasterHeight = sourceProduct.getSceneRasterHeight(); final int rasterWidth = sourceProduct.getSceneRasterWidth(); final Rectangle boundary = new Rectangle(rasterWidth, rasterHeight); final int tileCountX = MathUtils.ceilInt(boundary.width / (double) tileSize.width); final int tileCountY = MathUtils.ceilInt(boundary.height / (double) tileSize.height); Rectangle[] rectangles = new Rectangle[tileCountX * tileCountY]; int index = 0; for (int tileY = 0; tileY < tileCountY; tileY++) { for (int tileX = 0; tileX < tileCountX; tileX++) { final Rectangle tileRectangle = new Rectangle(tileX * tileSize.width, tileY * tileSize.height, tileSize.width, tileSize.height); final Rectangle intersection = boundary.intersection(tileRectangle); rectangles[index] = intersection; index++; } } return rectangles; }
private Rectangle[] getAllTileRectangles() { Dimension tileSize = ImageManager.getPreferredTileSize(sourceProduct); final int rasterHeight = sourceProduct.getSceneRasterHeight(); final int rasterWidth = sourceProduct.getSceneRasterWidth(); final Rectangle boundary = new Rectangle(rasterWidth, rasterHeight); final int tileCountX = MathUtils.ceilInt(boundary.width / (double) tileSize.width); final int tileCountY = MathUtils.ceilInt(boundary.height / (double) tileSize.height); Rectangle[] rectangles = new Rectangle[tileCountX * tileCountY]; int index = 0; for (int tileY = 0; tileY < tileCountY; tileY++) { for (int tileX = 0; tileX < tileCountX; tileX++) { final Rectangle tileRectangle = new Rectangle(tileX * tileSize.width, tileY * tileSize.height, tileSize.width, tileSize.height); final Rectangle intersection = boundary.intersection(tileRectangle); rectangles[index] = intersection; index++; } } return rectangles; }
public static OperatorExecutor create(Operator op) { OperatorContext operatorContext = getOperatorContext(op); Product targetProduct = op.getTargetProduct(); Dimension tileSize = targetProduct.getPreferredTileSize(); int rasterHeight = targetProduct.getSceneRasterHeight(); int rasterWidth = targetProduct.getSceneRasterWidth(); Rectangle boundary = new Rectangle(rasterWidth, rasterHeight); int tileCountX = MathUtils.ceilInt(boundary.width / (double) tileSize.width); int tileCountY = MathUtils.ceilInt(boundary.height / (double) tileSize.height); Band[] targetBands = targetProduct.getBands(); PlanarImage[] images = createImages(targetBands, operatorContext); return new OperatorExecutor(images, tileCountX, tileCountY); }
@Override public void initialize() throws OperatorException { targetProduct = sourceProduct; outputFileExists = targetProduct.getFileLocation() != null && targetProduct.getFileLocation().exists(); productWriter = ProductIO.getProductWriter(formatName); if (productWriter == null) { throw new OperatorException("No data product writer for the '" + formatName + "' format available"); } productWriter.setIncrementalMode(incremental); targetProduct.setProductWriter(productWriter); try { productWriter.writeProductNodes(targetProduct, file); } catch (IOException e) { throw new OperatorException("Not able to write product file: '" + file.getAbsolutePath() + "'", e); } final Band[] bands = targetProduct.getBands(); writableBands = new ArrayList<>(bands.length); for (final Band band : bands) { band.getSourceImage(); // trigger source image creation if (productWriter.shouldWrite(band)) { writableBands.add(band); } } tileSize = ImageManager.getPreferredTileSize(targetProduct); targetProduct.setPreferredTileSize(tileSize); tileCountX = MathUtils.ceilInt(targetProduct.getSceneRasterWidth() / (double) tileSize.width); tileCountY = MathUtils.ceilInt(targetProduct.getSceneRasterHeight() / (double) tileSize.height); tilesWritten = new boolean[writableBands.size()][tileCountY][tileCountX]; }
private static Rectangle[] computeDataSliceRectangles(MultiLevelImage maskImage, MultiLevelImage[] varImages, Dimension defaultSliceSize) { MultiLevelImage referenceImage = varImages[0]; Rectangle[] rectangles; if (areTilesDirectlyUsable(maskImage, varImages, defaultSliceSize)) { final Point[] tileIndices = referenceImage.getTileIndices(null); rectangles = new Rectangle[tileIndices.length]; for (int i = 0; i < tileIndices.length; i++) { Point tileIndex = tileIndices[i]; rectangles[i] = referenceImage.getTileRect(tileIndex.x, tileIndex.y); } } else { int sceneHeight = referenceImage.getHeight(); int numSlices = MathUtils.ceilInt(sceneHeight / (double) defaultSliceSize.height); rectangles = new Rectangle[numSlices]; for (int i = 0; i < numSlices; i++) { rectangles[i] = computeCurrentSliceRectangle(defaultSliceSize, i, sceneHeight); } } return rectangles; }
value = currentValue; final int firstBandIndex = MathUtils.floorInt(currentValue / (float) stepsPerTimespan); final int secondBandIndex = MathUtils.ceilInt(currentValue / (float) stepsPerTimespan); BandImageMultiLevelSource newSource = BandImageMultiLevelSource.create(bandList.get(secondBandIndex), ProgressMonitor.NULL);