private boolean calculateVolumes() { int x, y; double z, z2; double dVolumePos = 0; double dVolumeNeg = 0; double dVolume = 0; double dDif; final double dArea = m_LowerGrid.getWindowCellSize() * m_LowerGrid.getWindowCellSize(); for (y = 0; (y < m_iNY) && setProgress(y, m_iNY); y++) { for (x = 0; x < m_iNX; x++) { z = m_LowerGrid.getCellValueAsDouble(x, y); z2 = m_UpperGrid.getCellValueAsDouble(x, y); if (!m_LowerGrid.isNoDataValue(z) && !m_UpperGrid.isNoDataValue(z2)) { dDif = (z2 - z); dVolume += Math.abs(dDif); if (dDif > 0) { dVolumePos += dDif; } else { dVolumeNeg += -dDif; } } } } if (m_Task.isCanceled()) { return false; } else { dVolume *= dArea; dVolumePos *= dArea; dVolumeNeg *= dArea; final DecimalFormat df = new DecimalFormat("##.##"); final HTMLDoc doc = new HTMLDoc(); doc.open(Sextante.getText("Volumes")); doc.addHeader(Sextante.getText("Volumes"), 2); doc.startUnorderedList(); doc.addListElement(Sextante.getText("Volume_+") + df.format(dVolumePos)); doc.addListElement(Sextante.getText("Volume_-") + df.format(dVolumeNeg)); doc.addListElement(Sextante.getText("Total_volume") + df.format(dVolume)); doc.close(); addOutputText(VOL, Sextante.getText("Volume"), doc.getHTMLCode()); return true; } }
@Override public boolean processAlgorithm() throws GeoAlgorithmExecutionException { int x, y; int iN; int iNX, iNY; double dValue; double dProb; boolean bCDF; final IRasterLayer layer = m_Parameters.getParameterValueAsRasterLayer(INPUT); bCDF = m_Parameters.getParameterValueAsBoolean(CDF); dProb = m_Parameters.getParameterValueAsDouble(P); iN = m_Parameters.getParameterValueAsInt(N); layer.setFullExtent(); final AnalysisExtent gridExtent = new AnalysisExtent(layer); final IRasterLayer result = getNewRasterLayer( PROBABILITY, Sextante.getText("Probability__binomial"), IRasterLayer.RASTER_DATA_TYPE_DOUBLE, gridExtent); iNX = layer.getNX(); iNY = layer.getNY(); for (y = 0; y < iNY && setProgress(y, iNY); y++) { for (x = 0; x < iNX; x++) { dValue = layer.getCellValueAsDouble(x, y); if (!layer.isNoDataValue(dValue)) { if (bCDF) { result.setCellValue(x, y, PDF.binomialCDF(dProb, iN, (int) dValue)); } else { result.setCellValue(x, y, PDF.binomial(dProb, iN, (int) dValue)); } } else { result.setNoData(x, y); } } } return !m_Task.isCanceled(); }
@Override public boolean processAlgorithm() throws GeoAlgorithmExecutionException { int x, y; int iNX, iNY; double dValue; double dMean, dStdDev; boolean bCDF; final IRasterLayer window = m_Parameters.getParameterValueAsRasterLayer(INPUT); bCDF = m_Parameters.getParameterValueAsBoolean(CDF); dMean = m_Parameters.getParameterValueAsDouble(MEAN); dStdDev = m_Parameters.getParameterValueAsDouble(STDDEV); window.setFullExtent(); final AnalysisExtent gridExtent = new AnalysisExtent(window); final IRasterLayer result = getNewRasterLayer( PROBABILITY, Sextante.getText("Probability__exponential"), IRasterLayer.RASTER_DATA_TYPE_DOUBLE, gridExtent); iNX = window.getNX(); iNY = window.getNY(); for (y = 0; y < iNY && setProgress(y, iNY); y++) { for (x = 0; x < iNX; x++) { dValue = window.getCellValueAsDouble(x, y); if (!window.isNoDataValue(dValue)) { if (bCDF) { result.setCellValue(x, y, PDF.exponentialCDF(dMean, dStdDev, dValue)); } else { result.setCellValue(x, y, PDF.exponential(dMean, dStdDev, dValue)); } } else { result.setNoData(x, y); } } } return !m_Task.isCanceled(); }