Skip to content

Commit dbbcca2

Browse files
author
volayaf
committedApr 24, 2012
added some i.* to grass, some new tools to lastools and nviz
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@148 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 0023d04 commit dbbcca2

25 files changed

+229
-74
lines changed
 

‎build.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
<property name="version.number" value="1.0"/>
66
<target name="copy"
77
description="copy files">
8-
<copy todir="C:/Users/volaya/.qgis/python/plugins/sextante">
9-
<fileset dir="src/sextante" includes="**"/>
8+
<copy todir="C:/Users/volaya/.qgis/python/plugins">
9+
<fileset dir="src" includes="**"/>
1010
</copy>
11-
<copy todir="C:/Users/volaya/.qgis/python/plugins/sextanteexampleprovider">
12-
<fileset dir="src/sextanteexampleprovider" includes="**"/>
13-
</copy>
1411
</target>
1512
</project>

‎src/sextante/core/GeoAlgorithm.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ def setOutputCRSFromInputLayers(self):
145145
layers = QGisLayers.getAllLayers()
146146
for param in self.parameters:
147147
if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
148-
inputlayers = param.value.split(";")
149-
for inputlayer in inputlayers:
150-
for layer in layers:
151-
if layer.source() == inputlayer:
152-
self.crs = layer.crs()
153-
return
148+
if param.value:
149+
inputlayers = param.value.split(";")
150+
for inputlayer in inputlayers:
151+
for layer in layers:
152+
if layer.source() == inputlayer:
153+
self.crs = layer.crs()
154+
return
154155

155156

156157
def addOutput(self, output):

‎src/sextante/grass/GrassAlgorithm.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,20 @@ def calculateRegion(self):
9292
if auto:
9393
first = True;
9494
for param in self.parameters:
95-
if isinstance(param, (ParameterRaster, ParameterVector)):
96-
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
97-
layer = param.value
98-
else:
99-
layer = QGisLayers.getObjectFromUri(param.value)
100-
self.addToRegion(layer, first)
101-
first = False
102-
elif isinstance(param, ParameterMultipleInput):
103-
layers = param.value.split(";")
104-
for layername in layers:
105-
layer = QGisLayers.getObjectFromUri(layername, first)
95+
if param.value:
96+
if isinstance(param, (ParameterRaster, ParameterVector)):
97+
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
98+
layer = param.value
99+
else:
100+
layer = QGisLayers.getObjectFromUri(param.value)
106101
self.addToRegion(layer, first)
107102
first = False
103+
elif isinstance(param, ParameterMultipleInput):
104+
layers = param.value.split(";")
105+
for layername in layers:
106+
layer = QGisLayers.getObjectFromUri(layername, first)
107+
self.addToRegion(layer, first)
108+
first = False
108109
if self.cellsize == 0:
109110
self.cellsize = 1
110111
else:

‎src/sextante/grass/GrassAlgorithmProvider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sextante.grass.GrassAlgorithm import GrassAlgorithm
99
from sextante.core.SextanteUtils import SextanteUtils
1010
from sextante.grass.DefineGrassRegionAction import DefineGrassRegionAction
11+
from sextante.grass.nviz import nviz
1112

1213
class GrassAlgorithmProvider(AlgorithmProvider):
1314

@@ -57,6 +58,7 @@ def createAlgsList(self):
5758
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
5859
except Exception,e:
5960
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
61+
self.preloadedAlgs.append(nviz())
6062
#self.createDescriptionFiles()
6163

6264
def _loadAlgorithms(self):

‎src/sextante/grass/GrassUtils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def grassHelpPath():
6565
if os.path.exists(f):
6666
folder = f
6767
break
68-
68+
6969
return folder
7070

