/** * Retuns a "deep" copy of this product data. * * @return a copy of this product data */ @Override protected ProductData createDeepClone() { final Float data = new Float(_array.length); System.arraycopy(_array, 0, data._array, 0, _array.length); return data; }
/** * Tests whether this ProductData is equal to another one. * Performs an element-wise comparision if the other object is a {@link ProductData} instance of the same data type. * Otherwise the method behaves like {@link Object#equals(Object)}. * * @param other the other one */ @Override public boolean equalElems(ProductData other) { if (other == this) { return true; } else if (other instanceof ProductData.Float) { return Arrays.equals(_array, ((ProductData.Float) other).getArray()); } return false; }
/** * Sets the data of this value. The data must be an array of the type <code>float[]</code> or * <code>String[]</code> and have a length that is equal to the value returned by the * <code>getNumDataElems</code> method. * * @param data the data array * * @throws IllegalArgumentException if data is <code>null</code> or it is not an array of the required type or * does not have the required array length. */ @Override public void setElems(Object data) { Guardian.assertNotNull("data", data); if (data instanceof String[] && ((String[]) data).length == getNumElems()) { final String[] strings = (String[]) data; for (int i = 0; i < getNumElems(); i++) { _array[i] = java.lang.Float.parseFloat(strings[i]); } return; } if (!(data instanceof float[]) || ((float[]) data).length != getNumElems()) { throw new IllegalArgumentException("data is not a float[" + getNumElems() + "]"); } System.arraycopy(data, 0, _array, 0, getNumElems()); }
return new ProductData.UInt(numElems); case TYPE_FLOAT32: return new ProductData.Float(numElems); case TYPE_FLOAT64: return new ProductData.Double(numElems);
return new ProductData.UInt((int[]) data); case TYPE_FLOAT32: return new ProductData.Float((float[]) data); case TYPE_FLOAT64: return new ProductData.Double((double[]) data);
public DirectTile(RasterDataNode rasterDataNode, ProductData dataBuffer, Rectangle rectangle, boolean target) { Assert.notNull(rasterDataNode, "rasterDataNode"); this.rasterDataNode = rasterDataNode; this.dataBuffer = dataBuffer; this.minX = rectangle.x; this.minY = rectangle.y; this.maxX = rectangle.x + rectangle.width - 1; this.maxY = rectangle.y + rectangle.height - 1; this.width = rectangle.width; this.height = rectangle.height; this.target = target; this.scaled = rasterDataNode.isScalingApplied(); this.signedByte = rasterDataNode.getDataType() == ProductData.TYPE_INT8; this.dataBufferByte = (dataBuffer instanceof ProductData.Byte) ? ((ProductData.Byte) dataBuffer).getArray() : null; this.dataBufferShort = (dataBuffer instanceof ProductData.Short) ? ((ProductData.Short) dataBuffer).getArray() : null; this.dataBufferInt = (dataBuffer instanceof ProductData.Int) ? ((ProductData.Int) dataBuffer).getArray() : null; this.dataBufferFloat = (dataBuffer instanceof ProductData.Float) ? ((ProductData.Float) dataBuffer).getArray() : null; this.dataBufferDouble = (dataBuffer instanceof ProductData.Double) ? ((ProductData.Double) dataBuffer).getArray() : null; }
public static ProductData createInstance(float[] elems) { Guardian.assertNotNull("elems", elems); return new ProductData.Float(elems); }
private Band createFloatTestBand(int w, int h, float min, float max) { final Product product = createTestProduct(w, h); final Band band = product.addBand("float", ProductData.TYPE_FLOAT32); final float[] values = new float[w * h]; for (int i = 0; i < values.length; i++) { values[i] = min + i * (max - min) / (values.length - 1); } band.setData(new ProductData.Float(values)); return band; }