public static void assertIntAttribute(MetadataElement elem, String attributeName, int expectedValue) { final MetadataAttribute attribute = elem.getAttribute(attributeName); assertNotNull(attribute); assertEquals(ProductData.TYPE_INT32, attribute.getDataType()); assertEquals(1, attribute.getNumDataElems()); assertEquals(expectedValue, attribute.getData().getElemInt()); }
/** * Gets the sample value at the specified attribute index. * * @param index the attribute index. * @return the sample value. */ public int getSampleValue(int index) { return getAttributeAt(index).getData().getElemInt(); }
protected String getProductType(String productTypeKey) { final MetadataAttribute product_type = getProductMetadata().getAttribute(productTypeKey); final MetadataAttribute spacecraft_id = getProductMetadata().getAttribute("SPACECRAFT_ID"); final MetadataAttribute sensor_id = getProductMetadata().getAttribute("SENSOR_ID"); final StringBuilder result = new StringBuilder(); result.append(spacecraft_id.getData().getElemString()); result.append("_"); result.append(sensor_id.getData().getElemString()); result.append("_"); result.append(product_type.getData().getElemString()); return result.toString(); }
protected Dimension getDimension(String widthAttributeName, String heightAttributeName) { MetadataElement metadata = getProductMetadata(); MetadataAttribute widthAttribute = metadata.getAttribute(widthAttributeName); MetadataAttribute heightAttribute = metadata.getAttribute(heightAttributeName); if (widthAttribute != null && heightAttribute != null) { int width = widthAttribute.getData().getElemInt(); int height = heightAttribute.getData().getElemInt(); return new Dimension(width, height); } else { return null; } }
private void writeAttributes(PrintWriter out, MetadataElement element) { final MetadataAttribute[] attributes = element.getAttributes(); for (MetadataAttribute attribute : attributes) { out.print(createAttributeName(attribute) + "\t"); out.print(attribute.getData().getElemString() + "\t"); out.print(attribute.getUnit() + "\t"); out.print(attribute.getDescription() + "\t\n"); } final MetadataElement[] subElements = element.getElements(); for (MetadataElement subElement : subElements) { writeAttributes(out, subElement); } }
private static void addIDNode(final MetadataElement absRoot, final MetadataElement identNode, final String title, final String tag) { final MetadataAttribute attrib = absRoot.getAttribute(tag); if (attrib == null) return; final String value = title + ": " + attrib.getData().getElemString(); final MetadataElement newAttrib = new MetadataElement(value); identNode.addElement(newAttrib); }
private static float getSolarFluxFromMetadata(MetadataElement metadataRoot, int bandIndex) { if (metadataRoot != null) { MetadataElement scalingFactorGads = metadataRoot.getElement("Scaling_Factor_GADS"); if (scalingFactorGads != null) { MetadataAttribute sunSpecFlux = scalingFactorGads.getAttribute("sun_spec_flux"); ProductData data = sunSpecFlux.getData(); if (data.getNumElems() > bandIndex) { return data.getElemFloatAt(bandIndex); } } } return 0.0f; }
/** * Sets the attribute with the given name to the given double value. <p>A new attribute with * <code>ProductData.TYPE_FLOAT64</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 setAttributeDouble(String name, double value) { final MetadataAttribute attribute = getAndMaybeCreateAttribute(name, ProductData.TYPE_FLOAT64, 1); attribute.getData().setElemDouble(value); attribute.fireProductNodeDataChanged(); setModified(true); }
/** * 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); }
/** * Sets the attribute with the given name to the given string value. <p>A new attribute with * <code>ProductData.TYPE_ASCII</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 setAttributeString(String name, String value) { final MetadataAttribute attribute = getAndMaybeCreateAttribute(name, ProductData.TYPE_ASCII, 1); attribute.getData().setElems(value); attribute.fireProductNodeDataChanged(); setModified(true); }
/** * Sets the attribute with the given name to the given utc value. <p>A new attribute with * <code>ProductData.UTC</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 setAttributeUTC(String name, ProductData.UTC value) { final MetadataAttribute attribute = getAndMaybeCreateAttribute(name, ProductData.TYPE_UTC, 1); attribute.getData().setElems(value.getArray()); attribute.fireProductNodeDataChanged(); setModified(true); }
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); } }
public static void assertStringAttribute(MetadataElement elem, String attibuteName, String expectedValue) { final MetadataAttribute attribute = elem.getAttribute(attibuteName); assertNotNull(attribute); assertEquals(ProductData.TYPESTRING_ASCII, attribute.getData().getTypeString()); assertEquals(expectedValue, attribute.getData().getElemString()); }
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()); } }
public LandsatReprocessedMetadata(FileReader fileReader) throws IOException { super(fileReader); landsatLegacyMetadataDelegate = new LandsatLegacyMetadata(getMetaDataElementRoot()); landsat8MetadataDelegate = new Landsat8Metadata(getMetaDataElementRoot()); sensorId = getMetaDataElementRoot().getElement("PRODUCT_METADATA").getAttribute("SENSOR_ID").getData().getElemString(); }
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; } }
static void assertInputElementAt(int index, String inputName, MetadataElement metadataElement) { final MetadataElement productElement = metadataElement.getElementAt(index); assertEquals("source." + Integer.toString(index), productElement.getName()); final MetadataAttribute nameAttribute = productElement.getAttribute("name"); assertNotNull(nameAttribute); assertEquals(inputName, nameAttribute.getData().getElemString()); }