7171
@staticmethod
@@ -122,9 +122,9 @@ def createGrassScript(commands):
122122
output.write("set PATHEXT=%PATHEXT%;.PY\n")
123123
output.write("set PYTHONPATH=%PYTHONPATH%;%WINGISBASE%\\etc\\python;%WINGISBASE%\\etc\\wxpython\\n");
124124
output.write("\n")
125-
output.write("g.gisenv.exe set=\"MAPSET= " + mapset + "\n")
126-
output.write("g.gisenv.exe set=\"LOCATION=" + location + "\n")
127-
output.write("g.gisenv.exe set=\"LOCATION_NAME=" + location + "\n")
125+
output.write("g.gisenv.exe set=\"MAPSET=" + mapset + "\"\n")
126+
output.write("g.gisenv.exe set=\"LOCATION=" + location + "\"\n")
127+
output.write("g.gisenv.exe set=\"LOCATION_NAME=" + location + "\"\n")
128128
output.write("g.gisenv.exe set=\"GISDBASE=" + gisdbase + "\"\n")
129129
output.write("g.gisenv.exe set=\"GRASS_GUI=text\"\n")
130130
for command in commands:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
i.attcorr
2+
i.attcorr
3+
Imagery (i.*)
4+
ParameterBoolean|-f|-f|False
5+
ParameterBoolean|-a|-a|False
6+
ParameterBoolean|-b|-b|False
7+
ParameterBoolean|-o|-o|False
8+
ParameterRaster|iimg|iimg|False
9+
ParameterRaster|ialt|ialt|True
10+
ParameterRaster|ivis|ivis|True
11+
ParameterRange|iscl|iscl|0,255
12+
ParameterFile|icnd|icnd|False
13+
OutputRaster|oimg|oimg
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
i.fft
2+
i.fft
3+
Imagery (i.*)
4+
ParameterRaster|input_image|input_image|False
5+
OutputRaster|real_image|real_image
6+
OutputRaster|imaginary_image|imaginary_image
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
i.his.rgb
2+
i.his.rgb
3+
Imagery (i.*)
4+
ParameterRaster|hue_input|hue_input|False
5+
ParameterRaster|intensity_input|intensity_input|False
6+
ParameterRaster|saturation_input|saturation_input|False
7+
OutputRaster|red_output|red_output
8+
OutputRaster|green_output|green_output
9+
OutputRaster|blue_output|blue_output
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
i.ifft
2+
i.ifft
3+
Imagery (i.*)
4+
ParameterRaster|real_image|real_image|False
5+
ParameterRaster|imaginary_image|imaginary_image|False
6+
OutputRaster|output_image|output_image
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
i.zc
2+
i.zc
3+
Imagery (i.*)
4+
ParameterRaster|input|input|False
5+
ParameterRaster|green|green|False
6+
ParameterNumber|width|width|1|None|9
7+
ParameterNumber|threshold|threshold|0|None|10.0
8+
ParameterNumber|orientations|orientations|0|None|1
9+
OutputRaster|output|output
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
nviz
2+
nviz
3+
Visualization(NVIZ)
4+
ParameterMultipleInput|elevation|elevation|3|False
5+
ParameterMultipleInput|vector|vector|-1|False

‎src/sextante/grass/nviz.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput
3+
from sextante.grass.GrassUtils import GrassUtils
4+
from sextante.core.GeoAlgorithm import GeoAlgorithm
5+
from PyQt4 import QtGui
6+
7+
class nviz(GeoAlgorithm):
8+
9+
ELEVATION = "ELEVATION"
10+
VECTOR = "VECTOR"
11+
12+
def getIcon(self):
13+
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/grass.png")
14+
15+
def defineCharacteristics(self):
16+
self.name = "nviz"
17+
self.group = "Visualization(NVIZ)"
18+
self.addParameter(ParameterMultipleInput(nviz.ELEVATION, "Elevation layers", ParameterMultipleInput.TYPE_RASTER, True))
19+
self.addParameter(ParameterMultipleInput(nviz.VECTOR, "Vector layers", ParameterMultipleInput.TYPE_VECTOR_ANY, True))
20+
21+
def processAlgorithm(self, progress):
22+
commands = []
23+
command = "nviz"
24+
vector = self.getParameterValue(self.VECTOR);
25+
elevation = self.getParameterValue(self.ELEVATION);
26+
if vector:
27+
command += (" vector=" + vector.replace(";", ","))
28+
if elevation:
29+
command += (" elevation=" + elevation.replace(";", ","))
30+
if elevation is None and vector is None:
31+
command += " -q"
32+
commands.append(command)
33+
GrassUtils.createTempMapset();
34+
GrassUtils.executeGrass(commands, progress)

