Skip to content

Commit

Permalink
Polished some GRASS descriptions
Browse files Browse the repository at this point in the history
Fixed small bug when handling selection parameters
added statistical values to numerical value selector

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@58 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed Apr 3, 2012
1 parent c9b2d62 commit b74ae41
Show file tree
Hide file tree
Showing 52 changed files with 172 additions and 292 deletions.
2 changes: 1 addition & 1 deletion src/sextante/ftools/ConvexHull.py
Expand Up @@ -31,7 +31,7 @@ def processAlgorithm(self, progress):
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
output = self.getOutputValue(ConvexHull.OUTPUT)
useSelection = self.getParameterValue(ConvexHull.USE_SELECTED)
useField = (self.getParameterValue(ConvexHull.METHOD) == ConvexHull.METHODS[1])
useField = (self.getParameterValue(ConvexHull.METHOD) == 1)
field = self.getParameterValue(ConvexHull.FIELD)
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(ConvexHull.INPUT))
GEOS_EXCEPT = True
Expand Down
53 changes: 33 additions & 20 deletions src/sextante/grass/GrassAlgorithm.py
Expand Up @@ -19,6 +19,7 @@
from sextante.grass.GrassUtils import GrassUtils
import time
from sextante.core.SextanteUtils import SextanteUtils
from sextante.parameters.ParameterSelection import ParameterSelection

class GrassAlgorithm(GeoAlgorithm):

Expand Down Expand Up @@ -75,24 +76,20 @@ def calculateResamplingExtent(self):
if auto:
first = True;
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector)):
if isinstance(param.value, (QgsRasterLayer, QgsVectorLayer)):
value = param.value
if isinstance(param, ParameterRaster):
if isinstance(param.value, QgsRasterLayer):
layer = param.value
else:
value = QGisLayers.getObjectFromUri(param.value)
if first:
self.xmin = value.extent().xMinimum()
self.xmax = value.extent().xMaximum()
self.ymin = value.extent().yMinimum()
self.ymax = value.extent().yMaximum()
self.cellsize = (value.extent().xMaximum() - value.extent().xMinimum())/value.getRasterXDim()
first = False
else:
self.xmin = min(self.xmin, value.extent().xMinimum())
self.xmax = max(self.xmax, value.extent().xMaximum())
self.ymin = min(self.ymin, value.extent().yMinimum())
self.ymax = max(self.ymax, value.extent().yMaximum())
self.cellsize = max(self.cellsize, (value.extent().xMaximum() - value.extent().xMinimum())/value.getRasterXDim())
layer = QGisLayers.getObjectFromUri(param.value)
self.addToResamplingExtent(layer, first)
first = False
if isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
layers = param.value.split(";")
for layername in layers:
layer = QGisLayers.getObjectFromUri(layername, first)
self.addToResamplingExtent(layer, first)
first = False
else:
self.xmin = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_XMIN)
self.xmax = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_XMAX)
Expand All @@ -101,6 +98,21 @@ def calculateResamplingExtent(self):
self.cellsize = SextanteConfig.getSetting(GrassUtils.GRASS_REGION_CELLSIZE)


