Skip to content

Commit 28c4a6c

Browse files
committedJul 25, 2018
[processing][grass] Fix v.net.* output types, add tests
Fixes #19186
1 parent eca775f commit 28c4a6c

30 files changed

+127
-5
lines changed
 

‎python/plugins/processing/algs/grass7/ext/v_net.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,19 @@ def variableOutput(alg, layers, parameters, context, nocats=True):
100100
if not isinstance(typeList, list):
101101
continue
102102

103-
fileName = alg.parameterAsOutputLayer(parameters, outputName, context)
104-
grassName = '{}{}'.format(typeList[0], alg.uniqueSuffix)
105-
alg.exportVectorLayer(
106-
grassName, fileName, typeList[1], typeList[2],
107-
typeList[3])
103+
file_name = alg.parameterAsOutputLayer(parameters, outputName, context)
104+
105+
src_layer = typeList[0]
106+
output_type = typeList[1]
107+
output_layer_number = typeList[2]
108+
no_cats = typeList[3]
109+
110+
grass_name = '{}{}'.format(src_layer, alg.uniqueSuffix)
111+
alg.exportVectorLayer(grassName=grass_name,
112+
fileName=file_name,
113+
layer=output_layer_number,
114+
nocats=no_cats,
115+
dataType=output_type)
108116

109117

110118
def processOutputs(alg, parameters, context, feedback):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UTF-8
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS_1984_UTM_Zone_35S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS 84 / UTM zone 35S",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32735"]]
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UTF-8
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS_1984_UTM_Zone_35S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS 84 / UTM zone 35S",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32735"]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS_1984_UTM_Zone_35S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS_1984_UTM_Zone_35S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS_1984_UTM_Zone_35S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJCS["WGS_1984_UTM_Zone_35S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",27],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
Binary file not shown.
Binary file not shown.

‎python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,107 @@ tests:
139139
output:
140140
name: expected/grass7/v_vect_stats.shp
141141
type: vector
142+
143+
- algorithm: grass7:v.net.allpairs
144+
name: v.net.allpairs
145+
params:
146+
-g: false
147+
GRASS_MIN_AREA_PARAMETER: 0.0001
148+
GRASS_OUTPUT_TYPE_PARAMETER: 0
149+
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
150+
GRASS_VECTOR_DSCO: ''
151+
GRASS_VECTOR_LCO: ''
152+
cats: 1-10000
153+
input:
154+
name: custom/grass7/network.shp
155+
type: vector
156+
points:
157+
name: custom/grass7/network_points.shp
158+
type: vector
159+
threshold: 50.0
160+
where: ''
161+
results:
162+
output:
163+
name: expected/grass7/v_net_allpairs.shp
164+
type: vector
165+
166+
- algorithm: grass7:v.net.centrality
167+
name: v.net.centrality
168+
params:
169+
-a: true
170+
-g: false
171+
GRASS_MIN_AREA_PARAMETER: 0.0001
172+
GRASS_OUTPUT_TYPE_PARAMETER: 0
173+
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
174+
GRASS_VECTOR_DSCO: ''
175+
GRASS_VECTOR_LCO: ''
176+
betweenness: ''
177+
cats: ''
178+
closeness: closeness
179+
degree: degree
180+
eigenvector: ''
181+
error: 0.1
182+
input:
183+
name: custom/grass7/network.shp
184+
type: vector
185+
iterations: 1000
186+
points:
187+
name: custom/grass7/network_points.shp
188+
type: vector
189+
threshold: 50.0
190+
where: ''
191+
results:
192+
output:
193+
name: expected/grass7/v_net_centrality.shp
194+
type: vector
195+
196+
- algorithm: grass7:v.net.salesman
197+
name: v.net.salesman
198+
params:
199+
-g: false
200+
GRASS_MIN_AREA_PARAMETER: 0.0001
201+
GRASS_OUTPUT_TYPE_PARAMETER: 0
202+
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
203+
GRASS_VECTOR_DSCO: ''
204+
GRASS_VECTOR_LCO: ''
205+
arc_type:
206+
- 0
207+
- 1
208+
center_cats: 1-100000
209+
input:
210+
name: custom/grass7/network.shp
211+
type: vector
212+
points:
213+
name: custom/grass7/network_points.shp
214+
type: vector
215+
threshold: 50.0
216+
results:
217+
output:
218+
name: expected/grass7/v_net_salesman.shp
219+
type: vector
220+
221+
- algorithm: grass7:v.net.steiner
222+
name: v.net.steiner
223+
params:
224+
-g: false
225+
GRASS_MIN_AREA_PARAMETER: 0.0001
226+
GRASS_OUTPUT_TYPE_PARAMETER: 0
227+
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
228+
GRASS_VECTOR_DSCO: ''
229+
GRASS_VECTOR_LCO: ''
230+
arc_type:
231+
- 0
232+
- 1
233+
input:
234+
name: custom/grass7/network.shp
235+
type: vector
236+
npoints: -1
237+
points:
238+
name: custom/grass7/network_points.shp
239+
type: vector
240+
terminal_cats: 1-100000
241+
threshold: 50.0
242+
results:
243+
output:
244+
name: expected/grass7/v_net_steiner.shp
245+
type: vector

0 commit comments

Comments
 (0)
Please sign in to comment.