/** * Get calibration factors for all polarizations. */ private void getCalibrationFactor() { final MetadataElement level1Product = origMetadataRoot.getElement("level1Product"); final MetadataElement calibrationElem = level1Product.getElement("calibration"); final MetadataElement[] subElems = calibrationElem.getElements(); for (MetadataElement ele : subElems) { if (ele.getName().contains("calibrationConstant")) { final String pol = ele.getAttributeString("polLayer").toUpperCase(); final double factor = Double.parseDouble(ele.getAttributeString("calFactor")); calibrationFactor.put(pol, factor); } } }
public void assignMetadataTo(MetadataElement rootElem, int count) { final MetadataElement imgDescElem = new MetadataElement("Image Descriptor " + count); imageFDR.assignMetadataTo(imgDescElem); rootElem.addElement(imgDescElem); if (imageRecords.length > 0 && imageRecords[0] != null) { final MetadataElement imgRecElem = new MetadataElement("Image Record "); imageRecords[0].assignMetadataTo(imgRecElem); imgDescElem.addElement(imgRecElem); } }
protected Dimension getBandDimensions(final MetadataElement newRoot, final String bandMetadataName) { final MetadataElement absRoot = newRoot.getElement(AbstractMetadata.ABSTRACT_METADATA_ROOT); final MetadataElement bandMetadata = absRoot.getElement(bandMetadataName); final int width, height; if(bandMetadata != null) { width = bandMetadata.getAttributeInt(AbstractMetadata.num_samples_per_line); height = bandMetadata.getAttributeInt(AbstractMetadata.num_output_lines); } else { width = absRoot.getAttributeInt(AbstractMetadata.num_samples_per_line); height = absRoot.getAttributeInt(AbstractMetadata.num_output_lines); } return new Dimension(width, height); }
private static MetadataElement getBaselinesElem(final MetadataElement abstractedMetadata) { MetadataElement baselinesElem = abstractedMetadata.getElement("Baselines"); if (baselinesElem == null) { baselinesElem = new MetadataElement("Baselines"); abstractedMetadata.addElement(baselinesElem); } return baselinesElem; }
private double getBandTerrainHeight(final MetadataElement prodElem) { final MetadataElement generalAnnotation = prodElem.getElement("generalAnnotation"); final MetadataElement terrainHeightList = generalAnnotation.getElement("terrainHeightList"); double heightSum = 0.0; final MetadataElement[] heightList = terrainHeightList.getElements(); int cnt = 0; for (MetadataElement terrainHeight : heightList) { heightSum += terrainHeight.getAttributeDouble("value"); ++cnt; } return heightSum / cnt; }
/** * Get calibration constant from product original metadata. */ private void getCalibrationConstant() { final MetadataElement auxElem = origMetadataRoot.getElement("Auxiliary"); final MetadataElement rootElem = auxElem.getElement("Root"); final MetadataElement subSwathsElem = rootElem.getElement("SubSwaths"); final MetadataElement subSwathElem = subSwathsElem.getElement("SubSwath"); calibrationConstant = subSwathElem.getAttributeDouble("CalibrationConstant"); }
private void getPolarizations(final MetadataElement absRoot, final MetadataElement imageAttributes) { final MetadataElement[] imageAttribElems = imageAttributes.getElements(); int i = 0; for (MetadataElement elem : imageAttribElems) { if (elem.getName().equals("ipdf")) { final String pol = elem.getAttributeString("pole", "").toUpperCase(); polarizationMap.put(elem.getAttributeString("ipdf", "").toLowerCase(), pol); absRoot.setAttributeString(AbstractMetadata.polarTags[i], pol); ++i; } } }
MetadataElement warpDataElem = bandElem.getElement("WarpData"); if (warpDataElem == null) { warpDataElem = new MetadataElement("WarpData"); bandElem.addElement(warpDataElem); } else { final MetadataAttribute[] attribList = warpDataElem.getAttributes(); for (MetadataAttribute attrib : attribList) { warpDataElem.removeAttribute(attrib); for (int j = 0; j < numGCPsPerRgLine; j++) { if (velocityData.slvGCPx[i][j] != invalidIndex && velocityData.slvGCPx[i][j] != invalidIndex) { final MetadataElement gcpElem = new MetadataElement("GCP" + k); warpDataElem.addElement(gcpElem); gcpElem.setAttributeDouble("mst_x", velocityData.mstGCPx[i][j]); gcpElem.setAttributeDouble("mst_y", velocityData.mstGCPy[i][j]); gcpElem.setAttributeDouble("slv_x", velocityData.slvGCPx[i][j]); gcpElem.setAttributeDouble("slv_y", velocityData.slvGCPy[i][j]); k++;
@Override public int getRasterWidth() { if (width == 0) { MetadataElement currentElement; if (((currentElement = rootElement.getElement(SpotConstants.SPOT4_TAKE5_TAG_GEOMETRY)) != null)) { width = Integer.parseInt(currentElement.getAttributeString(SpotConstants.SPOT4_TAKE5_TAG_COLS)); } } return width; }
private static MetadataElement findElementContaining(final MetadataElement parent, final String elemName, final String attribName, final String attValue) { final MetadataElement[] elems = parent.getElements(); for (MetadataElement elem : elems) { if (elem.getName().equalsIgnoreCase(elemName) && elem.containsAttribute(attribName)) { String value = elem.getAttributeString(attribName); if (value != null && value.equalsIgnoreCase(attValue)) return elem; } } return null; }
protected static void updateProduct(final Product product, final MetadataElement newRoot) { final MetadataElement root = product.getMetadataRoot(); for(MetadataElement elem : newRoot.getElements()) { root.addElement(elem); } final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); product.setStartTime(absRoot.getAttributeUTC(AbstractMetadata.first_line_time)); product.setEndTime(absRoot.getAttributeUTC(AbstractMetadata.last_line_time)); product.setProductType(absRoot.getAttributeString(AbstractMetadata.PRODUCT_TYPE)); product.setDescription(absRoot.getAttributeString(AbstractMetadata.SPH_DESCRIPTOR)); }
public int[] getCalibrationPixel( final int subSwathIndex, final String polarization, final int vectorIndex) { final MetadataElement calibrationVectorListElem = getCalibrationVectorList(subSwathIndex, polarization); final MetadataElement[] list = calibrationVectorListElem.getElements(); final MetadataElement pixelElem = list[vectorIndex].getElement("pixel"); final String pixel = pixelElem.getAttributeString("pixel"); final int count = Integer.parseInt(pixelElem.getAttributeString("count")); final int[] pixelArray = new int[count]; addToArray(pixelArray, 0, pixel, " "); return pixelArray; }
/** * Helper method that copies the child nodes of a metadata element as child nodes * of another metadata element. * * @param source The metadata element holding the nodes to be copied * @param target The destination metadata element */ public static void CopyChildElements(MetadataElement source, MetadataElement target) { Assert.notNull(source); Assert.notNull(target); MetadataAttribute[] attributes = source.getAttributes(); if (attributes != null) { for (MetadataAttribute attribute : attributes) { if (!target.containsAttribute(attribute.getName()) && !attribute.getName().contains(":")) { target.addAttribute(attribute); } } } while (source.getNumElements() > 0) { MetadataElement currentElement = source.getElementAt(0); target.addElement(currentElement); source.removeElement(currentElement); } }
private void addOrbitStateVectors(final MetadataElement absRoot, final MetadataElement orbit) { final MetadataElement orbitHeader = orbit.getElement("orbitHeader"); AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, ReaderUtils.getTime(orbitHeader, "firstStateTimeUTC", standardDateFormat)); final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); int i = 0; final MetadataElement[] elems = orbit.getElements(); for(MetadataElement stateVec : elems) { if(stateVec.getName().equals("stateVec")) { addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, stateVec, i++); } } }
return; MetadataElement abstractedMetadata = root.getElement("Abstracted_Metadata"); if (abstractedMetadata == null) { return; MetadataElement productElem = abstractedMetadata.getElement("Product_Information"); if (productElem == null) { productElem = new MetadataElement("Product_Information"); abstractedMetadata.addElement(productElem); MetadataElement inputElem = productElem.getElement("InputProducts"); if (inputElem == null) { inputElem = new MetadataElement("InputProducts"); productElem.addElement(inputElem); final MetadataAttribute[] inputProductAttrbList = inputElem.getAttributes(); boolean found = false; for (MetadataAttribute attrib : inputProductAttrbList) {
/** * Get thermal noise correction flag from the original product metadata. */ private void getThermalNoiseCorrectionFlag() { final MetadataElement annotationElem = origMetadataRoot.getElement("annotation"); final MetadataElement[] annotationDataSetListElem = annotationElem.getElements(); final MetadataElement productElem = annotationDataSetListElem[0].getElement("product"); final MetadataElement imageAnnotationElem = productElem.getElement("imageAnnotation"); final MetadataElement processingInformationElem = imageAnnotationElem.getElement("processingInformation"); thermalNoiseCorrectionPerformed = Boolean.parseBoolean( processingInformationElem.getAttribute("thermalNoiseCorrectionPerformed").getData().getElemString()); }
private String createMetadataDouble(final String name, final MetadataElement recElem, final String elemName, String unit) { final MetadataElement elem = recElem.getElement(elemName); final double value = elem.getElement("Values").getAttributeDouble("data", 0); String valueStr = String.valueOf(value); if (value - (int) value != 0) valueStr = frmt.format(value); if (unit == null) { unit = elem.getAttributeString("units"); } return name + ": " + valueStr + " " + unit; }
private boolean isValidYField(MetadataElement metadataElement, String elementName, String nameY) { MetadataElement element = metadataElement.getName().equals(elementName) ? metadataElement : metadataElement.getElement(elementName); return StringUtils.isNotNullAndNotEmpty(nameY) && !MetadataPlotSettings.FIELD_NAME_NONE.equals(nameY) && element != null && element.getAttribute(nameY) != null; }
private static void searchMetadata(final MetadataElement resultElem, final MetadataElement elem, final String tag) { final MetadataElement[] elemList = elem.getElements(); for (MetadataElement e : elemList) { searchMetadata(resultElem, e, tag); } final MetadataAttribute[] attribList = elem.getAttributes(); for (MetadataAttribute attrib : attribList) { if (attrib.getName().toUpperCase().contains(tag)) { final MetadataAttribute newAttrib = attrib.createDeepClone(); newAttrib.setDescription(getAttributePath(attrib)); resultElem.addAttribute(newAttrib); } } }
public SpectraDataAsar(final Product product, final WaveProductType waveProductType) { super(product); setWaveProductType(waveProductType); final MetadataElement root = AbstractMetadata.getOriginalProductMetadata(product); final MetadataElement sph = root.getElement("SPH"); numDirBins = sph.getAttributeInt("NUM_DIR_BINS", 0); numWLBins = sph.getAttributeInt("NUM_WL_BINS", 0); firstDirBins = (float) sph.getAttributeDouble("FIRST_DIR_BIN", 0); dirBinStep = (float) sph.getAttributeDouble("DIR_BIN_STEP", 0); firstWLBin = (float) sph.getAttributeDouble("FIRST_WL_BIN", 0); lastWLBin = (float) sph.getAttributeDouble("LAST_WL_BIN", 0); final RasterDataNode rasterNode = product.getBandAt(0); numRecords = rasterNode.getRasterHeight() - 1; recordLength = rasterNode.getRasterWidth(); if (waveProductType == WaveProductType.WAVE_SPECTRA) { spectraMetadataRoot = root.getElement("OCEAN_WAVE_SPECTRA_MDS"); } else { spectraMetadataRoot = root.getElement("CROSS_SPECTRA_MDS"); } }