예제 #1
0
  private static void setSubsetSRGRCoefficients(
      final Product sourceProduct,
      final Product targetProduct,
      final ProductSubsetDef subsetDef,
      final MetadataElement absRoot,
      final boolean nearRangeOnLeft) {

    final MetadataElement SRGRCoefficientsElem = absRoot.getElement("SRGR_Coefficients");
    if (SRGRCoefficientsElem != null) {
      final double rangeSpacing = absRoot.getAttributeDouble("RANGE_SPACING", 0);
      final double colIndex = subsetDef.getRegion() == null ? 0 : subsetDef.getRegion().getX();

      for (MetadataElement srgrList : SRGRCoefficientsElem.getElements()) {
        final double grO = srgrList.getAttributeDouble("ground_range_origin", 0);
        double ground_range_origin_subset;
        if (nearRangeOnLeft) {
          ground_range_origin_subset = grO + colIndex * rangeSpacing;
        } else {
          final double colIndexFromRight =
              sourceProduct.getSceneRasterWidth() - colIndex - targetProduct.getSceneRasterWidth();
          ground_range_origin_subset = grO + colIndexFromRight * rangeSpacing;
        }
        srgrList.setAttributeDouble("ground_range_origin", ground_range_origin_subset);
      }
    }
  }