Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix indendation problems (as usual)...
  • Loading branch information
Médéric RIBREUX committed Jan 2, 2016
1 parent af01652 commit d6fbe93
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 28 deletions.
14 changes: 7 additions & 7 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -222,7 +222,7 @@ def processAlgorithm(self, progress):
raise GeoAlgorithmExecutionException(
self.tr('GRASS GIS 7 folder is not configured. Please '
'configure it before running GRASS GIS 7 algorithms.'))

# Create brand new commands lists
self.commands = []
self.outputCommands = []
Expand All @@ -244,13 +244,13 @@ def processAlgorithm(self, progress):
func(self)
else:
self.processInputs()

if hasattr(self.module, 'processCommand'):
func = getattr(self.module, 'processCommand')
func(self)
else:
self.processCommand()

if hasattr(self.module, 'processOutputs'):
func = getattr(self.module, 'processOutputs')
func(self)
Expand Down Expand Up @@ -389,7 +389,7 @@ def processCommand(self):
command += ' ' + param.name + '="' + unicode(param.value) + '"'
else:
command += ' ' + param.name + '="' + unicode(param.value) + '"'

for out in self.outputs:
if isinstance(out, OutputFile):
command += ' > ' + out.value
Expand All @@ -405,7 +405,7 @@ def processCommand(self):

command += ' --overwrite'
self.commands.append(command)

def processOutputs(self):
"""Prepare the GRASS v.out.ogr commands"""
for out in self.outputs:
Expand All @@ -416,7 +416,7 @@ def processOutputs(self):
# exporting
self.commands.append('g.region raster=' + out.name + self.uniqueSufix)
self.outputCommands.append('g.region raster=' + out.name
+ self.uniqueSufix)
+ self.uniqueSufix)

if self.grass7Name == 'r.statistics':
# r.statistics saves its results in a non-qgis compatible
Expand Down Expand Up @@ -477,7 +477,7 @@ def processOutputs(self):
command += ' output_layer=' + os.path.basename(out.value)[:-4]
self.commands.append(command)
self.outputCommands.append(command)

def exportVectorLayer(self, orgFilename):

# TODO: improve this. We are now exporting if it is not a shapefile,
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/grass7/ext/v_net_alloc.py
Expand Up @@ -27,5 +27,6 @@

from v_net import incorporatePoints


def processCommand(alg):
incorporatePoints(alg)
Expand Up @@ -27,5 +27,6 @@

from v_net import incorporatePoints


def processCommand(alg):
incorporatePoints(alg)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/v_net_bridge.py
Expand Up @@ -27,7 +27,7 @@

from v_net import variableOutput


def processOutputs(alg):
outputParameter = { u"output": { u"method" : { 0: u"line", 1: u"point" } } }
outputParameter = {u"output": {u"method": {0: u"line", 1: u"point"}}}
variableOutput(alg, outputParameter)

7 changes: 4 additions & 3 deletions python/plugins/processing/algs/grass7/ext/v_net_components.py
Expand Up @@ -27,6 +27,7 @@

from v_net import variableOutput


def processCommand(alg):
# remove the output for point
outPoint = alg.getOutputFromName(u'output_point')
Expand All @@ -39,8 +40,8 @@ def processCommand(alg):
# Re-add output for point
alg.addOutput(outPoint)


def processOutputs(alg):
outputParameter = { u"output": u"line",
u"output_point": u"point" }
outputParameter = {u"output": u"line",
u"output_point": u"point"}
variableOutput(alg, outputParameter)

12 changes: 7 additions & 5 deletions python/plugins/processing/algs/grass7/ext/v_net_connectivity.py
Expand Up @@ -27,23 +27,25 @@

from v_net import incorporatePoints, variableOutput


def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
params = [u'where', u'cats']
values = []
for param in params:
for i in range(1,3):
values.append(alg.getParameterValue(u'set{}_{}'.format(i,param)))
for i in range(1, 3):
values.append(alg.getParameterValue(u'set{}_{}'.format(i, param)))

if (values[0] or values[2]) and (values[1] or values[3]):
return None

return alg.tr("You need to set at least setX_where or setX_cats parameters for each set !")


def processCommand(alg):
incorporatePoints(alg)



def processOutputs(alg):
outputParameter = { u"output": u"point" }
outputParameter = {u"output": u"point"}
variableOutput(alg, outputParameter)

13 changes: 7 additions & 6 deletions python/plugins/processing/algs/grass7/ext/v_net_distance.py
Expand Up @@ -28,6 +28,7 @@

