Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added LasTools provider and a few algorithms (still quite a few left, to be added soon) git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@122 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf
committed
Apr 19, 2012
1 parent
97dbc83
commit 6195e81
Showing
24 changed files
with
503 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from PyQt4 import QtGui, QtCore | ||
from sextante.core.SextanteUtils import SextanteUtils | ||
|
||
class FileSelectionPanel(QtGui.QWidget): | ||
|
||
def __init__(self): | ||
super(FileSelectionPanel, self).__init__(None) | ||
self.horizontalLayout = QtGui.QHBoxLayout(self) | ||
self.horizontalLayout.setSpacing(2) | ||
self.horizontalLayout.setMargin(0) | ||
self.text = QtGui.QLineEdit() | ||
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) | ||
self.horizontalLayout.addWidget(self.text) | ||
self.pushButton = QtGui.QPushButton() | ||
self.pushButton.setText("...") | ||
self.pushButton.clicked.connect(self.showSelectionDialog) | ||
self.horizontalLayout.addWidget(self.pushButton) | ||
self.setLayout(self.horizontalLayout) | ||
|
||
def showSelectionDialog(self): | ||
filename = QtGui.QFileDialog.getOpenFileName(self, "Open file", QtCore.QString(""), "*.*") | ||
if filename: | ||
self.text.setText(str(filename)) | ||
|
||
def getValue(self): | ||
s = str(self.text.text()) | ||
if SextanteUtils.isWindows(): | ||
s = s.replace("/", "\\") | ||
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from sextante.lastools.LasToolsUtils import LasToolsUtils | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
|
||
class LasToolsAlgorithm(GeoAlgorithm): | ||
|
||
FIRST_ONLY = "FIRST_ONLY" | ||
LAST_ONLY = "LAST_ONLY" | ||
SINGLE_RET_ONLY = "SINGLE_RET_ONLY" | ||
DOUBLE_RET_ONLY = "DOUBLE_RET_ONLY" | ||
|
||
def checkBeforeOpeningParametersDialog(self): | ||
path = LasToolsUtils.LasToolsPath() | ||
if path == "": | ||
return "SAGA folder is not configured.\nPlease configure it before running SAGA algorithms." | ||
|
||
def addCommonParameters(self): | ||
self.addParameter(ParameterBoolean(LasToolsAlgorithm.FIRST_ONLY, "Keep first return only", False)) | ||
self.addParameter(ParameterBoolean(LasToolsAlgorithm.LAST_ONLY, "Keep last return only", False)) | ||
self.addParameter(ParameterBoolean(LasToolsAlgorithm.SINGLE_RET_ONLY, "Keep single returns only", False)) | ||
self.addParameter(ParameterBoolean(LasToolsAlgorithm.DOUBLE_RET_ONLY, "Keep double returns only", False)) | ||
|
||
def addCommonParameterValuesToCommand(self, commands): | ||
if self.getParameterValue(LasToolsAlgorithm.LAST_ONLY): | ||
commands.append("-last_only") | ||
if self.getParameterValue(LasToolsAlgorithm.FIRST_ONLY): | ||
commands.append("-first_only") | ||
if self.getParameterValue(LasToolsAlgorithm.SINGLE_RET_ONLY): | ||
commands.append("-single_returns_only") | ||
if self.getParameterValue(LasToolsAlgorithm.DOUBLE_RET_ONLY): | ||
commands.append("-double_returns_only") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
from sextante.core.AlgorithmProvider import AlgorithmProvider | ||
from sextante.lastools.LasToolsUtils import LasToolsUtils | ||
from sextante.core.SextanteConfig import Setting, SextanteConfig | ||
from sextante.lastools.las2shp import las2shp | ||
from sextante.lastools.las2dem import las2dem | ||
from sextante.lastools.lasboundary import lasboundary | ||
from sextante.lastools.las2iso import las2iso | ||
from sextante.lastools.lasgrid import lasgrid | ||
from sextante.lastools.lasground import lasground | ||
from sextante.lastools.lasinfo import lasinfo | ||
|
||
|
||
class LasToolsAlgorithmProvider(AlgorithmProvider): | ||
|
||
def __init__(self): | ||
AlgorithmProvider.__init__(self) | ||
self.algsList = [las2shp(), lasboundary(), las2dem(), las2iso(), lasgrid(), lasground(), lasinfo()] | ||
|
||
def initializeSettings(self): | ||
AlgorithmProvider.initializeSettings(self) | ||
SextanteConfig.addSetting(Setting("LASTools", LasToolsUtils.LASTOOLS_FOLDER, "LASTools folder", LasToolsUtils.LasToolsPath())) | ||
def getName(self): | ||
return "LASTools" | ||
|
||
def getIcon(self): | ||
return QIcon(os.path.dirname(__file__) + "/../images/tool.png") | ||
|
||
def _loadAlgorithms(self): | ||
self.algs = self.algsList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
import subprocess | ||
from sextante.core.SextanteLog import SextanteLog | ||
from sextante.core.SextanteConfig import SextanteConfig | ||
|
||
class LasToolsUtils(): | ||
|
||
LASTOOLS_FOLDER = "LASTOOLS_FOLDER" | ||
|
||
@staticmethod | ||
def LasToolsPath(): | ||
folder = SextanteConfig.getSetting(LasToolsUtils.LASTOOLS_FOLDER) | ||
if folder == None: | ||
folder ="" | ||
|
||
return folder | ||
|
||
@staticmethod | ||
def runLasTools(commands, progress): | ||
loglines = [] | ||
loglines.append("LasTools execution console output") | ||
proc = subprocess.Popen(commands, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=False).stdout | ||
for line in iter(proc.readline, ""): | ||
loglines.append(line) | ||
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
from PyQt4 import QtGui | ||
from sextante.parameters.ParameterString import ParameterString | ||
from sextante.lastools.LasToolsUtils import LasToolsUtils | ||
from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
from sextante.outputs.OutputRaster import OutputRaster | ||
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
|
||
class las2dem(LasToolsAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
INTENSITY = "INTENSITY" | ||
|
||
def getIcon(self): | ||
filepath = os.path.dirname(__file__) + "/../images/tool.png" | ||
return QtGui.QIcon(filepath) | ||
|
||
def defineCharacteristics(self): | ||
self.name = "las2dem" | ||
self.group = "Tools" | ||
self.addParameter(ParameterFile(las2dem.INPUT, "Input las layer", "")) | ||
self.addParameter(ParameterBoolean(las2dem.INTENSITY, "Use intensity instead of elevation", False)) | ||
self.addOutput(OutputRaster(las2dem.OUTPUT, "Output dem layer")) | ||
self.addCommonParameters() | ||
|
||
def processAlgorithm(self, progress): | ||
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "las2dem.exe")] | ||
commands.append("-i") | ||
commands.append(self.getParameterValue(las2dem.INPUT)) | ||
commands.append("-o") | ||
commands.append(self.getOutputValue(las2dem.OUTPUT)) | ||
if self.getParameterValue(las2dem.INTENSITY): | ||
commands.append("-intensity") | ||
self.addCommonParameterValuesToCommand(commands) | ||
|
||
LasToolsUtils.runLasTools(commands, progress) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
from PyQt4 import QtGui | ||
from sextante.parameters.ParameterString import ParameterString | ||
from sextante.lastools.LasToolsUtils import LasToolsUtils | ||
from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm | ||
from sextante.parameters.ParameterNumber import ParameterNumber | ||
from sextante.outputs.OutputVector import OutputVector | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
|
||
class las2iso(LasToolsAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
CLEAN = "CLEAN" | ||
SIMPLIFY = "SIMPLIFY" | ||
INTERVAL = "INTERVAL" | ||
|
||
def getIcon(self): | ||
filepath = os.path.dirname(__file__) + "/../images/tool.png" | ||
return QtGui.QIcon(filepath) | ||
|
||
def defineCharacteristics(self): | ||
self.name = "las2iso" | ||
self.group = "Tools" | ||
self.addParameter(ParameterFile(las2iso.INPUT, "Input las layer", "")) | ||
self.addParameter(ParameterNumber(las2iso.INTERVAL, "Interval between isolines", 0, None, 10.0)) | ||
self.addParameter(ParameterNumber(las2iso.CLEAN, "Clean isolines shorter than (0 = do not clean)", None, None, 0.0)) | ||
self.addParameter(ParameterNumber(las2iso.SIMPLIFY, "simplify segments shorter than (0 = do not simplify)", None, None, 0.0)) | ||
self.addOutput(OutputVector(las2iso.OUTPUT, "Output isolines")) | ||
self.addCommonParameters() | ||
|
||
def processAlgorithm(self, progress): | ||
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "las2iso.exe")] | ||
commands.append("-i") | ||
commands.append(self.getParameterValue(las2iso.INPUT)) | ||
commands.append("-o") | ||
commands.append(self.getOutputValue(las2iso.OUTPUT)) | ||
commands.append("-iso_every") | ||
commands.append(str(self.getParameterValue(las2iso.INTERVAL))) | ||
simplify = self.getParameterValue(las2iso.SIMPLIFY) | ||
if simplify != 0: | ||
commands.append("-simplify") | ||
commands.append(str(simplify)) | ||
clean = self.getParameterValue(las2iso.CLEAN) | ||
if clean != 0: | ||
commands.append("-clean") | ||
commands.append(str(clean)) | ||
self.addCommonParameterValuesToCommand(commands) | ||
|
||
LasToolsUtils.runLasTools(commands, progress) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from PyQt4 import QtGui | ||
from sextante.parameters.ParameterString import ParameterString | ||
from sextante.outputs.OutputVector import OutputVector | ||
from sextante.lastools.LasToolsUtils import LasToolsUtils | ||
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
|
||
class las2shp(LasToolsAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
|
||
def getIcon(self): | ||
filepath = os.path.dirname(__file__) + "/../images/tool.png" | ||
return QtGui.QIcon(filepath) | ||
|
||
def defineCharacteristics(self): | ||
self.name = "las2shp" | ||
self.group = "Tools" | ||
self.addParameter(ParameterFile(las2shp.INPUT, "Input las layer", "")) | ||
self.addOutput(OutputVector(las2shp.OUTPUT, "Output shp layer")) | ||
self.addCommonParameters() | ||
|
||
def processAlgorithm(self, progress): | ||
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "las2shp.exe")] | ||
commands.append("-i") | ||
commands.append(self.getParameterValue(las2shp.INPUT)) | ||
commands.append("-o") | ||
commands.append(self.getOutputValue(las2shp.OUTPUT)) | ||
self.addCommonParameterValuesToCommand(commands) | ||
|
||
|
||
LasToolsUtils.runLasTools(commands, progress) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
from PyQt4 import QtGui | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
from sextante.parameters.ParameterString import ParameterString | ||
from sextante.outputs.OutputVector import OutputVector | ||
from sextante.lastools.LasToolsUtils import LasToolsUtils | ||
from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
from sextante.parameters.ParameterNumber import ParameterNumber | ||
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
|
||
class lasboundary(LasToolsAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
CONCAVITY = "CONCAVITY" | ||
DISJOINT = "DISJOINT" | ||
HOLES = "HOLES" | ||
|
||
|
||
def getIcon(self): | ||
filepath = os.path.dirname(__file__) + "/../images/tool.png" | ||
return QtGui.QIcon(filepath) | ||
|
||
def defineCharacteristics(self): | ||
self.name = "lasboundary" | ||
self.group = "Tools" | ||
self.addParameter(ParameterFile(lasboundary.INPUT, "Input las layer", "")) | ||
self.addParameter(ParameterNumber(lasboundary.CONCAVITY, "Concavity threshold", 0, None, 50.0)) | ||
self.addParameter(ParameterBoolean(lasboundary.HOLES, "Compute also interior holes", False)) | ||
self.addParameter(ParameterBoolean(lasboundary.DISJOINT, "Compute disjoint hull", False)) | ||
self.addOutput(OutputVector(lasboundary.OUTPUT, "Output boundary layer")) | ||
self.addCommonParameters() | ||
|
||
def processAlgorithm(self, progress): | ||
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "lasboundary.exe")] | ||
commands.append("-i") | ||
commands.append(self.getParameterValue(lasboundary.INPUT)) | ||
commands.append("-o") | ||
commands.append(self.getOutputValue(lasboundary.OUTPUT)) | ||
commands.append("-concavity") | ||
commands.append(str(self.getParameterValue(lasboundary.CONCAVITY))) | ||
if self.getParameterValue(lasboundary.HOLES): | ||
commands.append("-holes") | ||
if self.getParameterValue(lasboundary.DISJOINT): | ||
commands.append("-disjoint") | ||
self.addCommonParameterValuesToCommand(commands) | ||
|
||
LasToolsUtils.runLasTools(commands, progress) |
Oops, something went wrong.