2012-10-04 19:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
lasboundary.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-12-22 12:32:37 +01:00
|
|
|
from processing.core.parameters import ParameterSelection
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterBoolean
|
|
|
|
from processing.core.parameters import ParameterNumber
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2013-09-24 22:06:50 +02:00
|
|
|
class lasboundary(LAStoolsAlgorithm):
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2014-12-22 12:32:37 +01:00
|
|
|
MODE = "MODE"
|
|
|
|
MODES = ["points", "spatial index (the *.lax file)", "bounding box"]
|
2014-05-19 19:58:33 +02:00
|
|
|
CONCAVITY = "CONCAVITY"
|
|
|
|
DISJOINT = "DISJOINT"
|
|
|
|
HOLES = "HOLES"
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2014-05-19 19:58:33 +02:00
|
|
|
self.name = "lasboundary"
|
|
|
|
self.group = "LAStools"
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseGUI()
|
|
|
|
self.addParametersPointInputGUI()
|
|
|
|
self.addParametersFilter1ReturnClassFlagsGUI()
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParameter(ParameterSelection(lasboundary.MODE, "compute boundary based on", lasboundary.MODES, 0))
|
2014-05-19 19:58:33 +02:00
|
|
|
self.addParameter(ParameterNumber(lasboundary.CONCAVITY, "concavity", 0, None, 50.0))
|
|
|
|
self.addParameter(ParameterBoolean(lasboundary.HOLES, "interior holes", False))
|
|
|
|
self.addParameter(ParameterBoolean(lasboundary.DISJOINT, "disjoint polygon", False))
|
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", "lasboundary")]
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseCommands(commands)
|
|
|
|
self.addParametersPointInputCommands(commands)
|
|
|
|
self.addParametersFilter1ReturnClassFlagsCommands(commands)
|
2014-12-22 12:32:37 +01:00
|
|
|
mode = self.getParameterValue(lasboundary.MODE)
|
|
|
|
if (mode != 0):
|
|
|
|
if (mode == 1):
|
|
|
|
commands.append("-use_lax")
|
|
|
|
else:
|
|
|
|
commands.append("-use_bb")
|
|
|
|
else:
|
|
|
|
concavity = self.getParameterValue(lasboundary.CONCAVITY)
|
|
|
|
commands.append("-concavity")
|
|
|
|
commands.append(str(concavity))
|
|
|
|
if self.getParameterValue(lasboundary.HOLES):
|
|
|
|
commands.append("-holes")
|
|
|
|
if self.getParameterValue(lasboundary.DISJOINT):
|
|
|
|
commands.append("-disjoint")
|
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)
|