|
| 1 | +import os |
| 2 | +from sextante.parameters.ParameterFile import ParameterFile |
| 3 | +from sextante.outputs.OutputTable import OutputTable |
| 4 | +from sextante.fusion.FusionUtils import FusionUtils |
| 5 | +from sextante.fusion.FusionAlgorithm import FusionAlgorithm |
| 6 | +from sextante.parameters.ParameterNumber import ParameterNumber |
| 7 | + |
| 8 | +class GridMetrics(FusionAlgorithm): |
| 9 | + |
| 10 | + INPUT = "INPUT" |
| 11 | + OUTPUT = "OUTPUT" |
| 12 | + GROUND = "GROUND" |
| 13 | + HEIGHT = "HEIGHT" |
| 14 | + CELLSIZE = "CELLSIZE" |
| 15 | + |
| 16 | + def defineCharacteristics(self): |
| 17 | + self.name = "Grid Metrics" |
| 18 | + self.group = "Points" |
| 19 | + self.addParameter(ParameterFile(self.INPUT, "Input las layer")) |
| 20 | + self.addParameter(ParameterFile(self.GROUND, "Input ground DTM layer")) |
| 21 | + self.addParameter(ParameterNumber(self.HEIGHT, "Height break")) |
| 22 | + self.addParameter(ParameterNumber(self.CELLSIZE, "Cellsize")) |
| 23 | + self.addOutput(OutputTable(self.OUTPUT, "Output table with grid metrics")) |
| 24 | + self.addAdvancedModifiers() |
| 25 | + |
| 26 | + def processAlgorithm(self, progress): |
| 27 | + commands = [os.path.join(FusionUtils.FusionPath(), "GridMetrics.exe")] |
| 28 | + commands.append("/verbose") |
| 29 | + self.addAdvancedModifiersToCommand(commands) |
| 30 | + commands.append(self.getParameterValue(self.GROUND)) |
| 31 | + commands.append(str(self.getParameterValue(self.HEIGHT))) |
| 32 | + commands.append(str(self.getParameterValue(self.CELLSIZE))) |
| 33 | + commands.append(self.getOutputValue(self.OUTPUT)) |
| 34 | + files = self.getParameterValue(self.INPUT).split(";") |
| 35 | + if len(files) == 1: |
| 36 | + commands.append(self.getParameterValue(self.INPUT)) |
| 37 | + else: |
| 38 | + FusionUtils.createFileList(files) |
| 39 | + commands.append(FusionUtils.tempFileListFilepath()) |
| 40 | + |
| 41 | + FusionUtils.runFusion(commands, progress) |
0 commit comments