2012-10-04 19:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
las2iso.py
|
|
|
|
---------------------
|
|
|
|
Date : August 2012
|
|
|
|
Copyright : (C) 2012 by Victor Olaya
|
|
|
|
Email : volayaf at gmail dot com
|
2013-09-24 22:06:50 +02:00
|
|
|
---------------------
|
|
|
|
Date : September 2013
|
|
|
|
Copyright : (C) 2013 by Martin Isenburg
|
|
|
|
Email : martin near rapidlasso point com
|
2012-10-04 19:33:47 +02:00
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Victor Olaya'
|
|
|
|
__date__ = 'August 2012'
|
|
|
|
__copyright__ = '(C) 2012, Victor Olaya'
|
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2012-09-15 18:25:25 +03:00
|
|
|
import os
|
2014-04-17 01:41:25 +02:00
|
|
|
from LAStoolsUtils import LAStoolsUtils
|
|
|
|
from LAStoolsAlgorithm import LAStoolsAlgorithm
|
2013-09-24 22:06:50 +02:00
|
|
|
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterNumber
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2013-09-24 22:06:50 +02:00
|
|
|
class las2iso(LAStoolsAlgorithm):
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2014-05-19 19:58:33 +02:00
|
|
|
SMOOTH = "SMOOTH"
|
|
|
|
ISO_EVERY = "ISO_EVERY"
|
|
|
|
SIMPLIFY_LENGTH = "SIMPLIFY_LENGTH"
|
|
|
|
SIMPLIFY_AREA = "SIMPLIFY_AREA"
|
|
|
|
CLEAN = "CLEAN"
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2014-05-19 19:58:33 +02:00
|
|
|
self.name = "las2iso"
|
|
|
|
self.group = "LAStools"
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseGUI()
|
|
|
|
self.addParametersPointInputGUI()
|
2014-05-19 19:58:33 +02:00
|
|
|
self.addParameter(ParameterNumber(las2iso.SMOOTH, "smooth underlying TIN", 0, None, 0))
|
|
|
|
self.addParameter(ParameterNumber(las2iso.ISO_EVERY, "extract isoline with a spacing of", 0, None, 10.0))
|
|
|
|
self.addParameter(ParameterNumber(las2iso.CLEAN, "clean isolines shorter than (0 = do not clean)", None, None, 0.0))
|
|
|
|
self.addParameter(ParameterNumber(las2iso.SIMPLIFY_LENGTH, "simplify segments shorter than (0 = do not simplify)", None, None, 0.0))
|
|
|
|
self.addParameter(ParameterNumber(las2iso.SIMPLIFY_AREA, "simplify segments pairs with area less than (0 = do not simplify)", None, None, 0.0))
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVectorOutputGUI()
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalGUI()
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2014-12-22 12:32:37 +01:00
|
|
|
commands = [os.path.join(LAStoolsUtils.LAStoolsPath(), "bin", "las2iso")]
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseCommands(commands)
|
2014-05-21 21:25:18 +02:00
|
|
|
self.addParametersPointInputCommands(commands)
|
2013-09-24 22:06:50 +02:00
|
|
|
smooth = self.getParameterValue(las2iso.SMOOTH)
|
|
|
|
if smooth != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-smooth")
|
2013-09-24 22:06:50 +02:00
|
|
|
commands.append(str(smooth))
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-iso_every")
|
2013-09-24 22:06:50 +02:00
|
|
|
commands.append(str(self.getParameterValue(las2iso.ISO_EVERY)))
|
|
|
|
simplify_length = self.getParameterValue(las2iso.SIMPLIFY_LENGTH)
|
|
|
|
if simplify_length != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-simplify_length")
|
2013-09-24 22:06:50 +02:00
|
|
|
commands.append(str(simplify_length))
|
|
|
|
simplify_area = self.getParameterValue(las2iso.SIMPLIFY_AREA)
|
|
|
|
if simplify_area != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-simplify_area")
|
2013-09-24 22:06:50 +02:00
|
|
|
commands.append(str(simplify_area))
|
2012-09-15 18:25:25 +03:00
|
|
|
clean = self.getParameterValue(las2iso.CLEAN)
|
|
|
|
if clean != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-clean")
|
2012-09-15 18:25:25 +03:00
|
|
|
commands.append(str(clean))
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVectorOutputCommands(commands)
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalCommands(commands)
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2013-09-24 22:06:50 +02:00
|
|
|
LAStoolsUtils.runLAStools(commands, progress)
|