private MetadataAttribute getAndMaybeCreateAttribute(final String name, final int type, final int numElems) { MetadataAttribute attribute = getAttribute(name); if (attribute == null) { attribute = new MetadataAttribute(name, type, numElems); addAttribute(attribute); } return attribute; }
private MetadataAttribute addAttribute(final MetadataElement platformMetadata, final String name, final ProductData data, final String unit) { final MetadataAttribute attribute = createAttribute(name, data); if (unit != null) { attribute.setUnit(unit); } platformMetadata.addAttribute(attribute); return attribute; } }
private static MetadataAttribute addAttribute(final MetadataElement platformMetadata, final String name, final ProductData data, final String unit) { final MetadataAttribute attribute = createAttribute(name, data); if (unit != null) { attribute.setUnit(unit); } platformMetadata.addAttribute(attribute); return attribute; }
protected static void addAttribString(String name, String value, MetadataElement subsetElem) { ProductData data = ProductData.createInstance(value); subsetElem.addAttribute(new MetadataAttribute(name, data, true)); }
protected void cloneMetadataAttributes(MetadataElement sourceRoot, MetadataElement destRoot) { for (int i = 0; i < sourceRoot.getNumAttributes(); i++) { MetadataAttribute sourceAttribute = sourceRoot.getAttributeAt(i); destRoot.addAttribute(sourceAttribute.createDeepClone()); } }
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)); }
static MetadataElement createSourceMetaElement(String productName, int index) { final MetadataElement productElement = new MetadataElement("source." + Integer.toString(index)); final MetadataAttribute nameAttribute = new MetadataAttribute("name", new ProductData.ASCII(productName), true); productElement.addAttribute(nameAttribute); return productElement; }
private void addVariableToMetadata(String variable) { MetadataElement variableListElement = tsProduct.getMetadataRoot(). getElement(TIME_SERIES_ROOT_NAME). getElement(VARIABLES); final ProductData variableName = ProductData.createInstance(variable); final ProductData isSelected = ProductData.createInstance(Boolean.toString(false)); int length = variableListElement.getElements().length + 1; MetadataElement elem = new MetadataElement(String.format("%s.%s", VARIABLES, Integer.toString(length))); elem.addAttribute(new MetadataAttribute(VARIABLE_NAME, variableName, true)); elem.addAttribute(new MetadataAttribute(VARIABLE_SELECTION, isSelected, true)); variableListElement.addElement(elem); }
private void addProductMetadata(Map.Entry<String, Product> productEntry) { MetadataElement productElement = tsProduct.getMetadataRoot(). getElement(TIME_SERIES_ROOT_NAME). getElement(SOURCE_PRODUCT_PATHS); ProductData productPath = ProductData.createInstance(productEntry.getKey()); int length = productElement.getElements().length + 1; MetadataElement elem = new MetadataElement(String.format("%s.%s", SOURCE_PRODUCT_PATHS, Integer.toString(length))); elem.addAttribute(new MetadataAttribute(PL_PATH, productPath, true)); productElement.addElement(elem); }
private void addSolarAzimuthAngleIfPossible(final Product product, final MetadataElement element) { try { final Calendar calendar = product.getStartTime().getAsCalendar(); final double lat = Double.parseDouble(chrisFile.getGlobalAttribute(ChrisConstants.ATTR_NAME_TARGET_LAT)); final double lon = Double.parseDouble(chrisFile.getGlobalAttribute(ChrisConstants.ATTR_NAME_TARGET_LON)); final double saa = SunPositionCalculator.calculate(calendar, lat, lon).getAzimuthAngle(); final ProductData data = ProductData.createInstance(String.format("%05.2f", saa)); element.addAttribute(new MetadataAttribute(ChrisConstants.ATTR_NAME_SOLAR_AZIMUTH_ANGLE, data, true)); } catch (Exception e) { // ignore } }
public static void addCenterToMetadata( MetadataElement clusterAnalysis, Band[] sourceBands, double[][] means) { for (int i = 0; i < means.length; i++) { MetadataElement element = new MetadataElement("class." + i); for (int j = 0; j < sourceBands.length; j++) { ProductData pData = ProductData.createInstance(new double[]{means[i][j]}); MetadataAttribute metadataAttribute = new MetadataAttribute( "cluster_center." + sourceBands[j].getName(), pData, true); element.addAttribute(metadataAttribute); } clusterAnalysis.addElement(element); } }
private void addInputProductPathsToMetadata(Product product) { final MetadataElement productsElement = new MetadataElement("Input products"); final String[] absoluteInputProductPaths = getAbsoluteInputProductPaths(); for (int i = 0; i < absoluteInputProductPaths.length; i++) { String inputProductAbsPath = absoluteInputProductPaths[i]; final ProductData pathData = ProductData.createInstance(inputProductAbsPath); final MetadataAttribute pathAttribute = new MetadataAttribute("product_" + i, pathData, true); productsElement.addAttribute(pathAttribute); } product.getMetadataRoot().addElement(productsElement); }
private MetadataElement createMetadataElement(String name, String description, Property[] properties) { MetadataElement element = new MetadataElement(name); element.setDescription(description); for (Property property : properties) { element.addAttribute(new MetadataAttribute(property.getName(), ProductData.createInstance(property.getValueAsText()), true)); } return element; }
private void addSynthesisMetadataElement(List<Attribute> rootMetadata, final Product product, String metadataElementName) { final MetadataElement metadataElement = new MetadataElement(metadataElementName); for (Attribute attribute : rootMetadata) { metadataElement.addAttribute(new MetadataAttribute(attribute.getName(), ProductData.createInstance(ProbaVUtils.getAttributeValue(attribute)), true)); } product.getMetadataRoot().addElement(metadataElement); }
private void addSynthesisMetadataElement(List<Attribute> rootMetadata, final Product product, String metadataElementName) { final MetadataElement metadataElement = new MetadataElement(metadataElementName); for (Attribute attribute : rootMetadata) { metadataElement.addAttribute(new MetadataAttribute(attribute.getName(), ProductData.createInstance(ProbaVUtils.getAttributeValue(attribute)), true)); } product.getMetadataRoot().addElement(metadataElement); }
private void addProductLocationElements(MetadataElement productLocations) { final MetadataElement location0 = new MetadataElement(AbstractTimeSeries.PRODUCT_LOCATIONS + "." + 0); final MetadataElement location1 = new MetadataElement(AbstractTimeSeries.PRODUCT_LOCATIONS + "." + 1); productLocations.addElement(location0); productLocations.addElement(location1); location0.addAttribute(new MetadataAttribute(AbstractTimeSeries.PL_PATH, ProductData.createInstance(absoluteProductPath1), true)); location0.addAttribute(new MetadataAttribute(AbstractTimeSeries.PL_TYPE, ProductData.createInstance("FILE"), true)); location1.addAttribute(new MetadataAttribute(AbstractTimeSeries.PL_PATH, ProductData.createInstance(absoluteProductPath2), true)); location1.addAttribute(new MetadataAttribute(AbstractTimeSeries.PL_TYPE, ProductData.createInstance("FILE"), true)); }
private void addSourceProductPathsElemets(MetadataElement sourcePaths) { final MetadataElement sourcePath1 = new MetadataElement(AbstractTimeSeries.SOURCE_PRODUCT_PATHS + "." + 0); final MetadataElement sourcePath2 = new MetadataElement(AbstractTimeSeries.SOURCE_PRODUCT_PATHS + "." + 1); sourcePaths.addElement(sourcePath1); sourcePaths.addElement(sourcePath2); sourcePath1.addAttribute(new MetadataAttribute(AbstractTimeSeries.PL_PATH, ProductData.createInstance(absoluteProductPath1), true)); sourcePath2.addAttribute(new MetadataAttribute(AbstractTimeSeries.PL_PATH, ProductData.createInstance(absoluteProductPath2), true)); } }
private void addMetadata(Product sp) { final MetadataElement meta1 = new MetadataElement("meta1"); meta1.addAttribute(new MetadataAttribute("attrib1", ProductData.createInstance("value"), true)); final MetadataElement meta2 = new MetadataElement("meta2"); final MetadataElement meta2_1 = new MetadataElement("meta2_1"); meta2_1.addAttribute(new MetadataAttribute("attrib2_1", ProductData.createInstance("meta2_1_value"), true)); meta2.addElement(meta2_1); final MetadataElement metadataRoot = sp.getMetadataRoot(); metadataRoot.addAttribute(new MetadataAttribute("attribRoot", ProductData.createInstance("rootValue"), true)); metadataRoot.addElement(meta1); metadataRoot.addElement(meta2); }
public MetadataElement createDeepClone() { MetadataElement clone = new MetadataElement(getName()); clone.setDescription(getDescription()); MetadataAttribute[] attributes = getAttributes(); for (MetadataAttribute attribute : attributes) { clone.addAttribute(attribute.createDeepClone()); } MetadataElement[] elements = getElements(); for (MetadataElement element : elements) { clone.addElement(element.createDeepClone()); } return clone; }
/** * GuiTest_DialogAndModalDialog the functionality for getNumAttributes() */ public void testGetNumAttributes() { MetadataElement annot = new MetadataElement("yepp"); MetadataAttribute att = new MetadataAttribute("GuiTest_DialogAndModalDialog", ProductData.createInstance(ProductData.TYPE_INT32), false); // a new object should not have any attributes assertEquals(0, annot.getNumAttributes()); // add one and test again annot.addAttribute(att); assertEquals(1, annot.getNumAttributes()); }