Skip to content

Commit

Permalink
added some i.* to grass, some new tools to lastools and nviz
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@148 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed Apr 24, 2012
1 parent 0023d04 commit dbbcca2
Show file tree
Hide file tree
Showing 25 changed files with 229 additions and 74 deletions.
7 changes: 2 additions & 5 deletions build.xml
Expand Up @@ -5,11 +5,8 @@
<property name="version.number" value="1.0"/>
<target name="copy"
description="copy files">
<copy todir="C:/Users/volaya/.qgis/python/plugins/sextante">
<fileset dir="src/sextante" includes="**"/>
<copy todir="C:/Users/volaya/.qgis/python/plugins">
<fileset dir="src" includes="**"/>
</copy>
<copy todir="C:/Users/volaya/.qgis/python/plugins/sextanteexampleprovider">
<fileset dir="src/sextanteexampleprovider" includes="**"/>
</copy>
</target>
</project>
13 changes: 7 additions & 6 deletions src/sextante/core/GeoAlgorithm.py
Expand Up @@ -145,12 +145,13 @@ def setOutputCRSFromInputLayers(self):
layers = QGisLayers.getAllLayers()
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
inputlayers = param.value.split(";")
for inputlayer in inputlayers:
for layer in layers:
if layer.source() == inputlayer:
self.crs = layer.crs()
return
if param.value:
inputlayers = param.value.split(";")
for inputlayer in inputlayers:
for layer in layers:
if layer.source() == inputlayer:
self.crs = layer.crs()
return


def addOutput(self, output):
Expand Down
23 changes: 12 additions & 11 deletions src/sextante/grass/GrassAlgorithm.py
Expand Up @@ -92,19 +92,20 @@ def calculateRegion(self):
if auto:
first = True;
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector)):
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
layer = param.value
else:
layer = QGisLayers.getObjectFromUri(param.value)
self.addToRegion(layer, first)
first = False
elif isinstance(param, ParameterMultipleInput):
layers = param.value.split(";")
for layername in layers:
layer = QGisLayers.getObjectFromUri(layername, first)
if param.value:
if isinstance(param, (ParameterRaster, ParameterVector)):
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
layer = param.value
else:
layer = QGisLayers.getObjectFromUri(param.value)
self.addToRegion(layer, first)
first = False
elif isinstance(param, ParameterMultipleInput):
layers = param.value.split(";")
for layername in layers:
layer = QGisLayers.getObjectFromUri(layername, first)
self.addToRegion(layer, first)
first = False
if self.cellsize == 0:
self.cellsize = 1
else:
Expand Down
2 changes: 2 additions & 0 deletions src/sextante/grass/GrassAlgorithmProvider.py
Expand Up @@ -8,6 +8,7 @@
from sextante.grass.GrassAlgorithm import GrassAlgorithm
from sextante.core.SextanteUtils import SextanteUtils
from sextante.grass.DefineGrassRegionAction import DefineGrassRegionAction
from sextante.grass.nviz import nviz

class GrassAlgorithmProvider(AlgorithmProvider):

Expand Down Expand Up @@ -57,6 +58,7 @@ def createAlgsList(self):
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
except Exception,e:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
self.preloadedAlgs.append(nviz())
#self.createDescriptionFiles()

def _loadAlgorithms(self):
Expand Down
8 changes: 4 additions & 4 deletions src/sextante/grass/GrassUtils.py
Expand Up @@ -65,7 +65,7 @@ def grassHelpPath():
if os.path.exists(f):
folder = f
break

return folder