‎src/sextante/lastools/LasToolsAlgorithm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from sextante.lastools.LasToolsUtils import LasToolsUtils
22
from sextante.core.GeoAlgorithm import GeoAlgorithm
33
from sextante.parameters.ParameterBoolean import ParameterBoolean
4+
import os
5+
from PyQt4 import QtGui
46

57
class LasToolsAlgorithm(GeoAlgorithm):
68

@@ -9,6 +11,10 @@ class LasToolsAlgorithm(GeoAlgorithm):
911
SINGLE_RET_ONLY = "SINGLE_RET_ONLY"
1012
DOUBLE_RET_ONLY = "DOUBLE_RET_ONLY"
1113

14+
def getIcon(self):
15+
filepath = os.path.dirname(__file__) + "/../images/tool.png"
16+
return QtGui.QIcon(filepath)
17+
1218
def checkBeforeOpeningParametersDialog(self):
1319
path = LasToolsUtils.LasToolsPath()
1420
if path == "":

‎src/sextante/lastools/LasToolsAlgorithmProvider.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
from sextante.lastools.lasgrid import lasgrid
1212
from sextante.lastools.lasground import lasground
1313
from sextante.lastools.lasinfo import lasinfo
14+
from sextante.lastools.lasheight import lasheight
15+
from sextante.lastools.lasprecision import lasprecision
16+
from sextante.lastools.lassplit import lassplit
1417

1518

1619
class LasToolsAlgorithmProvider(AlgorithmProvider):
1720

1821
def __init__(self):
1922
AlgorithmProvider.__init__(self)
20-
self.algsList = [las2shp(), lasboundary(), las2dem(), las2iso(), lasgrid(), lasground(), lasinfo()]
23+
self.algsList = [las2shp(), lasboundary(), las2dem(), las2iso(), lasgrid(), lasground(),
24+
lasinfo(), lasheight(), lasprecision(), lassplit()]
2125

2226
def initializeSettings(self):
2327
AlgorithmProvider.initializeSettings(self)

‎src/sextante/lastools/las2dem.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ class las2dem(LasToolsAlgorithm):
1313
OUTPUT = "OUTPUT"
1414
INTENSITY = "INTENSITY"
1515

16-
def getIcon(self):
17-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
18-
return QtGui.QIcon(filepath)
19-
2016
def defineCharacteristics(self):
2117
self.name = "las2dem"
2218
self.group = "Tools"

‎src/sextante/lastools/las2iso.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ class las2iso(LasToolsAlgorithm):
1616
SIMPLIFY = "SIMPLIFY"
1717
INTERVAL = "INTERVAL"
1818

19-
def getIcon(self):
20-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
21-
return QtGui.QIcon(filepath)
22-
2319
def defineCharacteristics(self):
2420
self.name = "las2iso"
2521
self.group = "Tools"

‎src/sextante/lastools/las2shp.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import os
2-
from PyQt4 import QtGui
3-
from sextante.parameters.ParameterString import ParameterString
42
from sextante.outputs.OutputVector import OutputVector
53
from sextante.lastools.LasToolsUtils import LasToolsUtils
64
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
@@ -11,10 +9,6 @@ class las2shp(LasToolsAlgorithm):
119
INPUT = "INPUT"
1210
OUTPUT = "OUTPUT"
1311

14-
def getIcon(self):
15-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
16-
return QtGui.QIcon(filepath)
17-
1812
def defineCharacteristics(self):
1913
self.name = "las2shp"
2014
self.group = "Tools"

‎src/sextante/lastools/lasboundary.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ class lasboundary(LasToolsAlgorithm):
1717
DISJOINT = "DISJOINT"
1818
HOLES = "HOLES"
1919

