private static void extendAttribute(MetadataAttribute attribute, String unit, String description) { if (unit != null) { attribute.setUnit(unit); } if (description != null) { attribute.setDescription(description); } } }
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; }
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; } }
String value = attribute.getStringValue(); if (value != null) { anAttribute.setUnit(value);
/** * Parses an integer attribute from the stream */ private MetadataAttribute parseIntAttribute(int size, String name, String description, String unit) throws IOException { int nData = 0; MetadataAttribute attribute = null; ProductData data = null; nData = parseInt(size); data = ProductData.createInstance(new int[]{nData}); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
/** * Parses an integer array attribute from the stream */ private MetadataAttribute parseIntArrayAttribute(int size, int numElems, String name, String description, String unit) throws IOException { int[] nData = null; MetadataAttribute attribute = null; ProductData data = null; nData = parseIntArray(size, numElems); data = ProductData.createInstance(nData); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
/** * Parses a float attribute from the stream */ private MetadataAttribute parseFloatAttribute(int size, String name, String description, String unit) throws IOException { float fData = 0.f; MetadataAttribute attribute = null; ProductData data = null; fData = parseFloat(size); data = ProductData.createInstance(new float[]{fData}); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return attribute; }
/** * Parses a string attribute from the stream */ private MetadataAttribute parseStringAttribute(int size, String name, String description, String unit) throws IOException { String string = null; MetadataAttribute attribute = null; ProductData data = null; string = parseString(size); data = ProductData.createInstance(string); attribute = new MetadataAttribute(name, data, true); if (description != null) { attribute.setDescription(description); } if (unit != null) { attribute.setUnit(unit); } return 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); }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the double value * @param unit the unit string * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, double value, String unit, MetadataElement dest, String desc) { final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_FLOAT64, 1); attribute.getData().setElems(new double[]{value}); attribute.setUnit(unit); attribute.setDescription(desc); dest.addAttribute(attribute); }
/** * Adds an attribute from src to dest * * @param tag the name of the attribute * @param value the UTC value * @param dest the destination element * @param desc the description */ private static void addAbstractedAttribute(String tag, ProductData.UTC value, MetadataElement dest, String desc) { final MetadataAttribute attribute = new MetadataAttribute(tag, ProductData.TYPE_UTC, 1); attribute.getData().setElems(value.getArray()); attribute.setUnit("utc"); attribute.setDescription(desc); dest.addAttribute(attribute); }
/** * Adds an attribute into dest * * @param dest the destination element * @param tag the name of the attribute * @param dataType the ProductData type * @param unit The unit * @param desc The description * @return MetadataAttribute */ private static MetadataAttribute addAbstractedAttribute(String tag, int dataType, String unit, String desc, MetadataElement dest) { final MetadataAttribute attribute = new MetadataAttribute(tag, dataType, 1); if (dataType == ProductData.TYPE_ASCII) attribute.getData().setElems(" "); attribute.setUnit(unit); attribute.setDescription(desc); attribute.setReadOnly(false); dest.addAttribute(attribute); return attribute; }
attribute.setUnit(field.getInfo().getPhysicalUnit());
data = ProductData.createInstance(new float[]{fData}); attribute = new MetadataAttribute(REFERENCE_UT_FIELD_NAME, data, true); attribute.setUnit(REFERENCE_UT_UNIT); attribute.setDescription(REFERENCE_UT_DESCRIPTION); _mph.addAttribute(attribute); data.setElemUInt(nData); attribute = new MetadataAttribute(REFERENCE_ERS_CLOCK_TIME_NAME, data, true); attribute.setUnit(REFERENCE_ERS_CLOCK_UNIT); attribute.setDescription(REFERENCE_ERS_CLOCK_TIME_DESCRIPTION); _mph.addAttribute(attribute); data.setElemUInt(nData); attribute = new MetadataAttribute(REFERENCE_ERS_CLOCK_PERIOD_NAME, data, true); attribute.setUnit(REFERENCE_ERS_CLOCK_UNIT); attribute.setDescription(REFERENCE_ERS_CLOCK_PERIOD_DESCRIPTION); _mph.addAttribute(attribute);
public MetadataAttribute createDeepClone() { MetadataAttribute clone = new MetadataAttribute(getName(), getData().createDeepClone(), isReadOnly()); clone.setDescription(getDescription()); clone.setSynthetic(isSynthetic()); clone.setUnit(getUnit()); return clone; } }
private void handleMetadataGroup(Group group, MetadataElement metadataElement) throws ProductIOException { List<Variable> variables = group.getVariables(); for (Variable variable : variables) { final String name = variable.getShortName(); final int dataType = getProductDataType(variable); Array array; try { array = variable.read(); } catch (IOException e) { throw new ProductIOException(e.getMessage(), e); } final ProductData data = ProductData.createInstance(dataType, array.getStorage()); final MetadataAttribute attribute = new MetadataAttribute("data", data, true); final MetadataElement sdsElement = new MetadataElement(name); sdsElement.addAttribute(attribute); metadataElement.addElement(sdsElement); final List<Attribute> list = variable.getAttributes(); for (Attribute hdfAttribute : list) { final String attribName = hdfAttribute.getShortName(); if ("units".equals(attribName)) { attribute.setUnit(hdfAttribute.getStringValue()); } else if ("long_name".equals(attribName)) { attribute.setDescription(hdfAttribute.getStringValue()); } else { addAttributeToElement(sdsElement, hdfAttribute); } } } }
attri.setUnit(unit.toString());
static MetadataElement createMetadataGroup(String name, Record record) { Debug.assertNotNullOrEmpty(name); Debug.assertNotNull(record); MetadataElement metadataGroup = new MetadataElement(name); for (int i = 0; i < record.getNumFields(); i++) { Field field = record.getFieldAt(i); String description = field.getInfo().getDescription(); if (description != null) { if ("Spare".equalsIgnoreCase(description)) { continue; } } MetadataAttribute attribute = new MetadataAttribute(field.getName(), field.getData(), true); if (field.getInfo().getPhysicalUnit() != null) { attribute.setUnit(field.getInfo().getPhysicalUnit()); } if (description != null) { attribute.setDescription(field.getInfo().getDescription()); } metadataGroup.addAttribute(attribute); } return metadataGroup; }
attribute.getData().setElemFloat(chrisFile.getCutOnWavelength(i)); attribute.setDescription("Cut-on wavelength"); attribute.setUnit("nm"); element.addAttribute(attribute); attribute.getData().setElemFloat(chrisFile.getCutOffWavelength(i)); attribute.setDescription("Cut-off wavelength"); attribute.setUnit("nm"); element.addAttribute(attribute); attribute.getData().setElemFloat(chrisFile.getWavelength(i)); attribute.setDescription("Central wavelength"); attribute.setUnit("nm"); element.addAttribute(attribute); attribute.getData().setElemFloat(chrisFile.getBandwidth(i)); attribute.setDescription("Cut-off minus cut-on wavelength"); attribute.setUnit("nm"); element.addAttribute(attribute);
MetadataAttribute tempAttri = createAttribute(LandsatConstants.RADIANCE_DESCRIPTION_SHORT[j], radData[j]); tempAttri.setUnit(LandsatConstants.Unit.RADIANCE.toString()); tempAttri.setDescription(LandsatConstants.RADIANCE_DESCRIPTION[j]); band.addAttribute(tempAttri);