/** * Gets the data element size in bytes. * * @see ProductData#getElemSize(int) */ public int getDataElemSize() { return ProductData.getElemSize(getDataType()); }
/** * Gets the element size of an element of this product data in bytes. * * @return the size of a single element in bytes */ public int getElemSize() { return getElemSize(getType()); }
public int getSizeInBytes() { return data.getElemSize() * data.getNumElems(); } }
public int getSizeInBytes() { return data.getElemSize() * data.getNumElems(); } }
private int getReadBufferLineCount() { final int sizePerLine = getRasterWidth() * ProductData.getElemSize(getDataType()); int bufferLineCount = READ_BUFFER_MAX_SIZE / sizePerLine; if (bufferLineCount == 0) { bufferLineCount = 1; } return bufferLineCount; }
/** * Writes elements of this <code>ProductData</code> instance to to the given output stream. * <p/> * <p> The method subsequentially writes the elements at <code>startPos</code> to <code>startPos+numElems-1</code> * of this <code>ProductData</code> instance to the given output stream.<br> Writing starts at * <code>outputPos</code> within the output stream. The method multiplies this position with the value returned by * <code>getElemSize()</code> in order to find the correct stream offset in bytes. * * @param startPos the source start position (zero-based) * @param numElems the number of elements to be written * @param output a seekable data output stream * @param outputPos the position in the data output stream where writing starts * * @throws IOException if an I/O error occurs */ public void writeTo(int startPos, int numElems, ImageOutputStream output, long outputPos) throws IOException { output.seek(getElemSize() * outputPos); writeTo(startPos, numElems, output); }
/** * Reads elements into this <code>ProductData</code> instance from the given input stream. * <p/> * <p> The method subsequentially reads the elements at <code>startPos</code> to <code>startPos+numElems-1</code> of * this <code>ProductData</code> instance from the given input stream.<br> Reading starts at <code>inputPos</code> * within the output stream. The method multiplies this position with the value returned by * <code>getElemSize()</code> in order to find the correct stream offset in bytes. * * @param startPos the destination start position (zero-based) * @param numElems the number of elements to read * @param input a seekable data input stream * @param inputPos the (zero-based) position in the data output stream where reading starts * * @throws IOException if an I/O error occurs */ public void readFrom(int startPos, int numElems, ImageInputStream input, long inputPos) throws IOException { input.seek(getElemSize() * inputPos); readFrom(startPos, numElems, input); }
private static long getImageFileSize(RasterDataNode band) { return (long) ProductData.getElemSize(band.getDataType()) * (long) band.getRasterWidth() * (long) band.getRasterHeight(); }
private TiffShort[] calculateBitsPerSample(final Product product) { int dataType = getBandDataType(); int elemSize = ProductData.getElemSize(dataType); final TiffShort[] tiffValues = new TiffShort[getNumBands(product)]; for (int i = 0; i < tiffValues.length; i++) { tiffValues[i] = new TiffShort(8 * elemSize); } return tiffValues; }
return maxUnsignedIntType; if (ProductData.getElemSize(maxUnsignedIntType) >= ProductData.getElemSize(maxSignedIntType)) { int returnType = maxUnsignedIntType - 10 + 1; if (returnType > 12) {
private TiffShort[] calculateBitsPerSample(final Product product) { int dataType = getBandDataType(); int elemSize = ProductData.getElemSize(dataType); final TiffShort[] tiffValues = new TiffShort[getNumBands(product)]; for (int i = 0; i < tiffValues.length; i++) { tiffValues[i] = new TiffShort(8 * elemSize); } return tiffValues; }
return maxUnsignedIntType; if (ProductData.getElemSize(maxUnsignedIntType) >= ProductData.getElemSize(maxSignedIntType)) { int returnType = maxUnsignedIntType - 10 + 1; if (returnType > 12) {
/** * Gets the estimated size in bytes of this product node. * * @param subsetDef if not <code>null</code> the subset may limit the size returned * @return the size in bytes. */ @Override public long getRawStorageSize(ProductSubsetDef subsetDef) { long size = 0L; if (isPartOfSubset(subsetDef)) { size += 256; // add estimated overhead of 256 bytes size += ProductData.getElemSize(getDataType()) * getNumDataElems(); } return size; }
public void testGetElemSizeInBytes() { assertEquals(1, ProductData.getElemSize(ProductData.TYPE_ASCII)); assertEquals(4, ProductData.getElemSize(ProductData.TYPE_FLOAT32)); assertEquals(8, ProductData.getElemSize(ProductData.TYPE_FLOAT64)); assertEquals(2, ProductData.getElemSize(ProductData.TYPE_INT16)); assertEquals(4, ProductData.getElemSize(ProductData.TYPE_INT32)); assertEquals(1, ProductData.getElemSize(ProductData.TYPE_INT8)); assertEquals(2, ProductData.getElemSize(ProductData.TYPE_UINT16)); assertEquals(4, ProductData.getElemSize(ProductData.TYPE_UINT32)); assertEquals(1, ProductData.getElemSize(ProductData.TYPE_UINT8)); assertEquals(4, ProductData.getElemSize(ProductData.TYPE_UTC)); int unsupportedDataType = ProductData.TYPE_ASCII + ProductData.TYPE_FLOAT32 + ProductData.TYPE_FLOAT64 + ProductData.TYPE_INT16 + ProductData.TYPE_INT32 + ProductData.TYPE_INT8 + ProductData.TYPE_UINT16 + ProductData.TYPE_UINT32 + ProductData.TYPE_UINT8 + ProductData.TYPE_UTC; try { ProductData.getElemSize(unsupportedDataType); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } }
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 float[] getCurrentByteArray(TiePointGrid grid) { FileImageInputStream inputStream = createInputStream(grid); int fileLength = new Long(inputStream.length()).intValue(); int arrayLength = fileLength / ProductData.getElemSize(ProductData.TYPE_FLOAT32); float[] currentFloats = new float[arrayLength]; try { inputStream.readFully(currentFloats, 0, arrayLength); inputStream.close(); } catch (FileNotFoundException e) { fail("FileNotFoundException not expected"); } catch (IOException e) { fail("IOException not expected"); } return currentFloats; }
/** * Gets an estimated raw storage size in bytes of this product node. * * @param subsetDef if not <code>null</code> the subset may limit the size returned * @return the size in bytes. */ @Override public long getRawStorageSize(ProductSubsetDef subsetDef) { long size = 0L; if (isPartOfSubset(subsetDef)) { size += 256; // add estimated overhead of 256 bytes long numDataElems = getNumDataElems(); if (subsetDef != null) { long width = getSceneRasterWidth(); long height = getSceneRasterHeight(); Rectangle region = subsetDef.getRegion(); if (region != null) { width = region.width; height = region.height; } width /= 1 + subsetDef.getSubSamplingX(); height /= 1 + subsetDef.getSubSamplingY(); numDataElems = width * height; } size += ProductData.getElemSize(getDataType()) * numDataElems; } return size; }
sourceY * _dsd.getRecordSize() + fieldOffset + minX * dataFieldSampleSize * field.getData().getElemSize(); final ImageInputStream istream = _productFile.getDataInputStream(); synchronized (istream) {
recordOffset + fieldOffset + minX * dataFieldSampleSize * field.getData().getElemSize();
Product product = destBand.getProduct(); final int sourceRasterWidth = product.getSceneRasterWidth(); final int elemSize = destBuffer.getElemSize();