Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing][grass] Fix v.net.* output types, add tests
Fixes #19186

(cherry-picked from 28c4a6c)
  • Loading branch information
nyalldawson committed Jul 25, 2018
1 parent ce689e7 commit a101562
Show file tree
Hide file tree
Showing 30 changed files with 127 additions and 5 deletions.
18 changes: 13 additions & 5 deletions python/plugins/processing/algs/grass7/ext/v_net.py
Expand Up @@ -100,11 +100,19 @@ def variableOutput(alg, layers, parameters, context, nocats=True):
if not isinstance(typeList, list):
continue

fileName = alg.parameterAsOutputLayer(parameters, outputName, context)
grassName = '{}{}'.format(typeList[0], alg.uniqueSuffix)
alg.exportVectorLayer(
grassName, fileName, typeList[1], typeList[2],
typeList[3])
file_name = alg.parameterAsOutputLayer(parameters, outputName, context)

src_layer = typeList[0]
output_type = typeList[1]
output_layer_number = typeList[2]
no_cats = typeList[3]

grass_name = '{}{}'.format(src_layer, alg.uniqueSuffix)
alg.exportVectorLayer(grassName=grass_name,
fileName=file_name,
layer=output_layer_number,
nocats=no_cats,
dataType=output_type)


def processOutputs(alg, parameters, context, feedback):
Expand Down
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
@@ -0,0 +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]]
@@ -0,0 +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.
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
@@ -0,0 +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]]
@@ -0,0 +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.
@@ -0,0 +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.
@@ -0,0 +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.
@@ -0,0 +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.
@@ -0,0 +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.
Expand Up @@ -139,3 +139,107 @@ tests:
output:
name: expected/grass7/v_vect_stats.shp
type: vector

- algorithm: grass7:v.net.allpairs
name: v.net.allpairs
params:
-g: false
GRASS_MIN_AREA_PARAMETER: 0.0001
GRASS_OUTPUT_TYPE_PARAMETER: 0
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
GRASS_VECTOR_DSCO: ''
GRASS_VECTOR_LCO: ''
cats: 1-10000
input:
name: custom/grass7/network.shp
type: vector
points:
name: custom/grass7/network_points.shp
type: vector
threshold: 50.0
where: ''
results:
output:
name: expected/grass7/v_net_allpairs.shp
type: vector

- algorithm: grass7:v.net.centrality
name: v.net.centrality
params:
-a: true
-g: false
GRASS_MIN_AREA_PARAMETER: 0.0001
GRASS_OUTPUT_TYPE_PARAMETER: 0
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
GRASS_VECTOR_DSCO: ''
GRASS_VECTOR_LCO: ''
betweenness: ''
cats: ''
closeness: closeness
degree: degree
eigenvector: ''
error: 0.1
input:
name: custom/grass7/network.shp
type: vector
iterations: 1000
points:
name: custom/grass7/network_points.shp
type: vector
threshold: 50.0
where: ''
results:
output:
name: expected/grass7/v_net_centrality.shp
type: vector

- algorithm: grass7:v.net.salesman
name: v.net.salesman
params:
-g: false
GRASS_MIN_AREA_PARAMETER: 0.0001
GRASS_OUTPUT_TYPE_PARAMETER: 0
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
GRASS_VECTOR_DSCO: ''
GRASS_VECTOR_LCO: ''
arc_type:
- 0
- 1
center_cats: 1-100000
input:
name: custom/grass7/network.shp
type: vector
points:
name: custom/grass7/network_points.shp
type: vector
threshold: 50.0
results:
output:
name: expected/grass7/v_net_salesman.shp
type: vector

- algorithm: grass7:v.net.steiner
name: v.net.steiner
params:
-g: false
GRASS_MIN_AREA_PARAMETER: 0.0001
GRASS_OUTPUT_TYPE_PARAMETER: 0
GRASS_SNAP_TOLERANCE_PARAMETER: -1.0
GRASS_VECTOR_DSCO: ''
GRASS_VECTOR_LCO: ''
arc_type:
- 0
- 1
input:
name: custom/grass7/network.shp
type: vector
npoints: -1
points:
name: custom/grass7/network_points.shp
type: vector
terminal_cats: 1-100000
threshold: 50.0
results:
output:
name: expected/grass7/v_net_steiner.shp
type: vector

0 comments on commit a101562

Please sign in to comment.