|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + ImageCreate.py |
| 6 | + --------------------- |
| 7 | + Date : January 2016 |
| 8 | + Copyright : (C) 2016 by Niccolo' Marchi |
| 9 | + Email : sciurusurbanus at hotmail dot it |
| 10 | +*************************************************************************** |
| 11 | +* * |
| 12 | +* This program is free software; you can redistribute it and/or modify * |
| 13 | +* it under the terms of the GNU General Public License as published by * |
| 14 | +* the Free Software Foundation; either version 2 of the License, or * |
| 15 | +* (at your option) any later version. * |
| 16 | +* * |
| 17 | +*************************************************************************** |
| 18 | +""" |
| 19 | + |
| 20 | +__author__ = "Niccolo' Marchi" |
| 21 | +__date__ = 'January 2016' |
| 22 | +__copyright__ = "(C) 2016 by Niccolo' Marchi" |
| 23 | + |
| 24 | +# This will get replaced with a git SHA1 when you do a git archive |
| 25 | + |
| 26 | +__revision__ = '$Format:%H$' |
| 27 | + |
| 28 | +import os |
| 29 | +from processing.core.parameters import ParameterBoolean |
| 30 | +from processing.core.parameters import ParameterFile |
| 31 | +from processing.core.parameters import ParameterSelection |
| 32 | +from processing.core.parameters import ParameterNumber |
| 33 | +from processing.core.outputs import OutputFile |
| 34 | +from FusionAlgorithm import FusionAlgorithm |
| 35 | +from FusionUtils import FusionUtils |
| 36 | + |
| 37 | + |
| 38 | +class ImageCreate(FusionAlgorithm): |
| 39 | + |
| 40 | + INPUT = 'INPUT' |
| 41 | + COLOROPTION = 'COLOROPTION' |
| 42 | + GROUND = 'GROUND' |
| 43 | + PIXEL = 'PIXEL' |
| 44 | + RGB = 'RGB' |
| 45 | + SWITCH = 'SWITCH' |
| 46 | + OUTPUT = 'OUTPUT' |
| 47 | + |
| 48 | + |
| 49 | + def defineCharacteristics(self): |
| 50 | + self.name, self.i18n_name = self.trAlgorithm('ImageCreate') |
| 51 | + self.group, self.i18n_group = self.trAlgorithm('Points') |
| 52 | + self.addParameter(ParameterFile( |
| 53 | + self.INPUT, self.tr('Input LAS'))) |
| 54 | + self.addParameter(ParameterSelection( |
| 55 | + self.COLOROPTION, self.tr('Method to assign colour'), ['Intensity', 'Elevation','Height'])) |
| 56 | + self.addParameter(ParameterFile( |
| 57 | + self.GROUND, self.tr("Ground file (used with 'Height' method)"),'dtm')) |
| 58 | + self.addParameter(ParameterBoolean(self.RGB, |
| 59 | + self.tr('Use RGB colour model to create the colour ramp'), False)) |
| 60 | + self.addParameter(ParameterNumber( |
| 61 | + self.PIXEL, self.tr('Pixel size'), 0, None, 1.0)) |
| 62 | + self.addParameter(ParameterSelection( |
| 63 | + self.SWITCH, self.tr('Output format'), ['JPEG', 'Bitmap'])) |
| 64 | + self.addOutput(OutputFile(self.OUTPUT, 'Output image')) |
| 65 | + self.addAdvancedModifiers() |
| 66 | + |
| 67 | + def processAlgorithm(self, progress): |
| 68 | + commands = [os.path.join(FusionUtils.FusionPath(), 'ImageCreate.exe')] |
| 69 | + commands.append('/verbose') |
| 70 | + commands.append('/coloroption:' + unicode(self.getParameterValue(self.COLOROPTION))) |
| 71 | + ground = self.getParameterValue(self.GROUND) |
| 72 | + if unicode(ground).strip(): |
| 73 | + commands.append('/dtm:' + unicode(ground)) |
| 74 | + if self.getParameterValue(self.RGB): |
| 75 | + commands.append('/rgb') |
| 76 | + if self.getParameterValue(self.SWITCH) == 0: |
| 77 | + commands.append('/jpg') |
| 78 | + else: |
| 79 | + commands.append('/bmp') |
| 80 | + outFile = self.getOutputValue(self.OUTPUT) |
| 81 | + commands.append(outFile) |
| 82 | + commands.append(unicode(self.getParameterValue(self.PIXEL))) |
| 83 | + files = self.getParameterValue(self.INPUT).split(';') |
| 84 | + if len(files) == 1: |
| 85 | + commands.append(self.getParameterValue(self.INPUT)) |
| 86 | + else: |
| 87 | + FusionUtils.createFileList(files) |
| 88 | + commands.append(FusionUtils.tempFileListFilepath()) |
| 89 | + FusionUtils.runFusion(commands, progress) |
0 commit comments