Example #1
0
  private void updateMetadata() {
    final Product targetProduct = super.getTargetProduct();
    final MetadataElement root = targetProduct.getMetadataRoot();
    if (root == null) {
      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) {
      if (attrib.getData().getElemString().equals(targetProduct.getName())) found = true;
    }
    if (!found) {
      final MetadataAttribute inputAttrb =
          addAttribute(inputElem, "InputProduct", ProductData.TYPE_ASCII, "", "");
      inputAttrb.getData().setElems(targetProduct.getName());
    }
  }
Example #2
0
  /** Create target product. */
  private void createTargetProduct() {

    targetProduct =
        new Product(
            sourceProduct.getName(),
            sourceProduct.getProductType(),
            sourceImageWidth,
            sourceImageHeight);

    ProductUtils.copyProductNodes(sourceProduct, targetProduct);

    addSelectedBands();

    final MetadataElement absTgt = AbstractMetadata.getAbstractedMetadata(targetProduct);

    if (externalDEMFile != null) { // if external DEM file is specified by user
      AbstractMetadata.setAttribute(absTgt, AbstractMetadata.DEM, externalDEMFile.getPath());
    } else {
      AbstractMetadata.setAttribute(absTgt, AbstractMetadata.DEM, demName);
    }

    absTgt.setAttributeString("DEM resampling method", demResamplingMethod);

    if (externalDEMFile != null) {
      absTgt.setAttributeDouble("external DEM no data value", externalDEMNoDataValue);
    }

    sourceGeoCoding = sourceProduct.getSceneGeoCoding();

    targetProduct.setPreferredTileSize(targetProduct.getSceneRasterWidth(), tileSize);
  }
Example #3
0
 public static MetadataAttribute addAttribute(
     final MetadataElement dest,
     final String tag,
     final int dataType,
     final String unit,
     final String desc) {
   final MetadataAttribute attribute = new MetadataAttribute(tag, dataType, 1);
   attribute.setUnit(unit);
   attribute.setDescription(desc);
   attribute.setReadOnly(true);
   dest.addAttribute(attribute);
   return attribute;
 }
Example #4
0
  /**
   * Retrieve required data from Abstracted Metadata
   *
   * @throws Exception if metadata not found
   */
  private void getMetadata() throws Exception {

    srgrFlag = AbstractMetadata.getAttributeBoolean(absRoot, AbstractMetadata.srgr_flag);
    wavelength = SARUtils.getRadarFrequency(absRoot);
    rangeSpacing = AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.range_spacing);
    firstLineUTC = absRoot.getAttributeUTC(AbstractMetadata.first_line_time).getMJD(); // in days
    lastLineUTC = absRoot.getAttributeUTC(AbstractMetadata.last_line_time).getMJD(); // in days
    lineTimeInterval =
        absRoot.getAttributeDouble(AbstractMetadata.line_time_interval)
            / Constants.secondsInDay; // s to day
    orbitStateVectors = AbstractMetadata.getOrbitStateVectors(absRoot);

    if (srgrFlag) {
      srgrConvParams = AbstractMetadata.getSRGRCoefficients(absRoot);
    } else {
      nearEdgeSlantRange =
          AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.slant_range_to_first_pixel);
    }

    final TiePointGrid incidenceAngle = OperatorUtils.getIncidenceAngle(sourceProduct);
    nearRangeOnLeft = SARGeocoding.isNearRangeOnLeft(incidenceAngle, sourceImageWidth);
  }