@staticmethod
Expand Down Expand Up @@ -122,9 +122,9 @@ def createGrassScript(commands):
output.write("set PATHEXT=%PATHEXT%;.PY\n")
output.write("set PYTHONPATH=%PYTHONPATH%;%WINGISBASE%\\etc\\python;%WINGISBASE%\\etc\\wxpython\\n");
output.write("\n")
output.write("g.gisenv.exe set=\"MAPSET= " + mapset + "\n")
output.write("g.gisenv.exe set=\"LOCATION=" + location + "\n")
output.write("g.gisenv.exe set=\"LOCATION_NAME=" + location + "\n")
output.write("g.gisenv.exe set=\"MAPSET=" + mapset + "\"\n")
output.write("g.gisenv.exe set=\"LOCATION=" + location + "\"\n")
output.write("g.gisenv.exe set=\"LOCATION_NAME=" + location + "\"\n")
output.write("g.gisenv.exe set=\"GISDBASE=" + gisdbase + "\"\n")
output.write("g.gisenv.exe set=\"GRASS_GUI=text\"\n")
for command in commands:
Expand Down
13 changes: 13 additions & 0 deletions src/sextante/grass/description/i.atcorr.txt
@@ -0,0 +1,13 @@
i.attcorr
i.attcorr
Imagery (i.*)
ParameterBoolean|-f|-f|False
ParameterBoolean|-a|-a|False
ParameterBoolean|-b|-b|False
ParameterBoolean|-o|-o|False
ParameterRaster|iimg|iimg|False
ParameterRaster|ialt|ialt|True
ParameterRaster|ivis|ivis|True
ParameterRange|iscl|iscl|0,255
ParameterFile|icnd|icnd|False
OutputRaster|oimg|oimg
6 changes: 6 additions & 0 deletions src/sextante/grass/description/i.fft.txt
@@ -0,0 +1,6 @@
i.fft
i.fft
Imagery (i.*)
ParameterRaster|input_image|input_image|False
OutputRaster|real_image|real_image
OutputRaster|imaginary_image|imaginary_image
9 changes: 9 additions & 0 deletions src/sextante/grass/description/i.his.rgb.txt
@@ -0,0 +1,9 @@
i.his.rgb
i.his.rgb
Imagery (i.*)
ParameterRaster|hue_input|hue_input|False
ParameterRaster|intensity_input|intensity_input|False
ParameterRaster|saturation_input|saturation_input|False
OutputRaster|red_output|red_output
OutputRaster|green_output|green_output
OutputRaster|blue_output|blue_output
6 changes: 6 additions & 0 deletions src/sextante/grass/description/i.ifft.txt
@@ -0,0 +1,6 @@
i.ifft
i.ifft
Imagery (i.*)
ParameterRaster|real_image|real_image|False
ParameterRaster|imaginary_image|imaginary_image|False
OutputRaster|output_image|output_image
9 changes: 9 additions & 0 deletions src/sextante/grass/description/i.zc.txt
@@ -0,0 +1,9 @@
i.zc
i.zc
Imagery (i.*)
ParameterRaster|input|input|False
ParameterRaster|green|green|False
ParameterNumber|width|width|1|None|9
ParameterNumber|threshold|threshold|0|None|10.0
ParameterNumber|orientations|orientations|0|None|1
OutputRaster|output|output
5 changes: 5 additions & 0 deletions src/sextante/grass/description/nviz.txt
@@ -0,0 +1,5 @@
nviz
nviz
Visualization(NVIZ)
ParameterMultipleInput|elevation|elevation|3|False
ParameterMultipleInput|vector|vector|-1|False
34 changes: 34 additions & 0 deletions src/sextante/grass/nviz.py
@@ -0,0 +1,34 @@
import os
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput
from sextante.grass.GrassUtils import GrassUtils
from sextante.core.GeoAlgorithm import GeoAlgorithm
from PyQt4 import QtGui

class nviz(GeoAlgorithm):

ELEVATION = "ELEVATION"
VECTOR = "VECTOR"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/grass.png")

def defineCharacteristics(self):
self.name = "nviz"
self.group = "Visualization(NVIZ)"
self.addParameter(ParameterMultipleInput(nviz.ELEVATION, "Elevation layers", ParameterMultipleInput.TYPE_RASTER, True))
self.addParameter(ParameterMultipleInput(nviz.VECTOR, "Vector layers", ParameterMultipleInput.TYPE_VECTOR_ANY, True))

def processAlgorithm(self, progress):
commands = []
command = "nviz"
vector = self.getParameterValue(self.VECTOR);
elevation = self.getParameterValue(self.ELEVATION);
if vector:
command += (" vector=" + vector.replace(";", ","))
if elevation:
command += (" elevation=" + elevation.replace(";", ","))
if elevation is None and vector is None:
command += " -q"
commands.append(command)
GrassUtils.createTempMapset();
GrassUtils.executeGrass(commands, progress)
6 changes: 6 additions & 0 deletions src/sextante/lastools/LasToolsAlgorithm.py
@@ -1,6 +1,8 @@
from sextante.lastools.LasToolsUtils import LasToolsUtils
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterBoolean import ParameterBoolean
import os
from PyQt4 import QtGui

class LasToolsAlgorithm(GeoAlgorithm):

Expand All @@ -9,6 +11,10 @@ class LasToolsAlgorithm(GeoAlgorithm):
SINGLE_RET_ONLY = "SINGLE_RET_ONLY"
DOUBLE_RET_ONLY = "DOUBLE_RET_ONLY"

def getIcon(self):
filepath = os.path.dirname(__file__) + "/../images/tool.png"
return QtGui.QIcon(filepath)

def checkBeforeOpeningParametersDialog(self):
path = LasToolsUtils.LasToolsPath()
if path == "":
Expand Down
6 changes: 5 additions & 1 deletion src/sextante/lastools/LasToolsAlgorithmProvider.py
Expand Up @@ -11,13 +11,17 @@
from sextante.lastools.lasgrid import lasgrid
from sextante.lastools.lasground import lasground
from sextante.lastools.lasinfo import lasinfo
from sextante.lastools.lasheight import lasheight
from sextante.lastools.lasprecision import lasprecision
from sextante.lastools.lassplit import lassplit


class LasToolsAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.algsList = [las2shp(), lasboundary(), las2dem(), las2iso(), lasgrid(), lasground(), lasinfo()]
self.algsList = [las2shp(), lasboundary(), las2dem(), las2iso(), lasgrid(), lasground(),
lasinfo(), lasheight(), lasprecision(), lassplit()]

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
Expand Down
4 changes: 0 additions & 4 deletions src/sextante/lastools/las2dem.py
Expand Up @@ -13,10 +13,6 @@ class las2dem(LasToolsAlgorithm):
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"
Expand Down
4 changes: 0 additions & 4 deletions src/sextante/lastools/las2iso.py
Expand Up @@ -16,10 +16,6 @@ class las2iso(LasToolsAlgorithm):
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"
Expand Down
6 changes: 0 additions & 6 deletions src/sextante/lastools/las2shp.py
@@ -1,6 +1,4 @@
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
Expand All @@ -11,10 +9,6 @@ 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"
Expand Down
5 changes: 0 additions & 5 deletions src/sextante/lastools/lasboundary.py
Expand Up @@ -17,11 +17,6 @@ class lasboundary(LasToolsAlgorithm):
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"
Expand Down
4 changes: 0 additions & 4 deletions src/sextante/lastools/lasgrid.py
Expand Up @@ -16,10 +16,6 @@ class lasgrid(LasToolsAlgorithm):
METHOD = "METHOD"
METHODS = ["-average", "-lowest", "-highest", "-stddev"]

def getIcon(self):
filepath = os.path.dirname(__file__) + "/../images/tool.png"
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = "lasgrid"
self.group = "Tools"
Expand Down
4 changes: 0 additions & 4 deletions src/sextante/lastools/lasground.py
Expand Up @@ -17,10 +17,6 @@ class lasground(LasToolsAlgorithm):
METHOD = "METHOD"
METHODS = ["terrain", "town", "city"]

def getIcon(self):
filepath = os.path.dirname(__file__) + "/../images/tool.png"
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = "lasground"
self.group = "Tools"
Expand Down
27 changes: 27 additions & 0 deletions src/sextante/lastools/lasheight.py
@@ -0,0 +1,27 @@
import os
from sextante.lastools.LasToolsUtils import LasToolsUtils
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
from sextante.parameters.ParameterFile import ParameterFile
from sextante.outputs.OutputFile import OutputFile

class lasheight(LasToolsAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"

def defineCharacteristics(self):
self.name = "lasheight"
self.group = "Tools"
self.addParameter(ParameterFile(lasheight.INPUT, "Input las layer", ""))
self.addOutput(OutputFile(lasheight.OUTPUT, "Output height las file"))
self.addCommonParameters()

def processAlgorithm(self, progress):
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "lasheight.exe")]
commands.append("-i")
commands.append(self.getParameterValue(lasheight.INPUT))
commands.append("-o")
commands.append(self.getOutputValue(lasheight.OUTPUT))
self.addCommonParameterValuesToCommand(commands)

LasToolsUtils.runLasTools(commands, progress)
5 changes: 0 additions & 5 deletions src/sextante/lastools/lasinfo.py
@@ -1,5 +1,4 @@
import os
from PyQt4 import QtGui
from sextante.lastools.LasToolsUtils import LasToolsUtils
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
from sextante.parameters.ParameterFile import ParameterFile
Expand All @@ -10,10 +9,6 @@ class lasinfo(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 = "lasinfo"
self.group = "Tools"
Expand Down
34 changes: 34 additions & 0 deletions src/sextante/lastools/lasprecision.py
@@ -0,0 +1,34 @@
import os
from PyQt4 import QtGui
from sextante.lastools.LasToolsUtils import LasToolsUtils
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
from sextante.parameters.ParameterFile import ParameterFile
from sextante.outputs.OutputHTML import OutputHTML

class lasprecision(LasToolsAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"

def defineCharacteristics(self):
self.name = "lasprecision"
self.group = "Tools"
self.addParameter(ParameterFile(lasprecision.INPUT, "Input las layer", ""))
self.addOutput(OutputHTML(lasprecision.OUTPUT, "Output info file"))

def processAlgorithm(self, progress):
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "lasprecision.exe")]
commands.append("-i")
commands.append(self.getParameterValue(lasprecision.INPUT))
commands.append(">")
commands.append(self.getOutputValue(lasprecision.OUTPUT) + ".txt")

LasToolsUtils.runLasTools(commands, progress)
fin = open (self.getOutputValue(lasprecision.OUTPUT) + ".txt")
fout = open (self.getOutputValue(lasprecision.OUTPUT), "w")
lines = fin.readlines()
for line in lines:
fout.write(line + "<br>")
fin.close()
fout.close()

0 comments on commit dbbcca2

Please sign in to comment.