示例#1
0
  private void processSource(Product sourceProduct, SpatialBinner spatialBinner)
      throws IOException {
    final StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    updateDateRangeUtc(sourceProduct);
    metadataAggregator.aggregateMetadata(sourceProduct);

    final String productName = sourceProduct.getName();
    getLogger().info(String.format("Spatial binning of product '%s'...", productName));
    getLogger().fine(String.format("Product start time: '%s'", sourceProduct.getStartTime()));
    getLogger().fine(String.format("Product end time:   '%s'", sourceProduct.getEndTime()));
    if (region != null) {
      SubsetOp subsetOp = new SubsetOp();
      subsetOp.setSourceProduct(sourceProduct);
      subsetOp.setGeoRegion(region);
      sourceProduct = subsetOp.getTargetProduct();
      // TODO mz/nf/mp 2013-11-06: avoid creation of subset products
      //  - replace subset with rectangle as parameter to SpatialProductBinner
      //  - grow rectangle by binSize in pixel units (see lc-tools of LC-CCI project)
    }
    final long numObs =
        SpatialProductBinner.processProduct(
            sourceProduct, spatialBinner, addedVariableBands, ProgressMonitor.NULL);
    stopWatch.stop();

    getLogger()
        .info(
            String.format(
                "Spatial binning of product '%s' done, %d observations seen, took %s",
                productName, numObs, stopWatch));

    if (region == null && regionArea != null) {
      for (GeneralPath generalPath : ProductUtils.createGeoBoundaryPaths(sourceProduct)) {
        try {
          Area area = new Area(generalPath);
          regionArea.add(area);
        } catch (Throwable e) {
          getLogger()
              .log(
                  Level.SEVERE,
                  String.format("Failed to handle product boundary: %s", e.getMessage()),
                  e);
          // sometimes the Area constructor throw an "java.lang.InternalError: Odd number of new
          // curves!"
          // then just ignore this geometry
        }
      }
    }

    ++numProductsAggregated;
  }
示例#2
0
 private static Product copyProduct(Product writtenProduct) {
   Product targetProduct =
       new Product(
           writtenProduct.getName(),
           writtenProduct.getProductType(),
           writtenProduct.getSceneRasterWidth(),
           writtenProduct.getSceneRasterHeight());
   targetProduct.setStartTime(writtenProduct.getStartTime());
   targetProduct.setEndTime(writtenProduct.getEndTime());
   ProductUtils.copyMetadata(writtenProduct, targetProduct);
   ProductUtils.copyGeoCoding(writtenProduct, targetProduct);
   ProductUtils.copyTiePointGrids(writtenProduct, targetProduct);
   ProductUtils.copyMasks(writtenProduct, targetProduct);
   ProductUtils.copyVectorData(writtenProduct, targetProduct);
   for (Band band : writtenProduct.getBands()) {
     // Force setting source image, otherwise GPF will set an OperatorImage and invoke
     // computeTile()!!
     ProductUtils.copyBand(band.getName(), writtenProduct, targetProduct, true);
   }
   return targetProduct;
 }