/** * Gets the sample name at the specified attribute index. * * @param index the attribute index. * @return the sample name. */ public String getSampleName(int index) { return getAttributeAt(index).getName(); }
private String createAttributeName(MetadataAttribute attribute) { StringBuilder sb = new StringBuilder(); MetadataElement metadataElement = attribute.getParentElement(); if (metadataElement != null) { prependParentName(metadataElement, sb); } sb.append(attribute.getName()); return sb.toString(); }
@Override public void visit(MetadataAttribute attribute) { visitedList.add(attribute.getName()); }
xmlAttribs.add(new String[]{DimapProductConstants.ATTRIB_NAME, attribute.getName()}); final String description = attribute.getDescription(); if (description != null) {
for (int j = 0; j < band.getFlagCoding().getNumAttributes(); j++) { final MetadataAttribute attribute = band.getFlagCoding().getAttributeAt(j); l.add(band.getName() + "." + attribute.getName());
private void resetFlagTableModel() { flagModel.clear(); if (currentRaster != null) { for (Band band : currentFlagBands) { final FlagCoding flagCoding = band.getFlagCoding(); final int numFlags = flagCoding.getNumAttributes(); final String bandNameDot = band.getName() + "."; for (int j = 0; j < numFlags; j++) { String name = bandNameDot + flagCoding.getAttributeAt(j).getName(); flagModel.addRow(name, "", ""); } } } }
public Object getValueAt(int column) { if (column == NAME_COL_INDEX) { if (index == -1) { return attribute.getName(); } else { return attribute.getName() + "." + index; } } else if (column == VALUE_COL_INDEX) { if (index == -1) { return attribute.getData().getElemString(); } else { return attribute.getData().getElemStringAt(index); } } else if (column == TYPE_COL_INDEX) { return attribute.getData().getTypeString(); } else if (column == UNIT_COL_INDEX) { return attribute.getUnit() != null ? attribute.getUnit() : ""; } else if (column == DESCR_COL_INDEX) { return attribute.getDescription() != null ? attribute.getDescription() : ""; } return ""; } }
ExpectedSampleCoding(SampleCoding sampleCoding) { this(); this.name = sampleCoding.getName(); samples = new ExpectedSample[sampleCoding.getNumAttributes()]; for (int i = 0; i < samples.length; i++) { final MetadataAttribute sampleAttribute = sampleCoding.getAttributeAt(i); samples[i] = new ExpectedSample(sampleAttribute.getName(), sampleAttribute.getData().getElemUInt(), sampleAttribute.getDescription()); } }
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() instanceof ProductData.UTC) { createScalarAttribute(locationID, attribute.getName(), attribute.getData().getElemString()); } else if (attribute.getData().isScalar()) { createScalarAttribute(locationID, attribute.getName(), getH5DataType(productDataType), attribute.getData().getElems()); } else { createArrayAttribute(locationID, attribute.getName(), getH5DataType(productDataType), attribute.getData().getNumElems(), if (attribute.getUnit() != null) { createScalarAttribute(locationID, attribute.getName() + ".unit", attribute.getUnit()); attribute.getName() + ".descr", attribute.getDescription());
private void writeMetadataAttribute(NFileWriteable ncFile, MetadataAttribute metadataAttr, NVariable ncVariable, String prefix) throws IOException { final ProductData productData = metadataAttr.getData(); String ncAttributeName; if (prefix.isEmpty()) { ncAttributeName = metadataAttr.getName(); } else { ncAttributeName = prefix + SPLITTER + metadataAttr.getName(); } if(!ncFile.isNameValid(ncAttributeName)) { ncAttributeName = ncFile.makeNameValid(ncAttributeName); } if (productData instanceof ProductData.ASCII || productData instanceof ProductData.UTC) { ncVariable.addAttribute(ncAttributeName, productData.getElemString()); } else { ncVariable.addAttribute(ncAttributeName, Array.factory(productData.getElems())); } if (metadataAttr.getUnit() != null) { ncVariable.addAttribute(ncAttributeName + "." + UNIT_SUFFIX, metadataAttr.getUnit()); } if (metadataAttr.getDescription() != null) { ncVariable.addAttribute(ncAttributeName + "." + DESCRIPTION_SUFFIX, metadataAttr.getDescription()); } } }
private static void assertMetadataAttributeEqualityInt(MetadataAttribute expected, MetadataAttribute actual) { assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getData().getElemInt(), actual.getData().getElemInt()); assertEquals(expected.getDescription(), actual.getDescription()); }
public MetadataAttribute createDeepClone() { MetadataAttribute clone = new MetadataAttribute(getName(), getData().createDeepClone(), isReadOnly()); clone.setDescription(getDescription()); clone.setSynthetic(isSynthetic()); clone.setUnit(getUnit()); return clone; } }
@Test public void testMultiProductsNames() throws Exception { String filePath = GPFFacadeTest.class.getResource("test-product.dim").toURI().getPath(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("file", new File(filePath)); Product p1 = GPF.createProduct("Read", parameters); Product p2 = GPF.createProduct("Foo", GPF.NO_PARAMS, new Product[]{p1}); Product p3 = GPF.createProduct("Foos", GPF.NO_PARAMS, new Product[]{p1, p2}); MetadataElement metadataElement = p3.getMetadataRoot().getElement("Processing_Graph"); MetadataElement sourceElement = null; for (MetadataElement element : metadataElement.getElements()) { if (element.getAttribute("operator").getData().getElemString().equals("Foos")) { sourceElement = element.getElement("sources"); break; } } assertNotNull(sourceElement); assertEquals(2, sourceElement.getNumAttributes()); assertEquals("sourceProduct.1", sourceElement.getAttributeAt(0).getName()); assertEquals("sourceProduct.2", sourceElement.getAttributeAt(1).getName()); }
@Test public void testProductName() throws Exception { String filePath = GPFFacadeTest.class.getResource("test-product.dim").toURI().getPath(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("file", new File(filePath)); Product p1 = GPF.createProduct("Read", parameters); Product p2 = GPF.createProduct("Foo", GPF.NO_PARAMS, new Product[]{p1}); MetadataElement metadataElement = p2.getMetadataRoot().getElement("Processing_Graph"); MetadataElement sourceElement = null; for (MetadataElement element : metadataElement.getElements()) { if (element.getAttribute("operator").getData().getElemString().equals("Foo")) { sourceElement = element.getElement("sources"); break; } } assertNotNull(sourceElement); assertEquals(1, sourceElement.getNumAttributes()); assertEquals("sourceProduct", sourceElement.getAttributeAt(0).getName()); assertTrue(sourceElement.getAttributeAt(0).getData().getElemString().endsWith("test-product.dim")); }
private void writeSampleCoding(int indent, SampleCoding sampleCoding, String[] fcTags, String tagFlag, String tagName, String tagIndex, String tagDescription) { final String[] names = sampleCoding.getAttributeNames(); for (String name : names) { final MetadataAttribute attribute = sampleCoding.getAttribute(name); final String[] fTags = createTags(indent + 1, tagFlag); println(fTags[0]); printLine(indent + 2, tagName, attribute.getName()); printLine(indent + 2, tagIndex, attribute.getData().getElemInt()); printLine(indent + 2, tagDescription, attribute.getDescription()); println(fTags[1]); } println(fcTags[1]); }
private static void registerSingleFlagSymbols(WritableNamespace namespace, Product product, String namePrefix) { for (int i = 0; i < product.getNumBands(); i++) { final Band band = product.getBandAt(i); if (band.getFlagCoding() != null) { for (int j = 0; j < band.getFlagCoding().getNumAttributes(); j++) { final MetadataAttribute attribute = band.getFlagCoding().getAttributeAt(j); final int flagMask = attribute.getData().getElemInt(); final String symbolName = namePrefix + band.getName() + "." + attribute.getName(); final Symbol symbol = new SingleFlagSymbol(symbolName, band, flagMask); namespace.registerSymbol(symbol); } } } }
private void addFlagCodingElements() { // Übernommen String[] codingNames = getProduct().getFlagCodingGroup().getNodeNames(); for (String codingName : codingNames) { Element flagCodingElem = new Element(DimapProductConstants.TAG_FLAG_CODING); flagCodingElem.setAttribute(DimapProductConstants.ATTRIB_NAME, codingName); _root.addContent(flagCodingElem); FlagCoding flagCoding = getProduct().getFlagCodingGroup().get(codingName); String[] flagNames = flagCoding.getFlagNames(); for (String flagName : flagNames) { MetadataAttribute flag = flagCoding.getFlag(flagName); Element flagElem = new Element(DimapProductConstants.TAG_FLAG); JDomHelper.addElement(DimapProductConstants.TAG_FLAG_NAME, flag.getName(), flagElem); JDomHelper.addElement(DimapProductConstants.TAG_FLAG_INDEX, flag.getData().getElemInt(), flagElem); JDomHelper.addElement(DimapProductConstants.TAG_FLAG_DESCRIPTION, flag.getDescription(), flagElem); flagCodingElem.addContent(flagElem); } } }
for (MetadataAttribute attribute : attributes) { final Element mdAttr = new Element(DimapProductConstants.TAG_METADATA_ATTRIBUTE); mdAttr.setAttribute(DimapProductConstants.ATTRIB_NAME, attribute.getName()); final String description = attribute.getDescription(); if (description != null) {