2012-10-04 19:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
lasclip.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 ParameterVector
|
|
|
|
from processing.core.parameters import ParameterBoolean
|
|
|
|
from processing.core.parameters import ParameterNumber
|
|
|
|
from processing.core.parameters import ParameterSelection
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2015-08-22 14:29:41 +02:00
|
|
|
|
2013-09-24 22:06:50 +02:00
|
|
|
class lasclip(LAStoolsAlgorithm):
|
2012-09-15 18:25:25 +03:00
|
|
|
|
2014-05-19 19:58:33 +02:00
|
|
|
POLYGON = "POLYGON"
|
|
|
|
INTERIOR = "INTERIOR"
|
|
|
|
OPERATION = "OPERATION"
|
|
|
|
OPERATIONS = ["clip", "classify"]
|
|
|
|
CLASSIFY_AS = "CLASSIFY_AS"
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2015-07-26 03:48:27 +02:00
|
|
|
self.name, self.i18n_name = self.trAlgorithm('lasclip')
|
|
|
|
self.group, self.i18n_group = self.trAlgorithm('LAStools')
|
fix python pep8 warnings and fix some revealed errors
pep8 --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701 \
--exclude="ui_*.py,debian/*,python/ext-libs/*" \
.
2015-02-01 14:15:42 +01:00
|
|
|
self.addParametersVerboseGUI()
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersPointInputGUI()
|
2015-01-14 20:57:56 +02:00
|
|
|
self.addParameter(ParameterVector(lasclip.POLYGON,
|
2015-08-22 14:29:41 +02:00
|
|
|
self.tr("Input polygon(s)"), ParameterVector.VECTOR_TYPE_POLYGON))
|
2015-01-14 20:57:56 +02:00
|
|
|
self.addParameter(ParameterBoolean(lasclip.INTERIOR,
|
2015-08-22 14:29:41 +02:00
|
|
|
self.tr("interior"), False))
|
2015-01-14 20:57:56 +02:00
|
|
|
self.addParameter(ParameterSelection(lasclip.OPERATION,
|
2015-08-22 14:29:41 +02:00
|
|
|
self.tr("what to do with points"), lasclip.OPERATIONS, 0))
|
2015-01-14 20:57:56 +02:00
|
|
|
self.addParameter(ParameterNumber(lasclip.CLASSIFY_AS,
|
2015-08-22 14:29:41 +02:00
|
|
|
self.tr("classify as"), 0, None, 12))
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersPointOutputGUI()
|
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", "lasclip")]
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseCommands(commands)
|
|
|
|
self.addParametersPointInputCommands(commands)
|
|
|
|
poly = self.getParameterValue(lasclip.POLYGON)
|
fix python pep8 warnings and fix some revealed errors
pep8 --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701 \
--exclude="ui_*.py,debian/*,python/ext-libs/*" \
.
2015-02-01 14:15:42 +01:00
|
|
|
if poly is not None:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-poly")
|
2013-09-24 22:06:50 +02:00
|
|
|
commands.append(poly)
|
|
|
|
if self.getParameterValue(lasclip.INTERIOR):
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-interior")
|
2013-09-24 22:06:50 +02:00
|
|
|
operation = self.getParameterValue(lasclip.OPERATION)
|
|
|
|
if operation != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-classify")
|
2013-09-24 22:06:50 +02:00
|
|
|
classify_as = self.getParameterValue(lasclip.CLASSIFY_AS)
|
2015-08-16 20:57:24 +02:00
|
|
|
commands.append(unicode(classify_as))
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersPointOutputCommands(commands)
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalCommands(commands)
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
LAStoolsUtils.runLAStools(commands, progress)
|