20-
21-
def getIcon(self):
22-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
23-
return QtGui.QIcon(filepath)
24-
2520
def defineCharacteristics(self):
2621
self.name = "lasboundary"
2722
self.group = "Tools"

‎src/sextante/lastools/lasgrid.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ class lasgrid(LasToolsAlgorithm):
1616
METHOD = "METHOD"
1717
METHODS = ["-average", "-lowest", "-highest", "-stddev"]
1818

19-
def getIcon(self):
20-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
21-
return QtGui.QIcon(filepath)
22-
2319
def defineCharacteristics(self):
2420
self.name = "lasgrid"
2521
self.group = "Tools"

‎src/sextante/lastools/lasground.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ class lasground(LasToolsAlgorithm):
1717
METHOD = "METHOD"
1818
METHODS = ["terrain", "town", "city"]
1919

20-
def getIcon(self):
21-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
22-
return QtGui.QIcon(filepath)
23-
2420
def defineCharacteristics(self):
2521
self.name = "lasground"
2622
self.group = "Tools"

‎src/sextante/lastools/lasheight.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
from sextante.lastools.LasToolsUtils import LasToolsUtils
3+
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
4+
from sextante.parameters.ParameterFile import ParameterFile
5+
from sextante.outputs.OutputFile import OutputFile
6+
7+
class lasheight(LasToolsAlgorithm):
8+
9+
INPUT = "INPUT"
10+
OUTPUT = "OUTPUT"
11+
12+
def defineCharacteristics(self):
13+
self.name = "lasheight"
14+
self.group = "Tools"
15+
self.addParameter(ParameterFile(lasheight.INPUT, "Input las layer", ""))
16+
self.addOutput(OutputFile(lasheight.OUTPUT, "Output height las file"))
17+
self.addCommonParameters()
18+
19+
def processAlgorithm(self, progress):
20+
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "lasheight.exe")]
21+
commands.append("-i")
22+
commands.append(self.getParameterValue(lasheight.INPUT))
23+
commands.append("-o")
24+
commands.append(self.getOutputValue(lasheight.OUTPUT))
25+
self.addCommonParameterValuesToCommand(commands)
26+
27+
LasToolsUtils.runLasTools(commands, progress)

‎src/sextante/lastools/lasinfo.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from PyQt4 import QtGui
32
from sextante.lastools.LasToolsUtils import LasToolsUtils
43
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
54
from sextante.parameters.ParameterFile import ParameterFile
@@ -10,10 +9,6 @@ class lasinfo(LasToolsAlgorithm):
109
INPUT = "INPUT"
1110
OUTPUT = "OUTPUT"
1211

13-
def getIcon(self):
14-
filepath = os.path.dirname(__file__) + "/../images/tool.png"
15-
return QtGui.QIcon(filepath)
16-
1712
def defineCharacteristics(self):
1813
self.name = "lasinfo"
1914
self.group = "Tools"

‎src/sextante/lastools/lasprecision.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import os
2+
from PyQt4 import QtGui
3+
from sextante.lastools.LasToolsUtils import LasToolsUtils
4+
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
5+
from sextante.parameters.ParameterFile import ParameterFile
6+
from sextante.outputs.OutputHTML import OutputHTML
7+
8+
class lasprecision(LasToolsAlgorithm):
9+
10+
INPUT = "INPUT"
11+
OUTPUT = "OUTPUT"
12+
13+
def defineCharacteristics(self):
14+
self.name = "lasprecision"
15+
self.group = "Tools"
16+
self.addParameter(ParameterFile(lasprecision.INPUT, "Input las layer", ""))
17+
self.addOutput(OutputHTML(lasprecision.OUTPUT, "Output info file"))
18+
19+
def processAlgorithm(self, progress):
20+
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "lasprecision.exe")]
21+
commands.append("-i")
22+
commands.append(self.getParameterValue(lasprecision.INPUT))
23+
commands.append(">")
24+
commands.append(self.getOutputValue(lasprecision.OUTPUT) + ".txt")
25+
26+
LasToolsUtils.runLasTools(commands, progress)
27+
fin = open (self.getOutputValue(lasprecision.OUTPUT) + ".txt")
28+
fout = open (self.getOutputValue(lasprecision.OUTPUT), "w")
29+
lines = fin.readlines()
30+
for line in lines:
31+
fout.write(line + "<br>")
32+
fin.close()
33+
fout.close()
34+

