public static void addIntAttributte(final MetadataElement elem, final String name, final int value) { final ProductData data = ProductData.createInstance(ProductData.TYPE_INT8); data.setElemInt(value); elem.addAttribute(new MetadataAttribute(name, data, true)); }
private void addMetadata(Product product) { final MetadataElement metadataRoot = product.getMetadataRoot(); metadataRoot.setDescription("metadata-desc"); final ProductData productData1 = ProductData.createInstance(ProductData.TYPE_INT16); productData1.setElemInt(123); final MetadataAttribute attribute1 = new MetadataAttribute("attrib1", productData1, false); metadataRoot.addAttribute(attribute1); final ProductData productData2 = ProductData.createInstance(new float[]{1, 2, 3, 4, 5, 6}); final MetadataAttribute attribute2 = new MetadataAttribute("attrib2", productData2, true); metadataRoot.addAttribute(attribute2); final ProductData productData3 = ProductData.createInstance(new double[]{7, 8, 9, 10, 11, 12}); final MetadataAttribute attribute3 = new MetadataAttribute("attrib3", productData3, false); metadataRoot.addAttribute(attribute3); final MetadataElement mdElem1 = new MetadataElement("mdElemName1"); mdElem1.setDescription("mdElem1-desc"); metadataRoot.addElement(mdElem1); final ProductData productData4 = ProductData.createInstance(new double[]{23.547, -8.0001, -59.989898}); final MetadataAttribute attribute4 = new MetadataAttribute("attrib4", productData4, true); mdElem1.addAttribute(attribute4); MetadataAttribute stringAttrib = new MetadataAttribute("StringAttrib", ProductData.createInstance("StringAttribValue"), true); mdElem1.addAttribute(stringAttrib); final ProductData productData5 = ProductData.createInstance(ProductData.TYPE_UTC); productData5.setElemIntAt(0, 123); productData5.setElemIntAt(1, 234); productData5.setElemIntAt(2, 345); final MetadataAttribute attribute5 = new MetadataAttribute("attrib5", productData5, false); metadataRoot.addAttribute(attribute5); }
/** * Sets the attribute with the given name to the given integer value. <p>A new attribute with * <code>ProductData.TYPE_INT32</code> is added to this node if an attribute with the given name could not be found * in this node. * * @param name the attribute name * @param value the new value */ public void setAttributeInt(String name, int value) { final MetadataAttribute attribute = getAndMaybeCreateAttribute(name, ProductData.TYPE_INT32, 1); attribute.getData().setElemInt(value); attribute.fireProductNodeDataChanged(); setModified(true); }
private static FlagCoding createNdviFlagCoding() { FlagCoding ndviFlagCoding = new FlagCoding("ndvi_flags"); ndviFlagCoding.setDescription("NDVI Flag Coding"); MetadataAttribute attribute; attribute = new MetadataAttribute(NDVI_ARITHMETIC_FLAG_NAME, ProductData.TYPE_INT32); attribute.getData().setElemInt(NDVI_ARITHMETIC_FLAG_VALUE); attribute.setDescription("NDVI value calculation failed due to an arithmetic exception"); ndviFlagCoding.addAttribute(attribute); attribute = new MetadataAttribute(NDVI_LOW_FLAG_NAME, ProductData.TYPE_INT32); attribute.getData().setElemInt(NDVI_LOW_FLAG_VALUE); attribute.setDescription("NDVI value is too low"); ndviFlagCoding.addAttribute(attribute); attribute = new MetadataAttribute(NDVI_HIGH_FLAG_NAME, ProductData.TYPE_INT32); attribute.getData().setElemInt(NDVI_HIGH_FLAG_VALUE); attribute.setDescription("NDVI value is too high"); ndviFlagCoding.addAttribute(attribute); return ndviFlagCoding; }
private void addFlag(FlagCoding flagCoding, int index) { MetadataAttribute attribute; attribute = new MetadataAttribute(String.format("%d_FLAG", index + 1), ProductData.TYPE_UINT8); final int maskValue = 1 << index; attribute.getData().setElemInt(maskValue); flagCoding.addAttribute(attribute); } }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the UTC value * @param unit the unit string * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, int value, String unit, MetadataElement dest, String desc) { final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_INT32, 1); attribute.getData().setElemInt(value); attribute.setUnit(unit); attribute.setDescription(desc); dest.addAttribute(attribute); }
private static FlagCoding createCloudFlagCoding(Product outputProduct) { MetadataAttribute cloudAttr; final FlagCoding flagCoding = new FlagCoding(CLOUD_FLAG_BAND); flagCoding.setDescription("Cloud Flag Coding"); cloudAttr = new MetadataAttribute("cloudy", ProductData.TYPE_UINT8); cloudAttr.getData().setElemInt(FLAG_CLOUDY); cloudAttr.setDescription("is with more than 80% cloudy"); flagCoding.addAttribute(cloudAttr); outputProduct.addMask(cloudAttr.getName(), flagCoding.getName() + "." + cloudAttr.getName(), cloudAttr.getDescription(), createBitmaskColor(1, 3), 0.5); cloudAttr = new MetadataAttribute("cloudfree", ProductData.TYPE_UINT8); cloudAttr.getData().setElemInt(FLAG_CLOUDFREE); cloudAttr.setDescription("is with less than 20% cloudy"); flagCoding.addAttribute(cloudAttr); outputProduct.addMask(cloudAttr.getName(), flagCoding.getName() + "." + cloudAttr.getName(), cloudAttr.getDescription(), createBitmaskColor(2, 3), 0.5); cloudAttr = new MetadataAttribute("cloud_uncertain", ProductData.TYPE_UINT8); cloudAttr.getData().setElemInt(FLAG_UNCERTAIN); cloudAttr.setDescription("is with between 20% and 80% cloudy"); flagCoding.addAttribute(cloudAttr); outputProduct.addMask(cloudAttr.getName(), flagCoding.getName() + "." + cloudAttr.getName(), cloudAttr.getDescription(), createBitmaskColor(3, 3), 0.5); return flagCoding; }
attribute.getData().setElemInt(chrisFile.getGainSetting(i)); attribute.setDescription("CHRIS analogue electronics gain setting"); element.addAttribute(attribute); attribute.getData().setElemInt(chrisFile.getLowRow(i)); attribute.setDescription("CCD row number for the cut-on wavelength"); element.addAttribute(attribute); attribute.getData().setElemInt(chrisFile.getHighRow(i)); attribute.setDescription("CCD row number for the cut-off wavelength"); element.addAttribute(attribute);