diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py
index 1e619eb4dd2..5b064b238e4 100644
--- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py
+++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py
@@ -631,15 +631,13 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
if outName in parameters and parameters[outName] is not None:
# for HTML reports, we need to redirect stdout
if out.defaultFileExtension().lower() == 'html':
- command += ' > "{}"'.format(
- self.parameterAsFileOutput(
- parameters, outName, context)
- )
+ command += ' {}=- > "{}"'.format(
+ outName,
+ self.parameterAsFileOutput(parameters, outName, context))
else:
command += ' {}="{}"'.format(
outName,
- self.parameterAsFileOutput(
- parameters, outName, context))
+ self.parameterAsFileOutput(parameters, outName, context))
# For folders destination
elif isinstance(out, QgsProcessingParameterFolderDestination):
# We need to add a unique temporary basename
diff --git a/python/plugins/processing/algs/grass7/description/v.net.nreport.txt b/python/plugins/processing/algs/grass7/description/v.net.nreport.txt
index 11aa8eed5f2..d45a4923ec1 100644
--- a/python/plugins/processing/algs/grass7/description/v.net.nreport.txt
+++ b/python/plugins/processing/algs/grass7/description/v.net.nreport.txt
@@ -3,4 +3,4 @@ v.net.nreport - Reports nodes information of a network
Vector (v.*)
QgsProcessingParameterFeatureSource|input|Input vector line layer (arcs)|1|None|False
Hardcoded|operation=nreport
-QgsProcessingParameterFileDestination|html|NReport|Html files (*.html)|None|False
+QgsProcessingParameterFileDestination|output|NReport|Html files (*.html)|None|False
diff --git a/python/plugins/processing/algs/grass7/description/v.net.report.txt b/python/plugins/processing/algs/grass7/description/v.net.report.txt
index 56ef1a72f21..de790ff7d0a 100644
--- a/python/plugins/processing/algs/grass7/description/v.net.report.txt
+++ b/python/plugins/processing/algs/grass7/description/v.net.report.txt
@@ -3,4 +3,4 @@ v.net.report - Reports lines information of a network
Vector (v.*)
QgsProcessingParameterFeatureSource|input|Input vector line layer (arcs)|1|None|False
Hardcoded|operation=report
-QgsProcessingParameterFileDestination|html|Report|Html files (*.html)|None|False
+QgsProcessingParameterFileDestination|output|Report|Html files (*.html)|None|False
diff --git a/python/plugins/processing/algs/grass7/description/v.net.salesman.txt b/python/plugins/processing/algs/grass7/description/v.net.salesman.txt
index cb423c7b40b..cf044a606e9 100644
--- a/python/plugins/processing/algs/grass7/description/v.net.salesman.txt
+++ b/python/plugins/processing/algs/grass7/description/v.net.salesman.txt
@@ -10,5 +10,5 @@ QgsProcessingParameterNumber|threshold|Threshold for connecting centers to the n
*QgsProcessingParameterField|arc_backward_column|Arc backward direction cost column (number)|None|input|0|False|True
*QgsProcessingParameterBoolean|-g|Use geodesic calculation for longitude-latitude locations|False|True
QgsProcessingParameterVectorDestination|output|Network_Salesman
-QgsProcessingParameterFileDestination|sequence|Output file holding node sequence|Html files (*.html)|report.html|True
+QgsProcessingParameterFileDestination|sequence|Output file holding node sequence|CSV files (*.csv)|None|True
diff --git a/python/plugins/processing/algs/grass7/ext/v_net.py b/python/plugins/processing/algs/grass7/ext/v_net.py
index e84357a491a..87e84f7dabb 100644
--- a/python/plugins/processing/algs/grass7/ext/v_net.py
+++ b/python/plugins/processing/algs/grass7/ext/v_net.py
@@ -58,12 +58,12 @@ def incorporatePoints(alg, parameters, context, feedback, pointLayerName='points
threshold = alg.parameterAsDouble(parameters, 'threshold', context)
# Create the v.net connect command for point layer integration
- command = u"v.net input={} points={} output={} operation=connect threshold={}".format(
+ command = 'v.net -s input={} points={} output={} operation=connect threshold={}'.format(
lineLayer, pointLayer, intLayer, threshold)
alg.commands.append(command)
# Connect the point layer database to the layer 2 of the network
- command = u"v.db.connect -o map={} table={} layer=2".format(intLayer, pointLayer)
+ command = 'v.db.connect -o map={} table={} layer=2'.format(intLayer, pointLayer)
alg.commands.append(command)
# remove undesired parameters
@@ -111,7 +111,7 @@ def variableOutput(alg, layers, parameters, context, nocats=True):
alg.exportVectorLayer(grassName=grass_name,
fileName=file_name,
layer=output_layer_number,
- nocats=no_cats,
+ exportnocat=no_cats,
dataType=output_type)
diff --git a/python/plugins/processing/algs/grass7/ext/v_net_connectivity.py b/python/plugins/processing/algs/grass7/ext/v_net_connectivity.py
index 5a393a25de1..0e5d04d9da9 100644
--- a/python/plugins/processing/algs/grass7/ext/v_net_connectivity.py
+++ b/python/plugins/processing/algs/grass7/ext/v_net_connectivity.py
@@ -30,14 +30,14 @@ from .v_net import incorporatePoints, variableOutput
def checkParameterValuesBeforeExecuting(alg, parameters, context):
""" Verify if we have the right parameters """
- params = [u'where', u'cats']
+ params = ['where', 'cats']
values = []
for param in params:
for i in range(1, 3):
values.append(
alg.parameterAsString(
parameters,
- u'set{}_{}'.format(i, param),
+ 'set{}_{}'.format(i, param),
context
)
)
@@ -45,7 +45,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
if (values[0] or values[2]) and (values[1] or values[3]):
return True, None
- return False, alg.tr("You need to set at least setX_where or setX_cats parameters for each set!")
+ return False, alg.tr('You need to set at least setX_where or setX_cats parameters for each set!')
def processCommand(alg, parameters, context, feedback):
diff --git a/python/plugins/processing/algs/grass7/ext/v_net_distance.py b/python/plugins/processing/algs/grass7/ext/v_net_distance.py
index babe573ff1f..0fd15b8f33c 100644
--- a/python/plugins/processing/algs/grass7/ext/v_net_distance.py
+++ b/python/plugins/processing/algs/grass7/ext/v_net_distance.py
@@ -48,20 +48,20 @@ def processCommand(alg, parameters, context, feedback):
threshold = alg.parameterAsDouble(parameters, 'threshold', context)
# Create the v.net connect command for from_layer integration
- command = u"v.net input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=2".format(
+ command = 'v.net -s input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=2'.format(
lineLayer, fromLayer, intLayer, threshold)
alg.commands.append(command)
# Do it again with to_layer
- command = u"v.net input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=3".format(
+ command = 'v.net -s input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=3'.format(
intLayer, toLayer, netLayer, threshold)
alg.commands.append(command)
# Connect the point layer database to the layer 2 of the network
- command = u"v.db.connect -o map={} table={} layer=2".format(netLayer, fromLayer)
+ command = 'v.db.connect -o map={} table={} layer=2'.format(netLayer, fromLayer)
alg.commands.append(command)
- command = u"v.db.connect -o map={} table={} layer=3".format(netLayer, toLayer)
+ command = 'v.db.connect -o map={} table={} layer=3'.format(netLayer, toLayer)
alg.commands.append(command)
# remove undesired parameters
diff --git a/python/plugins/processing/algs/grass7/ext/v_net_flow.py b/python/plugins/processing/algs/grass7/ext/v_net_flow.py
index 682f77484b1..110cffd390e 100644
--- a/python/plugins/processing/algs/grass7/ext/v_net_flow.py
+++ b/python/plugins/processing/algs/grass7/ext/v_net_flow.py
@@ -31,10 +31,10 @@ from .v_net import incorporatePoints, variableOutput
def checkParameterValuesBeforeExecuting(alg, parameters, context):
""" Verify if we have the right parameters """
- params = [u'where', u'cats']
+ params = ['where', 'cats']
values = []
for param in params:
- for i in [u'source', u'sink']:
+ for i in ['source', 'sink']:
values.append(
alg.parameterAsString(
parameters,
@@ -46,7 +46,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
if (values[0] or values[2]) and (values[1] or values[3]):
return True, None
- return False, alg.tr("You need to set at least source/sink_where or source/sink_cats parameters for each set!")
+ return False, alg.tr('You need to set at least source/sink_where or source/sink_cats parameters for each set!')
def processCommand(alg, parameters, context, feedback):
diff --git a/python/plugins/processing/tests/testdata/custom/grass7/point_end.gml b/python/plugins/processing/tests/testdata/custom/grass7/point_end.gml
new file mode 100644
index 00000000000..9660b9ebe66
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/custom/grass7/point_end.gml
@@ -0,0 +1,19 @@
+
+
1 -1 -1 +2 -1 -1 +3 -1 -1 +4 -1 -1 +5 -1 -1 +6 -1 -1 +7 -1 -1 +8 -1 -1 +9 -1 -1 +10 -1 -1 +11 -1 -1 +12 -1 -1 +13 -1 -1 +14 -1 -1 +15 -1 -1 +16 -1 -1 +17 -1 -1 +18 -1 -1 +19 -1 -1 +20 -1 -1 +21 -1 -1 +22 -1 -1 +23 -1 -1 +24 -1 -1 +25 -1 -1 +26 -1 -1 +
\ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman_seq.csv b/python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman_seq.csv new file mode 100644 index 00000000000..814f790d6bf --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman_seq.csv @@ -0,0 +1,4 @@ +sequence;category;cost_to_next +1;1;0.000 +2;2;0.000 +3;3;0.000 diff --git a/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml b/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml index 50f73109444..2899ba65339 100644 --- a/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml +++ b/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml @@ -141,6 +141,33 @@ tests: name: expected/grass7/v_vect_stats.shp type: vector + - algorithm: grass7:v.net + name: v.net (extract nodes) + params: + -c: false + -s: true + GRASS_MIN_AREA_PARAMETER: 0.0001 + GRASS_OUTPUT_TYPE_PARAMETER: 0 + GRASS_SNAP_TOLERANCE_PARAMETER: -1.0 + GRASS_VECTOR_DSCO: '' + GRASS_VECTOR_EXPORT_NOCAT: false + GRASS_VECTOR_LCO: '' + arc_type: + - 0 + - 1 + input: + name: roads.gml|layername=roads + type: vector + operation: 0 + threshold: 50.0 + results: + output: + name: expected/grass7/v_net_nodes.gml + type: vector + compare: + fields: + fid: skip + - algorithm: grass7:v.net.allpairs name: v.net.allpairs params: @@ -194,6 +221,41 @@ tests: name: expected/grass7/v_net_centrality.shp type: vector + - algorithm: grass7:v.net.distance + name: v.net.distance + params: + -g: false + -l: false + GRASS_MIN_AREA_PARAMETER: 0.0001 + GRASS_OUTPUT_TYPE_PARAMETER: 0 + GRASS_SNAP_TOLERANCE_PARAMETER: -1.0 + GRASS_VECTOR_DSCO: '' + GRASS_VECTOR_EXPORT_NOCAT: false + GRASS_VECTOR_LCO: '' + arc_type: + - 0 + - 1 + flayer: + name: custom/grass7/point_start.gml|layername=point_start + type: vector + from_cats: '' + from_where: '' + input: + name: roads.gml|layername=roads + type: vector + threshold: 50.0 + tlayer: + name: custom/grass7/point_end.gml|layername=point_end + type: vector + to_cats: '' + to_type: + - 0 + to_where: '' + results: + output: + name: expected/grass7/v_net_distance.shp + type: vector + - algorithm: grass7:v.net.salesman name: v.net.salesman params: @@ -218,6 +280,9 @@ tests: output: name: expected/grass7/v_net_salesman.shp type: vector + sequence: + name: expected/grass7/v_net_salesman_seq.csv + type: file - algorithm: grass7:v.net.steiner name: v.net.steiner