@ Execute public void process ( ) throws Exception { if ( ! concatOr ( outFlow == null , doReset ) ) { return ; } checkNull ( inFlow , inPit ) ; RegionMap regionMap = CoverageUtilities . getRegionParamsFromGridCoverage ( inPit ) ; cols = regionMap . getCols ( ) ; rows = regionMap . getRows ( ) ; xRes = regionMap . getXres ( ) ; yRes = regionMap . getYres ( ) ; dxySqrt = Math . sqrt ( xRes * xRes + yRes * yRes ) ; RenderedImage pitfillerRI = inPit . getRenderedImage ( ) ; WritableRaster pitfillerWR = CoverageUtilities . renderedImage2DoubleWritableRaster ( pitfillerRI , true ) ; RenderedImage flowRI = inFlow . getRenderedImage ( ) ; WritableRaster flowWR = CoverageUtilities . renderedImage2ShortWritableRaster ( flowRI , true ) ; RandomIter pitRandomIter = RandomIterFactory . create ( pitfillerWR , null ) ; // create new matrix double [ ] orderedelev = new double [ cols * rows ] ; int [ ] indexes = new int [ cols * rows ] ; int nelev = 0 ; for ( int r = 0 ; r < rows ; r ++ ) { if ( pm . isCanceled ( ) ) { return ; } for ( int c = 0 ; c < cols ; c ++ ) { double pitValue = pitRandomIter . getSampleDouble ( c , r , 0 ) ; int pos = ( r * cols ) + c ; orderedelev [ pos ] = pitValue ; indexes [ pos ] = pos + 1 ; if ( ! isNovalue ( pitValue ) ) { nelev = nelev + 1 ; } } } QuickSortAlgorithm t = new QuickSortAlgorithm ( pm ) ; t . sort ( orderedelev , indexes ) ; pm . message ( msg . message ( "draindir.initializematrix" ) ) ; // Initialize new RasterData and set value WritableRaster tcaWR = CoverageUtilities . createWritableRaster ( cols , rows , Integer . class , null , HMConstants . intNovalue ) ; WritableRaster dirWR = CoverageUtilities . createWritableRaster ( cols , rows , Short . class , null , HMConstants . shortNovalue ) ; // it contains the analyzed cells WritableRaster deviationsWR = CoverageUtilities . createWritableRaster ( cols , rows , Double . class , null , null ) ; BitMatrix analizedMatrix = new BitMatrix ( cols , rows ) ; if ( doLad ) { orlandiniD8LAD ( indexes , deviationsWR , analizedMatrix , pitfillerWR , flowWR , tcaWR , dirWR , nelev ) ; } else { orlandiniD8LTD ( indexes , deviationsWR , analizedMatrix , pitfillerWR , flowWR , tcaWR , dirWR , nelev ) ; if ( pm . isCanceled ( ) ) { return ; } // only if required executes this method if ( inFlownet != null ) { newDirections ( pitfillerWR , dirWR ) ; } } if ( pm . isCanceled ( ) ) { return ; } outFlow = CoverageUtilities . buildCoverage ( "draindir" , dirWR , regionMap , inPit . getCoordinateReferenceSystem ( ) ) ; outTca = CoverageUtilities . buildCoverage ( "tca" , tcaWR , regionMap , inPit . getCoordinateReferenceSystem ( ) ) ; }
Calculates new drainage directions