2016-05-30 11:55:54 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
lasdiff.py
|
|
|
|
---------------------
|
|
|
|
Date : May 2016
|
|
|
|
Copyright : (C) 2016 by Martin Isenburg
|
|
|
|
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. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
2016-09-21 18:24:26 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from future import standard_library
|
|
|
|
standard_library.install_aliases()
|
2016-05-30 11:55:54 +02:00
|
|
|
|
|
|
|
__author__ = 'Martin Isenburg'
|
|
|
|
__date__ = 'May 2016'
|
|
|
|
__copyright__ = '(C) 2016, Martin Isenburg'
|
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
|
|
|
import os
|
2016-09-21 18:24:26 +02:00
|
|
|
from .LAStoolsUtils import LAStoolsUtils
|
|
|
|
from .LAStoolsAlgorithm import LAStoolsAlgorithm
|
2016-05-30 11:55:54 +02:00
|
|
|
|
|
|
|
from processing.core.parameters import ParameterFile
|
|
|
|
from processing.core.parameters import ParameterBoolean
|
|
|
|
from processing.core.parameters import ParameterSelection
|
|
|
|
|
2016-06-02 16:06:40 +03:00
|
|
|
|
2016-05-30 11:55:54 +02:00
|
|
|
class lasdiff(LAStoolsAlgorithm):
|
|
|
|
|
|
|
|
OTHER_POINT_FILE = "OTHER_POINT_FILE"
|
|
|
|
CREATE_DIFFERENCE_FILE = "CREATE_DIFFERENCE_FILE"
|
|
|
|
SHUTUP = "SHUTUP"
|
2016-05-30 14:44:13 +02:00
|
|
|
SHUTUP_AFTER = ["5", "10", "50", "100", "1000", "10000", "50000"]
|
2016-05-30 11:55:54 +02:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
|
|
|
self.name, self.i18n_name = self.trAlgorithm('lasdiff')
|
|
|
|
self.group, self.i18n_group = self.trAlgorithm('LAStools')
|
|
|
|
self.addParametersVerboseGUI()
|
|
|
|
self.addParametersPointInputGUI()
|
|
|
|
self.addParameter(ParameterFile(lasdiff.OTHER_POINT_FILE,
|
2016-06-02 16:06:40 +03:00
|
|
|
self.tr("other input LAS/LAZ file"), False, False))
|
2016-05-30 11:55:54 +02:00
|
|
|
self.addParameter(ParameterSelection(lasdiff.SHUTUP,
|
|
|
|
self.tr("stop reporting difference after this many points"), lasdiff.SHUTUP_AFTER, 0))
|
|
|
|
self.addParameter(ParameterBoolean(lasdiff.CREATE_DIFFERENCE_FILE,
|
|
|
|
self.tr("create elevation difference file (if points are in the same order)"), False))
|
|
|
|
self.addParametersPointOutputGUI()
|
|
|
|
self.addParametersAdditionalGUI()
|
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2016-05-30 14:44:13 +02:00
|
|
|
if (LAStoolsUtils.hasWine()):
|
2016-05-30 11:55:54 +02:00
|
|
|
commands = [os.path.join(LAStoolsUtils.LAStoolsPath(), "bin", "lasdiff.exe")]
|
|
|
|
else:
|
|
|
|
commands = [os.path.join(LAStoolsUtils.LAStoolsPath(), "bin", "lasdiff")]
|
|
|
|
self.addParametersVerboseCommands(commands)
|
|
|
|
self.addParametersPointInputCommands(commands)
|
|
|
|
file = self.getParameterValue(lasdiff.OTHER_POINT_FILE)
|
|
|
|
if file is not None:
|
|
|
|
commands.append("-i")
|
|
|
|
commands.append('"' + file + '"')
|
|
|
|
shutup = self.getParameterValue(lasdiff.SHUTUP)
|
|
|
|
if (shutup != 0):
|
2016-05-30 14:44:13 +02:00
|
|
|
commands.append("-shutup")
|
2016-05-30 11:55:54 +02:00
|
|
|
commands.append(lasdiff.SHUTUP_AFTER[shutup])
|
|
|
|
if self.getParameterValue(lasdiff.CREATE_DIFFERENCE_FILE):
|
|
|
|
self.addParametersPointOutputCommands(commands)
|
|
|
|
self.addParametersAdditionalCommands(commands)
|
|
|
|
|
|
|
|
LAStoolsUtils.runLAStools(commands, progress)
|