‎src/sextante/lastools/lassplit.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
from sextante.lastools.LasToolsUtils import LasToolsUtils
3+
from sextante.lastools.LasToolsAlgorithm import LasToolsAlgorithm
4+
from sextante.parameters.ParameterFile import ParameterFile
5+
from sextante.outputs.OutputFile import OutputFile
6+
from sextante.parameters.ParameterNumber import ParameterNumber
7+
8+
class lassplit(LasToolsAlgorithm):
9+
10+
INPUT = "INPUT"
11+
OUTPUT = "OUTPUT"
12+
NUM_POINTS = "NUM_POINTS"
13+
14+
def defineCharacteristics(self):
15+
self.name = "lassplit"
16+
self.group = "Tools"
17+
self.addParameter(ParameterFile(lassplit.INPUT, "Input las layer", ""))
18+
self.addParameter(ParameterNumber(lassplit.NUM_POINTS, "Point in each output file", 1, None, 1000000))
19+
self.addOutput(OutputFile(lassplit.OUTPUT, "Output las file basename"))
20+
self.addCommonParameters()
21+
22+
def processAlgorithm(self, progress):
23+
commands = [os.path.join(LasToolsUtils.LasToolsPath(), "bin", "lassplit.exe")]
24+
commands.append("-i")
25+
commands.append(self.getParameterValue(lassplit.INPUT))
26+
commands.append("-o")
27+
commands.append(self.getOutputValue(lassplit.OUTPUT))
28+
commands.append("-split")
29+
commands.append(self.getParameterValue(lassplit.NUM_POINTS))
30+
self.addCommonParameterValuesToCommand(commands)
31+
32+
LasToolsUtils.runLasTools(commands, progress)

‎src/sextante/saga/SagaAlgorithm.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,21 @@ def calculateResamplingExtent(self):
8181
if auto:
8282
first = True;
8383
for param in self.parameters:
84-
if isinstance(param, ParameterRaster):
85-
if isinstance(param.value, QgsRasterLayer):
86-
layer = param.value
87-
else:
88-
layer = QGisLayers.getObjectFromUri(param.value)
89-
self.addToResamplingExtent(layer, first)
90-
first = False
91-
if isinstance(param, ParameterMultipleInput):
92-
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
93-
layers = param.value.split(";")
94-
for layername in layers:
95-
layer = QGisLayers.getObjectFromUri(layername)
96-
self.addToResamplingExtent(layer, first)
97-
first = False
84+
if param.value:
85+
if isinstance(param, ParameterRaster):
86+
if isinstance(param.value, QgsRasterLayer):
87+
layer = param.value
88+
else:
89+
layer = QGisLayers.getObjectFromUri(param.value)
90+
self.addToResamplingExtent(layer, first)
91+
first = False
92+
if isinstance(param, ParameterMultipleInput):
93+
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
94+
layers = param.value.split(";")
95+
for layername in layers:
96+
layer = QGisLayers.getObjectFromUri(layername)
97+
self.addToResamplingExtent(layer, first)
98+
first = False
9899
else:
99100
self.xmin = SextanteConfig.getSetting(SagaUtils.SAGA_RESAMPLING_REGION_XMIN)
100101
self.xmax = SextanteConfig.getSetting(SagaUtils.SAGA_RESAMPLING_REGION_XMAX)
@@ -183,7 +184,7 @@ def processAlgorithm(self, progress):
183184
command = "lib" + self.undecoratedGroup + " \"" + self.name + "\""
184185

185186
for param in self.parameters:
186-
if param.value == None:
187+
if param.value is None:
187188
continue
188189
if isinstance(param, (ParameterRaster, ParameterVector)):
189190
value = param.value

0 commit comments

Comments
 (0)
Please sign in to comment.