Example #1
0
  /** Interpretes the bins of the temporal database if algorithm needs this to be done. */
  protected void processBinIterpretation(ProgressMonitor pm) throws IOException {
    getLogger().info(L3Constants.LOG_MSG_INTERPRETE_BIN_CONTENT);

    final int rowOffset = temporalDB.getRowOffset();
    final int colOffset = temporalDB.getColOffset();
    final int width = temporalDB.getWidth();
    final int height = temporalDB.getHeight();
    Point rowcol = new Point();
    Bin tempBin = temporalDB.createBin();
    Bin finalBin = finalDB.createBin();

    pm.beginTask(L3Constants.LOG_MSG_INTERPRETE_BIN_CONTENT, height - rowOffset);
    try {
      for (int row = rowOffset; row < rowOffset + height; row++) {
        rowcol.y = row;
        for (int col = colOffset; col < colOffset + width; col++) {
          rowcol.x = col;

          temporalDB.read(rowcol, tempBin);
          final L3Context.BandDefinition[] bandDefinitions = context.getBandDefinitions();
          for (int bandIndex = 0; bandIndex < bandDefinitions.length; bandIndex++) {
            final L3Context.BandDefinition bandDef = bandDefinitions[bandIndex];
            final Algorithm algo = bandDef.getAlgorithm();
            tempBin.setBandIndex(bandIndex);
            finalBin.setBandIndex(bandIndex);
            algo.interprete(tempBin, finalBin);
          }
          finalDB.write(rowcol, finalBin);
        }

        // update progressbar
        pm.worked(1);
        if (pm.isCanceled()) {
          getLogger().warning(L3Constants.LOG_MSG_PROC_CANCELED);
          setCurrentState(L3Constants.STATUS_ABORTED);
          break;
        }
      }

    } finally {
      pm.done();
      finalDB.flush();
    }

    getLogger().info(ProcessorConstants.LOG_MSG_SUCCESS);
  }