def addToResamplingExtent(self, layer, first):
if first:
self.xmin = layer.extent().xMinimum()
self.xmax = layer.extent().xMaximum()
self.ymin = layer.extent().yMinimum()
self.ymax = layer.extent().yMaximum()
self.cellsize = (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width()
else:
self.xmin = min(self.xmin, layer.extent().xMinimum())
self.xmax = max(self.xmax, layer.extent().xMaximum())
self.ymin = min(self.ymin, layer.extent().yMinimum())
self.ymax = max(self.ymax, layer.extent().yMaximum())
self.cellsize = max(self.cellsize, (layer.extent().xMaximum() - layer.extent().xMinimum())/layer.width())


def processAlgorithm(self, progress):
path = GrassUtils.grassPath()
if path == "":
Expand All @@ -110,11 +122,9 @@ def processAlgorithm(self, progress):
self.exportedLayers = {}
self.numExportedLayers = 0;

##if self.needsregion:
self.calculateResamplingExtent()
GrassUtils.createTempMapset();

##if self.needsregion:
command = "g.region"
command += " n=" + str(self.ymax)
command +=" s=" + str(self.ymin)
Expand Down Expand Up @@ -169,7 +179,10 @@ def processAlgorithm(self, progress):
command+=(" " + param.name + "=" + s);
elif isinstance(param, ParameterBoolean):
if param.value:
command += param.name
command += (" " + param.name)
elif isinstance(param, ParameterSelection):
idx = int(param.value)
command+=(" " + param.name + "=" + str(param.options[idx]));
else:
command+=(" " + param.name + "=" + str(param.value));

Expand Down
10 changes: 6 additions & 4 deletions src/sextante/grass/GrassUtils.py
Expand Up @@ -4,6 +4,7 @@
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.SextanteLog import SextanteLog
import stat
import shutil

class GrassUtils:

Expand Down Expand Up @@ -161,14 +162,14 @@ def createTempMapset():
GrassUtils.writeGrassWindow(os.path.join(folder, "PERMANENT", "WIND"));
mkdir(os.path.join(folder, "user", "dbf"))
mkdir(os.path.join(folder, "user", ".tmp"))
outfile = open(mkdir(os.path.join(folder, "user", "VAR"), "w"))
outfile = open(os.path.join(folder, "user", "VAR"), "w")
outfile.write("DB_DRIVER: dbf\n");
outfile.write("DB_DATABASE: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/\n");
outfile.close()
GrassUtils.writeGrassWindow(os.path.join(folder, "user", "WIND"));

@staticmethod
def writeGRASSWindow(filename):
def writeGrassWindow(filename):
out = open(filename, "w")
latlon = SextanteConfig.getSetting(GrassUtils.GRASS_LATLON)
if not latlon:
Expand Down Expand Up @@ -232,9 +233,10 @@ def executeGrass(commands, progress):
pass
loglines.append(line)
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
shutil.rmtree(GrassUtils.grassMapsetFolder(), True)


def getGrassVersion(self):
@staticmethod
def getGrassVersion():
#I do not know if this should be removed or let the user enter it
#or something like that... This is just a temporary thing
return "6.4.0"
Expand Down
18 changes: 0 additions & 18 deletions src/sextante/grass/description/alg_100.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/sextante/grass/description/alg_3.txt
@@ -1,6 +1,6 @@
v.random
Vector (v.*)
ParameterString|n|n|None|None|0.0
ParameterNumber|n|n|None|None|0.0
ParameterNumber|zmin|zmin|None|None|0.0
ParameterString|zmax|zmax|None|None|0.0
ParameterTableField|column|column|z
Expand Down
5 changes: 0 additions & 5 deletions src/sextante/grass/description/alg_44.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/sextante/grass/description/alg_44b.txt
@@ -1,4 +1,4 @@
r.reclass.area.greater
r.reclass.area
Raster (r.*)
ParameterRaster|input|input|False
ParameterNumber|greater|greater|None|None|0.0
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/grass/description/alg_50.txt
@@ -1,7 +1,7 @@
r.prominence
Raster (r.*)
ParameterRaster|input|input|False
ParameterString|radius|radius|1
ParameterNumber|radius|radius|1|None|1
ParameterBoolean|-a|-a|True
ParameterBoolean|-l|-l|True
ParameterBoolean|-g|-g|True
Expand Down
2 changes: 1 addition & 1 deletion src/sextante/grass/description/alg_52.txt
Expand Up @@ -2,7 +2,7 @@ v.out.pov
Vector (v.*)
ParameterVector|input|input|-1|False
ParameterString|type|type|point,line,area,face
ParameterString|output|output|
ParameterString|output|output|/file
ParameterString|size|size|10
ParameterString|zmod|zmod|
ParameterString|objmod|objmod|
12 changes: 0 additions & 12 deletions src/sextante/grass/description/alg_53.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/sextante/grass/description/alg_54.txt
Expand Up @@ -3,7 +3,7 @@ Vector (v.*)
ParameterVector|input|input|-1|False
ParameterSelection|distribution|distribution|uniform;normal
ParameterString|parameters|parameters|
ParameterString|minimum|minimum|0.0
ParameterString|seed|seed|0
ParameterNumber|minimum|minimum|None|None|0.0
ParameterNumber|seed|seed|None|None|0
ParameterBoolean|-q|-q|True
OutputVector|output|output
12 changes: 0 additions & 12 deletions src/sextante/grass/description/alg_55.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/sextante/grass/description/alg_56.txt
@@ -1,6 +1,6 @@
r.cross
Raster (r.*)
ParameterMultipleInput|input|input|1.0|False
ParameterMultipleInput|input|input|3|False
ParameterBoolean|-z|-z|True
ParameterBoolean|-q|-q|True
OutputRaster|output|output
6 changes: 0 additions & 6 deletions src/sextante/grass/description/alg_57.txt

This file was deleted.

5 changes: 0 additions & 5 deletions src/sextante/grass/description/alg_60.txt

This file was deleted.

13 changes: 0 additions & 13 deletions src/sextante/grass/description/alg_61.txt

This file was deleted.

5 changes: 0 additions & 5 deletions src/sextante/grass/description/alg_62.txt

This file was deleted.

7 changes: 3 additions & 4 deletions src/sextante/grass/description/alg_63.txt
@@ -1,11 +1,10 @@
v.extrude
Vector (v.*)
ParameterVector|input|input|-1|False
ParameterString|zshift|zshift|0
ParameterNumber|zshift|zshift|None|None|0
ParameterRaster|elevation|elevation|False
ParameterString|height|height|
ParameterString|hcolumn|hcolumn|
ParameterNumber|height|height|None|None|0
ParameterNumber|hcolumn|hcolumn|None|None|0
ParameterString|type|type|point,line,boundary,area
ParameterString|layer|layer|1
ParameterBoolean|-t|-t|True
OutputVector|output|output
5 changes: 2 additions & 3 deletions src/sextante/grass/description/alg_65.txt
@@ -1,9 +1,8 @@
v.clean
Vector (v.*)
ParameterVector|input|input|-1|False
ParameterString|type|type|point,line,boundary,centroid,area
ParameterString|tool|tool|
ParameterString|thresh|thresh|
ParameterSelection|tool|tool|break;snap;rmdangle;chdangle;rmbridge;chbridge;rmdupl;rmdac;bpol;prune;rmarea;rmline;rmsa
ParameterNumber|thresh|thresh|None|None|0
ParameterBoolean|-b|-b|True
OutputVector|output|output
OutputVector|error|error
11 changes: 0 additions & 11 deletions src/sextante/grass/description/alg_66.txt

This file was deleted.

23 changes: 11 additions & 12 deletions src/sextante/grass/description/alg_67.txt
Expand Up @@ -3,24 +3,23 @@ Raster (r.*)
ParameterRaster|input|input|False
ParameterRaster|target_mask|target_mask|False
ParameterRaster|viewpt_mask|viewpt_mask|False
ParameterVector|sites|sites|-1|False
ParameterString|layer|layer|1
ParameterString|obs_elev|obs_elev|1.75
ParameterString|target_elev|target_elev|0.0
ParameterString|max_dist|max_dist|2000
ParameterString|seed|seed|1
ParameterString|sample|sample|10.0
ParameterVector|sites|sites|0|False
ParameterNumber|obs_elev|obs_elev|None|None|1.75
ParameterNumber|target_elev|target_elev|None|None|0.0
ParameterNumber|max_dist|max_dist|None|None|2000
ParameterNumber|seed|seed|None|None|1
ParameterNumber|sample|sample|None|None|10.0
ParameterSelection|type|type|sites;systematic;random;all
ParameterString|spot|spot|
ParameterString|offseta|offseta|
ParameterString|offsetb|offsetb|
ParameterString|azimuth1|azimuth1|
ParameterString|azimuth2|azimuth2|
ParameterString|vert1|vert1|
ParameterString|vert2|vert2|
ParameterString|radius1|radius1|
ParameterString|radius2|radius2|
ParameterString|curvc|curvc|0.0
ParameterString|vert1|vert1|None|None|0
ParameterString|vert2|vert2|None|None|0
ParameterNumber|radius1|radius1|None|None|1
ParameterNumber|radius2|radius2|None|None|1
ParameterNumber|curvc|curvc|None|None|0.0
ParameterBoolean|-f|-f|True
ParameterBoolean|-m|-m|True
ParameterBoolean|-a|-a|True
Expand Down
9 changes: 0 additions & 9 deletions src/sextante/grass/description/alg_68.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/sextante/grass/description/alg_69.txt
Expand Up @@ -2,6 +2,6 @@ v.lidar.growing
Vector (v.*)
ParameterVector|input|input|-1|False
ParameterVector|first|first|-1|False
ParameterString|tj|tj|0.2
ParameterString|td|td|0.6
ParameterNumber|tj|tj|None|None|0.2
ParameterNumber|td|td|None|None|0.6
OutputVector|output|output
22 changes: 7 additions & 15 deletions src/sextante/grass/description/alg_70.txt
@@ -1,19 +1,11 @@
v.transform
Vector (v.*)
ParameterVector|input|input|-1|False
ParameterString|pointsfile|pointsfile|/file
ParameterString|xshift|xshift|0.0
ParameterString|yshift|yshift|0.0
ParameterString|zshift|zshift|0.0
ParameterString|xscale|xscale|1.0
ParameterString|yscale|yscale|1.0
ParameterString|zscale|zscale|1.0
ParameterString|zrot|zrot|0.0
ParameterString|table|table|
ParameterString|columns|columns|
ParameterString|layer|layer|1
ParameterBoolean|-q|-q|True
ParameterBoolean|-t|-t|True
ParameterBoolean|-m|-m|True
ParameterBoolean|-s|-s|True
ParameterString|xshift|xshift|None|None|0.0
ParameterString|yshift|yshift|None|None|0.0
ParameterString|zshift|zshift|None|None|0.0
ParameterString|xscale|xscale|None|None|1.0
ParameterString|yscale|yscale|None|None|1.0
ParameterString|zscale|zscale|None|None|1.0
ParameterString|zrot|zrot|None|None|0.0
OutputVector|output|output
5 changes: 0 additions & 5 deletions src/sextante/grass/description/alg_71.txt

This file was deleted.

0 comments on commit b74ae41

Please sign in to comment.