fun run() { amIActive = true if (args.length < 2) { showFeedback("Plugin parameters have not been set properly.") return } val inputHeader: String = args.get(0) val outputHeader: String = args.get(1) if (inputHeader == null || outputHeader == null) { showFeedback("One or more of the input parameters have not been set properly.") return } try { var row: Int var col: Int var z: Double var progress: Int var oldProgress = -1 var data: DoubleArray val inputFile = WhiteboxRaster(inputHeader, "r") val rows: Int = inputFile.getNumberRows() val cols: Int = inputFile.getNumberColumns() val noData: Double = inputFile.getNoDataValue() val outputFile = WhiteboxRaster(outputHeader, "rw", inputHeader, WhiteboxRaster.DataType.FLOAT, noData) outputFile.setPreferredPalette(inputFile.getPreferredPalette()) row = 0 while (row < rows) { data = inputFile.getRowValues(row) col = 0 while (col < cols) { z = data[col] if (z != noData) { outputFile.setValue(row, col, Math.asin(z)) } col++ } progress = (100f * row / (rows - 1)).toInt() if (progress != oldProgress) { oldProgress = progress updateProgress(progress) if (cancelOp) { cancelOperation() return } } row++ } outputFile.addMetadataEntry("Created by the " + getDescriptiveName() + " tool.") outputFile.addMetadataEntry("Created on " + Date()) inputFile.close() outputFile.close() returnData(outputHeader) } catch (oe: OutOfMemoryError) { myHost.showFeedback("An out-of-memory error has occurred during operation.") } catch (e: Exception) { myHost.showFeedback("An error has occurred during operation. See log file for details.") myHost.logException("Error in " + getDescriptiveName(), e) } finally { updateProgress("Progress: ", 0) amIActive = false myHost.pluginComplete() } }
Used to execute this plugin tool .