Ejemplo n.º 1
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);
  }
  /**
   * Initializes this operator and sets the one and only target product.
   *
   * <p>The target product can be either defined by a field of type {@link Product} annotated with
   * the {@link TargetProduct TargetProduct} annotation or by calling {@link #setTargetProduct}
   * method.
   *
   * <p>The framework calls this method after it has created this operator. Any client code that
   * must be performed before computation of tile data should be placed here.
   *
   * @throws OperatorException If an error occurs during operator initialisation.
   * @see #getTargetProduct()
   */
  @Override
  public void initialize() throws OperatorException {

    try {
      targetProduct =
          new Product(
              sourceProduct.getName(),
              sourceProduct.getProductType(),
              sourceProduct.getSceneRasterWidth(),
              sourceProduct.getSceneRasterHeight());

      ProductUtils.copyProductNodes(sourceProduct, targetProduct);

      dataType = ProductData.getType(targetDataType);
      targetScaling = getScaling(targetScalingStr);

      addSelectedBands();

    } catch (Throwable e) {
      throw new OperatorException(e);
    }
  }