本文整理了Java中org.esa.beam.framework.datamodel.MetadataElement.getAttributeString()
方法的一些代码示例,展示了MetadataElement.getAttributeString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetadataElement.getAttributeString()
方法的具体详情如下:
包路径:org.esa.beam.framework.datamodel.MetadataElement
类名称:MetadataElement
方法名:getAttributeString
[英]Returns the string value of the attribute with the given name.
An Exception is thrown if an attribute with the given name could not be found in this node.
[中]返回具有给定名称的属性的字符串值。
如果在此节点中找不到具有给定名称的属性,将引发异常。
代码示例来源:origin: bcdev/beam
@Override
public boolean isEoVariableSelected(String variableName) {
final MetadataElement[] variables = getVariableMetadataElements();
for (MetadataElement elem : variables) {
if (elem.getAttributeString(VARIABLE_NAME).equals(variableName)) {
return Boolean.parseBoolean(elem.getAttributeString(VARIABLE_SELECTION));
}
}
return false;
}
代码示例来源:origin: bcdev/beam
boolean isLandsatETM_Plus() {
final MetadataElement productMetadata = getProductMetadata();
return "ETM+".equals(productMetadata.getAttributeString(SENSOR_ID));
}
代码示例来源:origin: bcdev/beam
@Override
public List
MetadataElement[] variableElems = getVariableMetadataElements();
List
for (MetadataElement varElem : variableElems) {
variables.add(varElem.getAttributeString(VARIABLE_NAME));
}
return variables;
}
代码示例来源:origin: bcdev/beam
boolean isLandsatTM() {
final MetadataElement productMetadata = getProductMetadata();
return "TM".equals(productMetadata.getAttributeString(SENSOR_ID));
}
代码示例来源:origin: bcdev/beam
protected ProductData.UTC getCenterTime(String acquisitionDateKey, String sceneCenterScanTimeKey) {
MetadataElement metadata = getProductMetadata();
String dateString = metadata.getAttributeString(acquisitionDateKey);
String timeString = metadata.getAttributeString(sceneCenterScanTimeKey);
try {
if (dateString != null && timeString != null) {
timeString = timeString.substring(0, 12);
final DateFormat dateFormat = ProductData.UTC.createDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
final Date date = dateFormat.parse(dateString + " " + timeString);
String milliSecOnds= timeString.substring(timeString.length() - 3);
return ProductData.UTC.create(date, Long.parseLong(milliSeconds) * 1000);
}
} catch (ParseException ignored) {
// ignore
}
return null;
}
代码示例来源:origin: bcdev/beam
private void removeAttributeWithValue(String attributeName, String value, MetadataElement parentElement) {
final MetadataElement[] childElements = parentElement.getElements();
for (MetadataElement elem : childElements) {
if (elem.getAttributeString(attributeName).equals(value)) {
parentElement.removeElement(elem);
return;
}
}
}
代码示例来源:origin: bcdev/beam
private void initProductLocations() {
MetadataElement tsElem = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME);
MetadataElement productListElem = tsElem.getElement(PRODUCT_LOCATIONS);
MetadataElement[] productElems = productListElem.getElements();
productLocatiOnList= new ArrayList
final File fileLocation = tsProduct.getProduct().getFileLocation();
for (MetadataElement productElem : productElems) {
String path = productElem.getAttributeString(PL_PATH);
File productFile;
if (fileLocation != null) {
final URI resolvedUri = fileLocation.toURI().resolve(path);
productFile = new File(resolvedUri);
} else {
productFile = new File(path);
}
String type = productElem.getAttributeString(PL_TYPE);
productLocationList.add(new ProductLocation(ProductLocationType.valueOf(type), productFile.getAbsolutePath()));
}
}
代码示例来源:origin: bcdev/beam
public static ReprocessingVersion autoDetect(Product product) {
final MetadataElement dsdElement = product.getMetadataRoot().getElement(ELEM_NAME_DSD);
if (dsdElement != null) {
MetadataElement[] dsdElements = dsdElement.getElements();
for (MetadataElement element : dsdElements) {
String datasetName = element.getAttributeString("DATASET_NAME", "").toLowerCase();
if (datasetName.startsWith("radiometric") && datasetName.contains("calibration")) {
final String calibratiOnFileName= element.getAttributeString(ATTRIBUTE_FILE_NAME);
if (StringUtils.isNotNullAndNotEmpty(calibrationFileName)) {
final boolean reduced = product.getProductType().startsWith(REDUCED_RESOLUTION_PREFIX);
final ReprocessingVersion version = detectReprocessingVersion(calibrationFileName, reduced);
if (!ReprocessingVersion.AUTO_DETECT.equals(version)) {
return version;
}
}
}
}
}
return ReprocessingVersion.AUTO_DETECT;
}
代码示例来源:origin: bcdev/beam
@Override
public boolean isAutoAdjustingTimeCoding() {
final MetadataElement tsRootElement = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME);
if (!tsRootElement.containsAttribute(AUTO_ADJUSTING_TIME_CODING)) {
setAutoAdjustingTimeCoding(true);
}
final String autoAdjustString = tsRootElement.getAttributeString(AUTO_ADJUSTING_TIME_CODING);
return Boolean.parseBoolean(autoAdjustString);
}
代码示例来源:origin: bcdev/beam
private static void initParameter(MetadataElement parentElement, Field field,
Map
OperatorException {
Parameter annotation = field.getAnnotation(Parameter.class);
String name = annotation.alias();
if (name.isEmpty()) {
name = field.getName();
}
try {
if (parentElement.containsAttribute(name)) {
final Converter cOnverter= getConverter(field.getType(), annotation);
final String parameterText = parentElement.getAttributeString(name);
final Object value = converter.parse(parameterText);
parameters.put(name, value);
} else {
final MetadataElement element = parentElement.getElement(name);
if (element != null) {
final Object obj = field.getType().newInstance();
final HashMap
collectParameters(obj.getClass(), element, objParams);
initObject(objParams, obj);
parameters.put(name, obj);
}
}
} catch (Exception e) {
throw new OperatorException(String.format("Cannot initialise operator parameter '%s'", name), e);
}
}
代码示例来源:origin: bcdev/beam
public static Map
final MetadataElement graphElement = product.getMetadataRoot().getElement("Processing_Graph");
if (graphElement == null) {
throw new OperatorException("Product has no metadata element named 'Processing_Graph'");
}
final String operatorAlias = "Mosaic";
final Map
boolean operatorFound = false;
for (MetadataElement nodeElement : graphElement.getElements()) {
if (operatorAlias.equals(nodeElement.getAttributeString("operator"))) {
operatorFound = true;
collectParameters(MosaicOp.class, nodeElement.getElement("parameters"), parameters);
}
}
if (!operatorFound) {
throw new OperatorException("No metadata found for operator '" + operatorAlias + "'");
}
return parameters;
}
代码示例来源:origin: bcdev/beam
private static void replaceWithRelativePaths(MetadataElement[] elements, File outputDir) {
for (MetadataElement element : elements) {
final String pathName = element.getAttributeString(AbstractTimeSeries.PL_PATH);
final URI relativeUri = FileUtils.getRelativeUri(outputDir.toURI(), new File(pathName));
final MetadataAttribute pathAttr = element.getAttribute(AbstractTimeSeries.PL_PATH);
final MetadataAttribute typeAttr = element.getAttribute(AbstractTimeSeries.PL_TYPE);
element.removeAttribute(pathAttr);
element.removeAttribute(typeAttr);
pathAttr.dispose();
final MetadataAttribute newPathAttr = new MetadataAttribute(AbstractTimeSeries.PL_PATH, ProductData.createInstance(relativeUri.toString()), true);
element.addAttribute(newPathAttr);
element.addAttribute(typeAttr);
}
}
代码示例来源:origin: bcdev/beam
@Override
public void setEoVariableSelected(String variableName, boolean selected) {
// set in metadata
final MetadataElement[] variables = getVariableMetadataElements();
for (MetadataElement elem : variables) {
if (elem.getAttributeString(VARIABLE_NAME).equals(variableName)) {
elem.setAttributeString(VARIABLE_SELECTION, String.valueOf(selected));
}
}
// set in product
if (selected) {
for (Product product : getAllProducts(ProgressMonitor.NULL)) {
addSpecifiedBandOfGivenProduct(variableName, product);
}
} else {
final Band[] bands = tsProduct.getBands();
for (Band band : bands) {
if (variableName.equals(rasterToVariableName(band.getName()))) {
tsProduct.removeBand(band);
}
}
}
fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_EO_VARIABLE_SELECTION, null, this));
}
代码示例来源:origin: bcdev/beam
private void updateMetadata(Product product) {
final MetadataElement graphElement = product.getMetadataRoot().getElement("Processing_Graph");
for (MetadataElement nodeElement : graphElement.getElements()) {
if (getSpi().getOperatorAlias().equals(nodeElement.getAttributeString("operator"))) {
final MetadataElement sourcesElement = nodeElement.getElement("sources");
for (int i = 0; i
final String newIndex = String.valueOf(sourcesElement.getNumAttributes() + i + 1);
final Product sourceProduct = sourceProducts[i];
final String attributeName = getSourceProductId(sourceProduct).replaceFirst(oldIndex, newIndex);
final File location = sourceProduct.getFileLocation();
final ProductData attributeValue;
if (location == null) {
attributeValue = ProductData.createInstance(product.toString());
} else {
attributeValue = ProductData.createInstance(location.getPath());
}
final MetadataAttribute attribute = new MetadataAttribute(attributeName, attributeValue, true);
sourcesElement.addAttribute(attribute);
}
}
}
}
代码示例来源:origin: bcdev/beam
private MetadataElement getSourcesElement(MosaicOp mosaicUpdateOp, MetadataElement mosaicMetadata) {
for (MetadataElement element : mosaicMetadata.getElements()) {
if (mosaicUpdateOp.getSpi().getOperatorAlias().equals(element.getAttributeString("operator"))) {
return element.getElement("sources");
}
}
return null;
}
代码示例来源:origin: bcdev/beam
private String getPathString(final String tsMetadataName, int idx) {
return testProduct.getMetadataRoot()
.getElement(AbstractTimeSeries.TIME_SERIES_ROOT_NAME)
.getElement(tsMetadataName)
.getElement(tsMetadataName + "." + idx)
.getAttributeString(AbstractTimeSeries.PL_PATH);
}
代码示例来源:origin: bcdev/beam
addAbstractedAttribute("PRODUCT", mph.getAttributeString("PRODUCT", ""), absRoot, "Product name");
addAbstractedAttribute("PRODUCT_TYPE", _productType, absRoot, "Product type");
addAbstractedAttribute("SPH_DESCRIPTOR", sph.getAttributeString("SPH_DESCRIPTOR", ""), absRoot, "Description");
addAbstractedAttribute("MISSION", getMission(_productType, _file), absRoot, "Satellite mission");
addAbstractedAttribute("BEAMS", " ", absRoot, "Beams used");
if (waveProduct) {
addAbstractedAttribute("SWATH", sph.getAttributeString("SWATH_1", ""), absRoot, "Swath name");
} else {
addAbstractedAttribute("SWATH", sph.getAttributeString("SWATH", ""), absRoot, "Swath Name");
addAbstractedAttribute("Processing_system_identifier", mph.getAttributeString("SOFTWARE_VER", ""), absRoot,
"Processing system identifier");
addAbstractedAttribute(mph, "CYCLE", absRoot, "Cycle");
addAbstractedAttribute("STATE_VECTOR_TIME", mph.getAttributeUTC("STATE_VECTOR_TIME", new ProductData.UTC(0)), absRoot,
"Time of orbit state vector");
addAbstractedAttribute("VECTOR_SOURCE", mph.getAttributeString("VECTOR_SOURCE", ""), absRoot,
"State vector source");
String mds1_tx_rx_polar = sph.getAttributeString("tx_rx_polar", "");
mds1_tx_rx_polar = mds1_tx_rx_polar.replace("/", "");
addAbstractedAttribute("mds1_tx_rx_polar", mds1_tx_rx_polar, absRoot, "Polarization");
addAbstractedAttribute("PASS", sph.getAttributeString("PASS", ""), absRoot, "ASCENDING or DESCENDING");
addAbstractedAttribute("SAMPLE_TYPE", sph.getAttributeString("SAMPLE_TYPE").trim(), absRoot, "DETECTED or COMPLEX");
String mds1_tx_rx_polar = sph.getAttributeString("mds1_tx_rx_polar", "");
mds1_tx_rx_polar = mds1_tx_rx_polar.replace("/", "");
代码示例来源:origin: bcdev/beam
@Test
public void testProcessingGraphInMetadata() {
// using the SubsetOp here, because when using a TestOperator the module.xml is not found
OperatorSpiRegistry operatorSpiRegistry = GPF.getDefaultInstance().getOperatorSpiRegistry();
if (operatorSpiRegistry.getOperatorSpi("Subset") == null) {
operatorSpiRegistry.addOperatorSpi(new SubsetOp.Spi());
}
final Operator testOp = operatorSpiRegistry.getOperatorSpi("Subset").createOperator();
testOp.setSourceProduct(new Product("dummy", "T", 10, 10));
Product targetProduct = testOp.getTargetProduct();
MetadataElement metadataRoot = targetProduct.getMetadataRoot();
MetadataElement elementPG = metadataRoot.getElement(OperatorContext.PROCESSING_GRAPH_ELEMENT_NAME);
assertNotNull(elementPG);
MetadataElement node0Element = elementPG.getElement("node.0");
assertNotNull(node0Element);
assertEquals(9, node0Element.getNumAttributes());
assertNotNull(node0Element.getAttribute("id"));
assertNotNull(node0Element.getAttribute("operator"));
assertNotNull(node0Element.getAttribute("moduleName"));
assertEquals("beam-gpf", node0Element.getAttributeString("moduleName"));
assertNotNull(node0Element.getAttribute("moduleVersion"));
assertNotNull(node0Element.getAttribute("processingTime"));
}