public static void markHillSlopeWithLinkValue ( RandomIter flowIter , RandomIter attributeIter , WritableRandomIter markedIter , int cols , int rows , IHMProgressMonitor pm ) { pm . beginTask ( "Marking the hillslopes with the channel value..." , rows ) ; for ( int r = 0 ; r < rows ; r ++ ) { for ( int c = 0 ; c < cols ; c ++ ) { FlowNode flowNode = new FlowNode ( flowIter , cols , rows , c , r ) ; if ( flowNode . isHeadingOutside ( ) ) { // ignore single cells on borders that exit anyway continue ; } if ( flowNode . isMarkedAsOutlet ( ) ) { double attributeValue = flowNode . getDoubleValueFromMap ( attributeIter ) ; flowNode . setDoubleValueInMap ( markedIter , attributeValue ) ; continue ; } if ( flowNode . isValid ( ) && flowNode . isSource ( ) ) { /* * run down to the net to find the * attribute map content on the net */ double attributeValue = doubleNovalue ; FlowNode runningNode = flowNode . goDownstream ( ) ; int runningRow = - 1 ; int runningCol = - 1 ; while ( runningNode != null && runningNode . isValid ( ) ) { runningRow = runningNode . row ; runningCol = runningNode . col ; if ( runningNode . isMarkedAsOutlet ( ) ) { attributeValue = runningNode . getDoubleValueFromMap ( attributeIter ) ; break ; } runningNode = runningNode . goDownstream ( ) ; } if ( ! isNovalue ( attributeValue ) ) { // run down marking the hills runningNode = flowNode ; while ( runningNode != null && runningNode . isValid ( ) ) { runningNode . setDoubleValueInMap ( markedIter , attributeValue ) ; if ( runningNode . isMarkedAsOutlet ( ) ) { break ; } runningNode = runningNode . goDownstream ( ) ; } } else { throw new ModelsIllegalargumentException ( "Could not find a value of the attributes map in the channel after point: " + runningCol + "/" + runningRow + ". Are you sure that everything leads to a channel or outlet?" , "MODELSENGINE" , pm ) ; } } } pm . worked ( 1 ) ; } pm . done ( ) ; }
Marks a map on the hillslope with the values on the channel of an attribute map .