from processing.core.parameters import getParameterFromString, ParameterVector, ParameterNumber, ParameterBoolean, ParameterString


def processCommand(alg):
""" Handle data preparation for v.net.distance:
* Integrate point layers into network vector map.
Expand All @@ -51,15 +52,15 @@ def processCommand(alg):
for i, layer in enumerate([u'from', u'to']):
# Get a temp layer name
intLayer = alg.getTempFilename()

# Grab the from point layer and delete this parameter (not used by v.net.distance)
point_layer = alg.getParameterValue(layer + u'_points')
if point_layer:
point_layer = alg.exportedLayers[point_layer]
paramsToDelete.append(alg.getParameterFromName(layer + u'_points'))

# Create the v.net connect command for point layer integration
command = u"v.net -s input={} points={} out={} op=connect threshold={} arc_layer=1 node_layer={}".format( line_layer, point_layer, intLayer, threshold, i+2 )
command = u"v.net -s input={} points={} out={} op=connect threshold={} arc_layer=1 node_layer={}".format(line_layer, point_layer, intLayer, threshold, i + 2)
alg.commands.append(command)
line_layer = intLayer

Expand All @@ -68,20 +69,20 @@ def processCommand(alg):
if not parameter:
parameter = getParameterFromString(u'ParameterNumber|{0}_layer|{0} layer number|1|3|2|False'.format(layer))
alg.addParameter(parameter)
parameter.setValue(i+2)
parameter.setValue(i + 2)

# Make the connection with attribute table
command = u"v.db.connect -o map={} table={} layer={}".format(line_layer, point_layer, i+2)
command = u"v.db.connect -o map={} table={} layer={}".format(line_layer, point_layer, i + 2)
alg.commands.append(command)

alg.setParameterValue(u'input', line_layer)

# Delete some unnecessary parameters
for param in paramsToDelete:
alg.parameters.remove(param)

alg.processCommand()

# Bring back the parameters:
for param in paramsToDelete:
alg.parameters.append(param)
Expand Down
9 changes: 6 additions & 3 deletions python/plugins/processing/algs/grass7/ext/v_net_flow.py
Expand Up @@ -28,23 +28,26 @@

from v_net import incorporatePoints, processOutputs


def checkParameterValuesBeforeExecuting(alg):
""" Verify if we have the right parameters """
params = [u'where', u'cats']
values = []
for param in params:
for i in [u'source', u'sink']:
values.append(alg.getParameterValue(u'{}_{}'.format(i,param)))
values.append(alg.getParameterValue(u'{}_{}'.format(i, param)))

if (values[0] or values[2]) and (values[1] or values[3]):
return None

return alg.tr("You need to set at least source/sink_where or source/sink_cats parameters for each set !")


def processCommand(alg):
incorporatePoints(alg)


def processOutputs(alg):
outputParameter = { u"output": u"line",
u"cut": u"line" }
outputParameter = {u"output": u"line",
u"cut": u"line"}
variableOutput(alg, outputParameter)
1 change: 1 addition & 0 deletions python/plugins/processing/algs/grass7/ext/v_net_iso.py
Expand Up @@ -27,5 +27,6 @@

from v_net import incorporatePoints


def processCommand(alg):
incorporatePoints(alg)
1 change: 1 addition & 0 deletions python/plugins/processing/algs/grass7/ext/v_net_path.py
Expand Up @@ -27,5 +27,6 @@

from v_net import incorporatePoints


def processCommand(alg):
incorporatePoints(alg)
Expand Up @@ -28,6 +28,7 @@
from processing.core.parameters import getParameterFromString
from v_net import incorporatePoints


def processCommand(alg):
# We temporary remove the output 'sequence'
sequence = alg.getOutputFromName(u'sequence')
Expand All @@ -46,4 +47,3 @@ def processCommand(alg):
# then we delete the input parameter and add the old output
alg.parameters.remove(param)
alg.addOutput(sequence)

1 change: 1 addition & 0 deletions python/plugins/processing/algs/grass7/ext/v_net_steiner.py
Expand Up @@ -27,5 +27,6 @@

from v_net import incorporatePoints


def processCommand(alg):
incorporatePoints(alg)
Expand Up @@ -27,6 +27,7 @@

from v_net import variableOutput


def processOutputs(alg):
outputParameter = { u"output": u"line" }
outputParameter = {u"output": u"line"}
variableOutput(alg, outputParameter, False)

0 comments on commit d6fbe93

Please sign in to comment.