Skip to content
Permalink
Browse files

[processing][grass] Fix v.net.* output types, add tests

Fixes #19186
  • Loading branch information
nyalldawson committed Jul 25, 2018
1 parent eca775f commit 28c4a6cf592714609f715e6e16f6b7a415fb6ae6
Showing with 127 additions and 5 deletions.
  1. +13 −5 python/plugins/processing/algs/grass7/ext/v_net.py
  2. +1 −0 python/plugins/processing/tests/testdata/custom/grass7/network.cpg
  3. BIN python/plugins/processing/tests/testdata/custom/grass7/network.dbf
  4. +1 −0 python/plugins/processing/tests/testdata/custom/grass7/network.prj
  5. +1 −0 python/plugins/processing/tests/testdata/custom/grass7/network.qpj
  6. BIN python/plugins/processing/tests/testdata/custom/grass7/network.shp
  7. BIN python/plugins/processing/tests/testdata/custom/grass7/network.shx
  8. +1 −0 python/plugins/processing/tests/testdata/custom/grass7/network_points.cpg
  9. BIN python/plugins/processing/tests/testdata/custom/grass7/network_points.dbf
  10. +1 −0 python/plugins/processing/tests/testdata/custom/grass7/network_points.prj
  11. +1 −0 python/plugins/processing/tests/testdata/custom/grass7/network_points.qpj
  12. BIN python/plugins/processing/tests/testdata/custom/grass7/network_points.shp
  13. BIN python/plugins/processing/tests/testdata/custom/grass7/network_points.shx
  14. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_allpairs.dbf
  15. +1 −0 python/plugins/processing/tests/testdata/expected/grass7/v_net_allpairs.prj
  16. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_allpairs.shp
  17. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_allpairs.shx
  18. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_centrality.dbf
  19. +1 −0 python/plugins/processing/tests/testdata/expected/grass7/v_net_centrality.prj
  20. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_centrality.shp
  21. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_centrality.shx
  22. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman.dbf
  23. +1 −0 python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman.prj
  24. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman.shp
  25. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman.shx
  26. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_steiner.dbf
  27. +1 −0 python/plugins/processing/tests/testdata/expected/grass7/v_net_steiner.prj
  28. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_steiner.shp
  29. BIN python/plugins/processing/tests/testdata/expected/grass7/v_net_steiner.shx
  30. +104 −0 python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml
@@ -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):
@@ -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.
@@ -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 28c4a6c

Please sign in to comment.
You can’t perform that action at this time.