2014-05-19 19:58:33 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
lasinfo.py
|
|
|
|
---------------------
|
|
|
|
Date : August 2012
|
|
|
|
Copyright : (C) 2012 by Victor Olaya
|
|
|
|
Email : volayaf at gmail dot com
|
|
|
|
---------------------
|
|
|
|
Date : March 2014
|
|
|
|
Copyright : (C) 2014 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. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Martin Isenburg'
|
|
|
|
__date__ = 'March 2014'
|
|
|
|
__copyright__ = '(C) 2014, Martin Isenburg'
|
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
|
|
|
import os
|
|
|
|
from LAStoolsUtils import LAStoolsUtils
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterExtent
|
2014-05-19 19:58:33 +02:00
|
|
|
from LAStoolsAlgorithm import LAStoolsAlgorithm
|
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
|
|
|
from qgis.core import QgsMapLayer, QgsMapLayerRegistry
|
2014-05-19 19:58:33 +02:00
|
|
|
|
|
|
|
class lasquery(LAStoolsAlgorithm):
|
|
|
|
|
|
|
|
AOI = "AOI"
|
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2015-07-26 03:48:27 +02:00
|
|
|
self.name, self.i18n_name = self.trAlgorithm('lasquery')
|
|
|
|
self.group, self.i18n_group = self.trAlgorithm('LAStools')
|
2014-05-19 19:58:33 +02:00
|
|
|
self.addParametersVerboseGUI()
|
2015-01-14 20:57:56 +02:00
|
|
|
self.addParameter(ParameterExtent(self.AOI, self.tr('area of interest')))
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalGUI()
|
2014-05-19 19:58:33 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2014-05-21 21:25:18 +02:00
|
|
|
|
2014-12-22 12:32:37 +01:00
|
|
|
commands = [os.path.join(LAStoolsUtils.LAStoolsPath(), "bin", "lasview")]
|
2014-05-19 19:58:33 +02:00
|
|
|
self.addParametersVerboseCommands(commands)
|
|
|
|
|
2015-01-14 20:57:56 +02:00
|
|
|
# get area-of-interest
|
2014-05-19 19:58:33 +02:00
|
|
|
aoi = str(self.getParameterValue(self.AOI))
|
|
|
|
aoiCoords = aoi.split(',')
|
2014-05-21 21:25:18 +02:00
|
|
|
|
2014-05-19 19:58:33 +02:00
|
|
|
# get layers
|
|
|
|
layers = QgsMapLayerRegistry.instance().mapLayers()
|
|
|
|
|
|
|
|
# loop over layers
|
|
|
|
for name,layer in layers.iteritems():
|
2014-05-21 21:25:18 +02:00
|
|
|
layerType = layer.type()
|
|
|
|
if layerType == QgsMapLayer.VectorLayer:
|
2014-05-19 19:58:33 +02:00
|
|
|
shp_file_name = layer.source()
|
2014-05-21 21:25:18 +02:00
|
|
|
file_name = shp_file_name[:-4] + ".laz"
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append('-i')
|
|
|
|
commands.append(file_name)
|
|
|
|
|
|
|
|
commands.append("-files_are_flightlines")
|
|
|
|
commands.append('-inside')
|
|
|
|
commands.append(aoiCoords[0])
|
|
|
|
commands.append(aoiCoords[2])
|
|
|
|
commands.append(aoiCoords[1])
|
|
|
|
commands.append(aoiCoords[3])
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalCommands(commands)
|
2014-05-19 19:58:33 +02:00
|
|
|
|
|
|
|
LAStoolsUtils.runLAStools(commands, progress)
|