/** * Tests if this value is a scalar. * * @return true, if so */ public boolean isScalar() { return getNumElems() == 1; }
@Override public final int getSize() { return _buffer.getNumElems(); }
private void checkBufferSize(int sourceWidth, int sourceHeight, ProductData sourceBuffer) { int expectedBufferSize = sourceWidth * sourceHeight; int actualBufferSize = sourceBuffer.getNumElems(); Guardian.assertEquals("wrong sourceBuffer size", actualBufferSize, expectedBufferSize); }
private static void checkBufferSize(int sourceWidth, int sourceHeight, ProductData sourceBuffer) { final int expectedBufferSize = sourceWidth * sourceHeight; final int actualBufferSize = sourceBuffer.getNumElems(); Guardian.assertEquals("sourceWidth * sourceHeight", actualBufferSize, expectedBufferSize); /*I18N*/ }
private static ProductData recycleOrCreateBuffer(final int dataType, final int buffersize, ProductData readBuffer) { if (readBuffer == null || readBuffer.getNumElems() != buffersize) { readBuffer = ProductData.createInstance(dataType, buffersize); } return readBuffer; }
public int getSizeInBytes() { return data.getElemSize() * data.getNumElems(); } }
public int getSizeInBytes() { return data.getElemSize() * data.getNumElems(); } }
/** * Writes all elements of this <code>ProductData</code> instance to to the given output stream. * <p/> * <p> The method subsequentially writes the elements at <code>0</code> to <code>getNumElems()-1</code> of this * <code>ProductData</code> instance to the given output stream.<br> Writing starts at the current seek position * within the output stream. * * @param output a seekable data output stream * * @throws IOException if an I/O error occurs */ public void writeTo(ImageOutputStream output) throws IOException { writeTo(0, getNumElems(), output); }
/** * Reads all elements of this <code>ProductData</code> instance from to the given input stream. * <p/> * <p> The method subsequentially reads the elements at <code>0</code> to <code>getNumElems()-1</code> of this * <code>ProductData</code> instance from the given input stream.<br> Reading starts at the current seek position * within the input stream. * * @param input a seekable data input stream * * @throws IOException if an I/O error occurs */ public void readFrom(ImageInputStream input) throws IOException { readFrom(0, getNumElems(), input); }
public DataNode(String name, ProductData data, boolean readOnly) { super(name); Guardian.assertNotNull("data", data); this.dataType = data.getType(); this.numElems = data.getNumElems(); this.data = data; this.readOnly = readOnly; }
public ProductData getFrameData(final Band targetBand) { if (frameRectangle == null) { return null; } ProductData frameData = frameDataMap.get(targetBand.getName()); final int numElems = frameRectangle.width * frameRectangle.height; if (frameData == null || frameData.getNumElems() != numElems) { frameData = targetBand.createCompatibleProductData(numElems); frameDataMap.put(targetBand.getName(), frameData); } return frameData; }
/** * Tests whether the given parameters specify a compatible raster or not. * * @param rasterData the raster data * @param w the raster width * @param h the raster height * @return {@code true} if so */ public boolean isCompatibleRasterData(ProductData rasterData, int w, int h) { return rasterData != null && rasterData.getType() == getDataType() && rasterData.getNumElems() == w * h; }
private static float getSolarFluxFromMetadata(MetadataElement metadataRoot, int bandIndex) { if (metadataRoot != null) { MetadataElement scalingFactorGads = metadataRoot.getElement("Scaling_Factor_GADS"); if (scalingFactorGads != null) { MetadataAttribute sunSpecFlux = scalingFactorGads.getAttribute("sun_spec_flux"); ProductData data = sunSpecFlux.getData(); if (data.getNumElems() > bandIndex) { return data.getElemFloatAt(bandIndex); } } } return 0.0f; }
@Override public void computeTileStack(Map<Band, Tile> targetTiles, Rectangle targetRectangle, ProgressMonitor pm) throws OperatorException { assertEquals(3, targetTiles.size()); for (Tile tt : targetTiles.values()) { ProductData dataBuffer = tt.getDataBuffer(); int numElems = dataBuffer.getNumElems(); for (int i = 0; i < numElems; i++) { dataBuffer.setElemIntAt(i, i); } } assertEquals(0, tileCache.getCacheTileCount()); } };
@Override public synchronized ProductData getRawSamples() { if (rawSamples == null) { ProductData dataBuffer = getDataBuffer(); if (width * height == dataBuffer.getNumElems()) { rawSamples = dataBuffer; } } if (rawSamples == null) { rawSamples = rasterDataNode.createCompatibleRasterData(width, height); if (target) { mustWriteSampleData = true; } else { raster.getDataElements(minX, minY, width, height, rawSamples.getElems()); } } return rawSamples; }
private ProductData getFilledSourceData(int size) { ProductData data = getSourceData(size); byte[] bytes = new byte[data.getNumElems()]; for (int i = 0; i < bytes.length; i++) { bytes[i] = 85; } data.setElems(bytes); return data; }
private long getDataFieldOffset() { long offset = 0; Record pixelDataRecord = getPixelDataRecord(); for (int i = 0; i < pixelDataRecord.getNumFields(); i++) { Field field = pixelDataRecord.getFieldAt(i); if (field == getPixelDataField()) { break; } ProductData data = field.getData(); offset += data.getElemSize() * data.getNumElems(); } return offset; }
private void fillWithData(Band band, float multiplicator, float offset) { band.ensureRasterData(); final ProductData data = band.getRasterData(); for (int i = 0; i < data.getNumElems(); i++) { data.setElemFloatAt(i, i * multiplicator + offset); } } }
private static void fillBandWithData(Band band) { final ProductData productData = band.createCompatibleRasterData(); final int n = productData.getNumElems(); for (int i = 0; i < n; i++) { productData.setElemDoubleAt(i, i * 2.4); } band.setData(productData); } }
@Override public synchronized void setRawSamples(ProductData rawSamples) { if (target) { if (rawSamples != this.dataBuffer) { Assert.notNull(rawSamples, "rawSamples"); Assert.argument(rawSamples.getType() == dataBuffer.getType(), "rawSamples.getType() == dataBuffer.getType()"); Assert.argument(rawSamples.getNumElems() == dataBuffer.getNumElems(), "rawSamples.getNumElems() == dataBuffer.getNumElems()"); dataBuffer.setElems(rawSamples.getElems()); } } }