@Override protected ProductData inferType(String elementName, String value) { return ProductData.createInstance(value); }
@Override protected ProductData inferType(String elementName, String value) { return ProductData.createInstance(value); }
@Override protected ProductData inferType(String elementName, String value) { return ProductData.createInstance(value); }
@Override protected ProductData inferType(String elementName, String value) { return ProductData.createInstance(value); }
@Override protected ProductData inferType(String elementName, String value) { return ProductData.createInstance(value); }
@Override protected ProductData inferType(String elementName, String value) { return ProductData.createInstance(value); }
protected ProductData createProductData(int dataType, int size) { ProductData buffer; switch (dataType) { case ProductData.TYPE_UINT8: buffer = ProductData.createUnsignedInstance(new byte[size]); break; case ProductData.TYPE_INT8: buffer = ProductData.createInstance(new byte[size]); break; case ProductData.TYPE_UINT16: buffer = ProductData.createUnsignedInstance(new short[size]); break; case ProductData.TYPE_INT16: buffer = ProductData.createInstance(new short[size]); break; case ProductData.TYPE_INT32: buffer = ProductData.createInstance(new int[size]); break; case ProductData.TYPE_UINT32: buffer = ProductData.createUnsignedInstance(new int[size]); break; case ProductData.TYPE_FLOAT32: buffer = ProductData.createInstance(new float[size]); break; default: buffer = ProductData.createUnsignedInstance(new byte[size]); break; } return buffer; }
public final ProductData buildOutputProductData() { int widthCount = this.imageWidth + 2; int heightCount = this.imageHeight + 2; int[][] marker = buildMarkerMatrix(widthCount, heightCount); int elementCount = this.imageWidth * this.imageHeight; ProductData data = ProductData.createInstance(ProductData.TYPE_INT32, elementCount); for (int y = 1; y < heightCount - 1; y++) { for (int x = 1; x < widthCount - 1; x++) { int elementIndex = (this.imageWidth * (y - 1)) + (x - 1); data.setElemIntAt(elementIndex, marker[y][x]); //result.setValueAt(y-1, x-1, marker[y][x]); } } WeakReference<int[][]> referenceMarkerMatrix = new WeakReference<int[][]>(marker); referenceMarkerMatrix.clear(); return data; }
public ProductData getData() { Object dataElemArray = getDataElemArray(data, elemIndex); return ProductData.createInstance(data.getType(), dataElemArray); }
static ProductData createInstance(int type, String value) { ProductData retVal; switch (type) { case ProductData.TYPE_UINT8: retVal = ProductData.createInstance(type); retVal.setElemUInt(Byte.parseByte(value)); break; case ProductData.TYPE_INT32: retVal = ProductData.createInstance(type); retVal.setElemInt(Integer.parseInt(value)); break; case ProductData.TYPE_FLOAT32: retVal = ProductData.createInstance(type); retVal.setElemFloat(Float.parseFloat(value)); break; case ProductData.TYPE_UTC: try { retVal = ProductData.UTC.parse(value); } catch (ParseException e) { retVal = new ProductData.ASCII(value); } break; default: retVal = new ProductData.ASCII(value); break; } return retVal; } }
switch (type) { case ProductData.TYPE_UINT8: retVal = ProductData.createInstance(type); retVal.setElemUInt(Byte.parseByte(value)); break; case ProductData.TYPE_INT32: retVal = ProductData.createInstance(type); retVal.setElemInt(Integer.parseInt(value)); break; case ProductData.TYPE_FLOAT32: retVal = ProductData.createInstance(type); retVal.setElemFloat(Float.parseFloat(value)); break;
public UnionMasksTilesComputing(IntMatrix colorFillerMatrix, IntSet currentSegmentationTrimmingRegionKeys, IntSet previousSegmentationTrimmingRegionKeys, int tileWidth, int tileHeight) { super(colorFillerMatrix.getColumnCount(), colorFillerMatrix.getRowCount(), tileWidth, tileHeight); this.colorFillerMatrix = colorFillerMatrix; this.currentSegmentationTrimmingRegionKeys = currentSegmentationTrimmingRegionKeys; this.previousSegmentationTrimmingRegionKeys = previousSegmentationTrimmingRegionKeys; int sceneWidth = this.colorFillerMatrix.getColumnCount(); int sceneHeight = this.colorFillerMatrix.getRowCount(); this.productData = ProductData.createInstance(ProductData.TYPE_INT32, sceneWidth * sceneHeight); }
private void updateMetadata(Product product) { final MetadataElement graphElement = product.getMetadataRoot().getElement("Processing_Graph"); for (MetadataElement nodeElement : graphElement.getElements()) { if (getSpi().getOperatorAlias().equals(nodeElement.getAttributeString("operator"))) { final MetadataElement sourcesElement = nodeElement.getElement("sources"); for (int i = 0; i < this.sourceProducts.length; i++) { final String oldIndex = String.valueOf(i + 1); final String newIndex = String.valueOf(sourcesElement.getNumAttributes() + i + 1); final Product sourceProduct = this.sourceProducts[i]; final String attributeName = getSourceProductId(sourceProduct).replaceFirst(oldIndex, newIndex); final File location = sourceProduct.getFileLocation(); final ProductData attributeValue; if (location == null) { attributeValue = ProductData.createInstance(product.toString()); } else { attributeValue = ProductData.createInstance(location.getPath()); } final MetadataAttribute attribute = new MetadataAttribute(attributeName, attributeValue, true); sourcesElement.addAttribute(attribute); } } } }
private void addAttributes(MetadataElement element) { element.addAttribute(new MetadataAttribute("string", ProductData.createInstance("O815"), true)); element.addAttribute(new MetadataAttribute("singleValue", ProductData.createInstance(new byte[]{108}), true)); element.addAttribute(new MetadataAttribute("array", ProductData.createInstance(new byte[]{4, 8, 15, 16, 23, 42}), true)); element.addAttribute(new MetadataAttribute("splittedArray.1", ProductData.createInstance(new byte[]{4}), true)); element.addAttribute(new MetadataAttribute("splittedArray.2", ProductData.createInstance(new byte[]{8}), true)); element.addAttribute(new MetadataAttribute("splittedArray.3", ProductData.createInstance(new byte[]{15}), true)); element.addAttribute(new MetadataAttribute("splittedArray.4", ProductData.createInstance(new byte[]{16}), true)); element.addAttribute(new MetadataAttribute("splittedArray.5", ProductData.createInstance(new byte[]{23}), true)); element.addAttribute(new MetadataAttribute("splittedArray.6", ProductData.createInstance(new byte[]{42}), true)); } }
@Test public void testCreateTransectProfileText_Float() throws IOException { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_FLOAT32); node.setSynthetic(true); final float[] data = new float[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, 1.0f); data[0] = Float.NaN; // no data node.setData(ProductData.createInstance(data)); final Line2D.Float shape = new Line2D.Float(0.5f, 0.5f, 1.5f, 0.5f); final TransectProfileData profileData = node.createTransectProfileData(shape); final String profileDataString = StatisticsUtils.TransectProfile.createTransectProfileText(node, profileData); assertTrue(profileDataString.contains("NaN")); assertFalse(profileDataString.toLowerCase().contains("no data")); } }
/** * @param w width * @param h height * @return the created product */ private static Product createTestProduct(int w, int h) { final Product testProduct = TestUtils.createProduct("ASA_APG_1P", w, h); // create a Band: band1 final Band band1 = testProduct.addBand("Amplitude", ProductData.TYPE_INT32); band1.setUnit(Unit.AMPLITUDE); final int[] intValues = new int[w * h]; for (int i = 0; i < w * h; i++) { intValues[i] = i + 1; } band1.setData(ProductData.createInstance(intValues)); final float[] incidence_angle = new float[64]; Arrays.fill(incidence_angle, 30.0f); testProduct.addTiePointGrid(new TiePointGrid(OperatorUtils.TPG_INCIDENT_ANGLE, 16, 4, 0, 0, 1, 1, incidence_angle)); return testProduct; } }
/** * @param w width * @param h height * @return the created product */ private static Product createTestProduct(String name, String unit, int w, int h) { final Product testProduct = TestUtils.createProduct("ASA_APG_1P", w, h); // create a Band: band1 final Band band1 = testProduct.addBand(name, ProductData.TYPE_INT32); band1.setUnit(unit); final int[] intValues = new int[w * h]; for (int i = 0; i < w * h; i++) { intValues[i] = i + 1; } band1.setData(ProductData.createInstance(intValues)); final float[] incidence_angle = new float[64]; Arrays.fill(incidence_angle, 30.0f); testProduct.addTiePointGrid(new TiePointGrid(OperatorUtils.TPG_INCIDENT_ANGLE, 16, 4, 0, 0, 1, 1, incidence_angle)); return testProduct; } }
int destPos = 0; final ProductData tmpBuffer = ProductData.createInstance(new float[destBuffer.getNumElems() * 2]); final int tmpWidth = destWidth * 2;
@Test public void testCreateTransectProfileText_Byte() throws IOException { final Product product = new Product("X", "Y", 2, 1); Band node = product.addBand("name", ProductData.TYPE_INT8); node.setSynthetic(true); node.setNoDataValue(0); node.setNoDataValueUsed(true); final byte[] data = new byte[product.getSceneRasterWidth() * product.getSceneRasterHeight()]; Arrays.fill(data, (byte) 1); data[0] = 0; // no data node.setData(ProductData.createInstance(data)); final Line2D.Float shape = new Line2D.Float(0.5f, 0.5f, 1.5f, 0.5f); final TransectProfileData profileData = node.createTransectProfileData(shape); final String profileDataString = StatisticsUtils.TransectProfile.createTransectProfileText(node, profileData); assertTrue(profileDataString.contains("NaN")); assertFalse(profileDataString.toLowerCase().contains("no data")); }
ProductData lineData = ProductData.createInstance(destBuffer.getType(), sourceWidth);