use of javax.media.jai.iterator.RectIter in project imageio-ext by geosolutions-it.
the class AsciiGridsImageWriter method writeRaster.
/**
* Write the raster to file.
*
* @throws IOException
*/
private void writeRaster() throws IOException {
// we need to cobble rasters of the same row together in order to
// respect the way our writer works.
final RectIter iterator = RectIterFactory.create(inputRenderedImage, null);
// writing
final Double noDataDouble = new Double(rasterWriter.getNoData());
final String noDataMarker = rasterWriter.getNoDataMarker();
rasterWriter.writeRaster(iterator, noDataDouble, noDataMarker);
}
use of javax.media.jai.iterator.RectIter in project polymap4-core by Polymap4.
the class PredefinedColorMap method minMax3.
/**
* @return double[] {min, max, novalue}
*/
protected double[] minMax3(GridCoverage2D grid, IProgressMonitor monitor) {
@SuppressWarnings("hiding") double // see OmsRasterReader
novalue = -9999.0;
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
RenderedImage renderedImage = grid.getRenderedImage();
monitor.beginTask("calculating min/max", renderedImage.getHeight());
RectIter iter = RectIterFactory.create(renderedImage, null);
Timer timer = new Timer();
int sampleCount = 0;
do {
do {
double value = iter.getSampleDouble();
if (value == novalue) {
continue;
}
if (value < novalue) {
throw new IllegalStateException("XXX value < novalue : " + value);
}
if (value < min) {
min = value;
}
if (value > max) {
max = value;
}
sampleCount++;
} while (!iter.nextPixelDone());
iter.startPixels();
monitor.worked(1);
// monitor.subTask( String.valueOf( sampleCount ) );
} while (// http://github.com/Polymap4/polymap4-core/issues/108 will be better/faster
!iter.nextLineDone() && timer.elapsedTime() < 5000);
monitor.done();
log.info("minMax(): " + sampleCount + " samples in " + timer.elapsedTime() + "ms");
// XXX check novalue
return new double[] { min, max, novalue };
}
Aggregations