コード例 #1
0
  private void copyStx(RasterDataNode sourceRaster, RasterDataNode targetRaster) {
    final Stx sourceStx = sourceRaster.getStx();
    final Histogram sourceHistogram = sourceStx.getHistogram();
    final Histogram targetHistogram =
        new Histogram(
            sourceStx.getHistogramBinCount(),
            sourceHistogram.getLowValue(0),
            sourceHistogram.getHighValue(0),
            1);

    System.arraycopy(
        sourceHistogram.getBins(0),
        0,
        targetHistogram.getBins(0),
        0,
        sourceStx.getHistogramBinCount());

    final Stx targetStx =
        new Stx(
            sourceStx.getMinimum(),
            sourceStx.getMaximum(),
            sourceStx.getMean(),
            sourceStx.getStandardDeviation(),
            sourceStx.getCoefficientOfVariation(),
            sourceStx.getEquivalentNumberOfLooks(),
            sourceStx.isLogHistogram(),
            sourceStx.isIntHistogram(),
            targetHistogram,
            sourceStx.getResolutionLevel());

    targetRaster.setStx(targetStx);
  }
コード例 #2
0
 private static void copyData(
     ProductData sourceBuffer,
     int sourcePos,
     ProductData destBuffer,
     int destPos,
     int destLength) {
   System.arraycopy(
       sourceBuffer.getElems(), sourcePos, destBuffer.getElems(), destPos, destLength);
 }
コード例 #3
0
ファイル: L3BinFileReader.java プロジェクト: bcdev/beam
  @Override
  public synchronized void readBandData(
      Band destBand,
      int sourceOffsetX,
      int sourceOffsetY,
      int sourceWidth,
      int sourceHeight,
      int sourceStepX,
      int sourceStepY,
      ProductData destBuffer,
      ProgressMonitor pm)
      throws IOException, InvalidRangeException {

    final Variable variable = variableMap.get(destBand);
    DataType prodtype = variable.getDataType();
    float[] fbuffer;
    short[] sbuffer;
    int[] ibuffer;
    byte[] bbuffer;
    Object buffer;

    if (prodtype == DataType.FLOAT) {
      fbuffer = (float[]) destBuffer.getElems();
      Arrays.fill(fbuffer, Float.NaN);
      buffer = fbuffer;
    } else if (prodtype == DataType.SHORT) {
      sbuffer = (short[]) destBuffer.getElems();
      Arrays.fill(sbuffer, (short) -999);
      buffer = sbuffer;
    } else if (prodtype == DataType.BYTE) {
      bbuffer = (byte[]) destBuffer.getElems();
      Arrays.fill(bbuffer, (byte) 255);
      buffer = bbuffer;
    } else {
      ibuffer = (int[]) destBuffer.getElems();
      Arrays.fill(ibuffer, -999);
      buffer = ibuffer;
    }

    if (rowInfo == null) {
      rowInfo = createRowInfos();
    }

    final int height = sceneHeight;
    final int width = sceneWidth;
    final ISINGrid grid = this.grid;

    // loop over lines
    try {
      int[] lineOffsets = new int[1];
      int[] lineLengths = new int[1];
      int[] stride = new int[1];
      stride[0] = 1;

      //            for (int y = sourceOffsetY; y < sourceOffsetY + sourceHeight; y++) {
      for (int y = sourceOffsetY; y < sourceOffsetY + sourceHeight; y += sourceStepY) {
        if (pm.isCanceled()) {
          break;
        }
        final int rowIndex = (height - 1) - y;
        final RowInfo rowInfo = this.rowInfo[rowIndex];
        if (rowInfo != null) {

          final int lineOffset = rowInfo.offset;
          final int lineLength = rowInfo.length;

          lineOffsets[0] = lineOffset;
          lineLengths[0] = lineLength;
          final Object bindata;

          synchronized (ncFile) {
            bindata = variable.read().section(lineOffsets, lineLengths, stride).copyTo1DJavaArray();
          }
          int lineIndex0 = 0;
          for (int x = sourceOffsetX; x < sourceOffsetX + sourceWidth; x++) {
            final double lon = x * 360.0 / width;
            final int binIndex = grid.getBinIndex(rowIndex, lon);
            int lineIndex = -1;
            for (int i = lineIndex0; i < lineLength; i++) {
              int binidx = bins[lineOffset + i];
              if (binidx >= binIndex) {
                if (binidx == binIndex) {
                  lineIndex = i;
                }
                lineIndex0 = i;
                break;
              }
            }

            if (lineIndex >= 0) {
              final int rasterIndex = sourceWidth * (y - sourceOffsetY) + (x - sourceOffsetX);

              System.arraycopy(bindata, lineIndex, buffer, rasterIndex, 1);
            }
          }
          pm.worked(1);
        }
      }

    } finally {
      pm.done();
    }
  }