2013-09-24 22:06:50 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
lascontrol.py
|
|
|
|
---------------------
|
2016-05-30 11:55:54 +02:00
|
|
|
Date : May 2016
|
|
|
|
Copyright : (C) 2016 by Martin Isenburg
|
2013-09-24 22:06:50 +02:00
|
|
|
Email : martin near rapidlasso point com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* 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__ = 'Martin Isenburg'
|
2016-05-30 11:55:54 +02:00
|
|
|
__date__ = 'May 2016'
|
|
|
|
__copyright__ = '(C) 2016, Martin Isenburg'
|
2013-09-24 22:06:50 +02:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
|
|
|
import os
|
2016-05-30 11:55:54 +02:00
|
|
|
from LAStoolsUtils import LAStoolsUtils
|
|
|
|
from LAStoolsAlgorithm import LAStoolsAlgorithm
|
2013-09-24 22:06:50 +02:00
|
|
|
|
2016-05-30 11:55:54 +02:00
|
|
|
from processing.core.parameters import ParameterFile
|
|
|
|
from processing.core.parameters import ParameterString
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterBoolean
|
|
|
|
from processing.core.parameters import ParameterSelection
|
2013-09-24 22:06:50 +02:00
|
|
|
|
2016-06-02 16:06:40 +03:00
|
|
|
|
2013-09-24 22:06:50 +02:00
|
|
|
class lascontrol(LAStoolsAlgorithm):
|
|
|
|
|
2016-05-30 11:55:54 +02:00
|
|
|
CONTROL_POINT_FILE = "CONTROL_POINT_FILE"
|
|
|
|
PARSE_STRING = "PARSE_STRING"
|
|
|
|
USE_POINTS = "USE_POINTS"
|
|
|
|
USE_POINTS_LIST = ["all", "ground (2)", "ground (2) and keypoints (8)", "ground (2), buldings (6), and keypoints (8)"]
|
|
|
|
ADJUST_Z = "ADJUST_Z"
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2015-07-26 03:48:27 +02:00
|
|
|
self.name, self.i18n_name = self.trAlgorithm('lascontrol')
|
|
|
|
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()
|
2016-05-30 11:55:54 +02:00
|
|
|
self.addParameter(ParameterFile(lascontrol.CONTROL_POINT_FILE,
|
2016-06-02 16:06:40 +03:00
|
|
|
self.tr("ASCII text file of control points"), False, False))
|
2016-05-30 11:55:54 +02:00
|
|
|
self.addParameter(ParameterString(lascontrol.PARSE_STRING,
|
2016-06-02 16:06:40 +03:00
|
|
|
self.tr("parse string marking which columns are xyz (use 's' for skip)"), "sxyz", False, False))
|
2016-05-30 11:55:54 +02:00
|
|
|
self.addParameter(ParameterSelection(lascontrol.USE_POINTS,
|
|
|
|
self.tr("which points to use for elevation checks"), lascontrol.USE_POINTS_LIST, 0))
|
|
|
|
self.addParameter(ParameterBoolean(lascontrol.ADJUST_Z,
|
|
|
|
self.tr("adjust z elevation by translating away the average error"), False))
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalGUI()
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2014-12-22 12:32:37 +01:00
|
|
|
commands = [os.path.join(LAStoolsUtils.LAStoolsPath(), "bin", "lascontrol")]
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseCommands(commands)
|
|
|
|
self.addParametersPointInputCommands(commands)
|
2016-05-30 11:55:54 +02:00
|
|
|
file = self.getParameterValue(lascontrol.CONTROL_POINT_FILE)
|
|
|
|
if file is not None:
|
|
|
|
commands.append("-cp")
|
|
|
|
commands.append('"' + file + '"')
|
|
|
|
parse = self.getParameterValue(lascontrol.PARSE_STRING)
|
|
|
|
if parse is not None:
|
|
|
|
commands.append("-parse")
|
|
|
|
commands.append(parse)
|
|
|
|
use_point = self.getParameterValue(lascontrol.USE_POINTS)
|
|
|
|
if use_point > 0:
|
|
|
|
commands.append("-keep_class")
|
|
|
|
commands.append(unicode(2))
|
|
|
|
if use_point > 1:
|
|
|
|
commands.append(unicode(8))
|
|
|
|
if use_point > 2:
|
|
|
|
commands.append(unicode(6))
|
|
|
|
if self.getParameterValue(lascontrol.ADJUST_Z):
|
|
|
|
commands.append("-adjust_z")
|
|
|
|
commands.append("-odix _adjusted")
|
|
|
|
commands.append("-olaz")
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalCommands(commands)
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
LAStoolsUtils.runLAStools(commands, progress)
|