Ejemplo n.º 1
0
  @Override
  protected void computeRect(
      final PlanarImage[] sources, final WritableRaster dest, final Rectangle destRect) {
    final PlanarImage source = sources[0];
    final Rectangle bounds = destRect.intersection(source.getBounds());
    if (!destRect.equals(bounds)) {
      // TODO: Check if this case occurs sometime, and fill pixel values if it does.
      //       If it happen to occurs, we will need to fix other GeoTools operations
      //       as well.
      Logging.getLogger(TransformException.class)
          .warning("Bounds mismatch: " + destRect + " and " + bounds);
    }
    WritableRectIter iterator = RectIterFactory.createWritable(dest, bounds);

    // TODO: Detect if source and destination rasters are the same. If they are
    //       the same, we should skip this block. Iteration will then be faster.
    iterator = TransfertRectIter.create(RectIterFactory.create(source, bounds), iterator);

    if (!iterator.finishedBands()) {
      do {
        recode(iterator);
      } while (!iterator.nextBandDone());
    }
  }