From 3abea3600024c4d329403e7462a47af4db503339 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 31 Jan 2019 12:50:09 +0200 Subject: [PATCH 1/5] [processing] snap points to network by default (fix #19904) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kudos to Pedro VenĂ¢ncio for finding solution for this bug --- python/plugins/processing/algs/grass7/ext/v_net.py | 4 ++-- .../processing/algs/grass7/ext/v_net_connectivity.py | 6 +++--- .../plugins/processing/algs/grass7/ext/v_net_distance.py | 8 ++++---- python/plugins/processing/algs/grass7/ext/v_net_flow.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/plugins/processing/algs/grass7/ext/v_net.py b/python/plugins/processing/algs/grass7/ext/v_net.py index e84357a491a5..d2f9acdbd8c0 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 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 5a393a25de12..0e5d04d9da97 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 @@ 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 babe573ff1f8..0fd15b8f33c8 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 682f77484b12..110cffd390e7 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 @@ 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): From dbe2cb73ad7352ae58ab465761d2feeec59ab554 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 31 Jan 2019 12:51:42 +0200 Subject: [PATCH 2/5] [processing] add test for v.net.distance algorithm --- .../testdata/custom/grass7/point_end.gml | 19 ++++++++++ .../testdata/custom/grass7/point_end.xsd | 23 ++++++++++++ .../testdata/custom/grass7/point_start.gml | 19 ++++++++++ .../testdata/custom/grass7/point_start.xsd | 23 ++++++++++++ .../expected/grass7/v_net_distance.dbf | Bin 0 -> 259 bytes .../expected/grass7/v_net_distance.prj | 1 + .../expected/grass7/v_net_distance.shp | Bin 0 -> 1036 bytes .../expected/grass7/v_net_distance.shx | Bin 0 -> 124 bytes .../grass7_algorithms_vector_tests.yaml | 35 ++++++++++++++++++ 9 files changed, 120 insertions(+) create mode 100644 python/plugins/processing/tests/testdata/custom/grass7/point_end.gml create mode 100644 python/plugins/processing/tests/testdata/custom/grass7/point_end.xsd create mode 100644 python/plugins/processing/tests/testdata/custom/grass7/point_start.gml create mode 100644 python/plugins/processing/tests/testdata/custom/grass7/point_start.xsd create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.dbf create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.prj create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.shp create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.shx 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 000000000000..9660b9ebe66f --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/grass7/point_end.gml @@ -0,0 +1,19 @@ + + + + + 1003696.6480203046222370.049363472 + 1003696.6480203046222370.049363472 + + + + + + 1003696.6480203,6222370.04936347 + + + diff --git a/python/plugins/processing/tests/testdata/custom/grass7/point_end.xsd b/python/plugins/processing/tests/testdata/custom/grass7/point_end.xsd new file mode 100644 index 000000000000..15c755d436c1 --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/grass7/point_end.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/plugins/processing/tests/testdata/custom/grass7/point_start.gml b/python/plugins/processing/tests/testdata/custom/grass7/point_start.gml new file mode 100644 index 000000000000..58d2261fe840 --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/grass7/point_start.gml @@ -0,0 +1,19 @@ + + + + + 1000993.6094793886220361.983185438 + 1000993.6094793886220361.983185438 + + + + + + 1000993.60947939,6220361.98318544 + + + diff --git a/python/plugins/processing/tests/testdata/custom/grass7/point_start.xsd b/python/plugins/processing/tests/testdata/custom/grass7/point_start.xsd new file mode 100644 index 000000000000..2a58108e024a --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/grass7/point_start.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.dbf b/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.dbf new file mode 100644 index 0000000000000000000000000000000000000000..c26ba7220a74a9a0493682b73e7e7441a4665aad GIT binary patch literal 259 zcmZQBXOw4VU|?uu&<2udAe@0AIk5yL=m%nO!gx@+1fc+{d`f09%mA>w1V5?)yb3U2 ah{7;7vozE*w=^|?19M}T0tKonl>z_+{2W;T literal 0 HcmV?d00001 diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.prj b/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.prj new file mode 100644 index 000000000000..55aa2f4a4f72 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.prj @@ -0,0 +1 @@ +PROJCS["WGS_1984_UTM_Zone_33S",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",15],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]] \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.shp b/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.shp new file mode 100644 index 0000000000000000000000000000000000000000..b05db7e7c27d018cc2c99bbe4126b0e4cea10529 GIT binary patch literal 1036 zcmZwGc}P@290%~HxrSo>VW2^%l}ByXXj*NOV3R4WVu%@nrt5*BWgaCOW=o2iXRdA@ ztE;P-*LvlVw<(plrI|sbiEKuOc~D82g>LkH&=M^UZytOezxlmk_zuJD(`Pmv+Pa^% zFbp0>kgxLh%_g+v?AT0puMdrrHD33uBvdS4%I@v=p_?xM|DzVeXq{wxb#Ow2Ryl;) zX0EPD&?~edjB}-&P}RJDXBT>*kg@!`Rw=> ztgPYahaO16Uhg4YFA^AE9*D5VY7HlBTn{X8qs_U8FUj~Kz4RaZXU-0;zO4uqb<4a&6p)^8= zw+wriH-z`YZq5McD%8uJz6*25#qas>(wMKI z1a{Qza=8h+3~eZ6utmb7_;t84`8KZ^-sw4QZjCHS3m*Hl!f6ZEyuq^}Gm-?R$qi#WI*n{R>Vf*S~vO`^~&i<^pC+o26-@U3jwtCtFHViC} z=|Qj9$cuBC@MoK-wNChg^M~F&6*#}5p_F=9znfd(3J3j=DDJ}p3oG(!SSpUTX3wvP TY#;g!2l!>hieUBL)O-B{ROO}O literal 0 HcmV?d00001 diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.shx b/python/plugins/processing/tests/testdata/expected/grass7/v_net_distance.shx new file mode 100644 index 0000000000000000000000000000000000000000..b83833629565df9ad9620bae91eec9225e53983b GIT binary patch literal 124 zcmZQzQ0HR64(whqGcW)VL;R$_u~9vGj_du--09gB?pQW|O+~;$J;%wbUia+U6Yhvz XJBp|g0|TQ25SIZ(HGuRYAe{gJMaL8I literal 0 HcmV?d00001 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 50f73109444a..f3d178b2de71 100644 --- a/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml +++ b/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml @@ -194,6 +194,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: From a911ef336703056833133104fae6c7d09c889fed Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 31 Jan 2019 13:15:53 +0200 Subject: [PATCH 3/5] [processing] fix output generation in v.net and add test --- .../processing/algs/grass7/ext/v_net.py | 2 +- .../testdata/expected/grass7/v_net_nodes.gml | 824 ++++++++++++++++++ .../testdata/expected/grass7/v_net_nodes.xsd | 30 + .../grass7_algorithms_vector_tests.yaml | 27 + 4 files changed, 882 insertions(+), 1 deletion(-) create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.gml create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.xsd diff --git a/python/plugins/processing/algs/grass7/ext/v_net.py b/python/plugins/processing/algs/grass7/ext/v_net.py index d2f9acdbd8c0..87e84f7dabbd 100644 --- a/python/plugins/processing/algs/grass7/ext/v_net.py +++ b/python/plugins/processing/algs/grass7/ext/v_net.py @@ -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/tests/testdata/expected/grass7/v_net_nodes.gml b/python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.gml new file mode 100644 index 000000000000..0fe91aada921 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.gml @@ -0,0 +1,824 @@ + + + + + 1000449.940005246219385.3239352 + 1005036.209880136223332.12607736 + + + + + + 1003358.61234295,6222589.37828666 + + + + + 1003316.81265982,6222641.75340997 + + + + + 1003258.54390028,6221499.10871054 + + + + + 1005036.20988013,6221731.80733868 + + + + + 1003464.29159962,6222752.89626958 + + + + + 1003343.52194629,6223093.50140971 + + + + + 1003318.51056419,6222558.84948158 + + + + + 1004871.15965709,6221745.31232436 + + + + + 1003455.22813233,6222681.09220546 + + + + + 1003330.95107314,6222272.98904849 + + + + + 1003486.67143748,6222451.21158441 + + + + + 1003430.63468333,6222565.77529146 + + + + + 1003403.86741564,6222623.83109929 + + + + + 1003419.72556936,6222882.40752935 + + + + + 1003622.33659825,6223084.31361034 + + + + + 1003394.25380049,6222340.63979273 + + + + + 1003483.81137232,6222286.60579404 + + + + + 1003602.8338769,6222436.67874613 + + + + + 1003406.90500878,6222189.64158806 + + + + + 1003472.3070191,6222272.11630568 + + + + + 1003596.67006395,6222145.79506248 + + + + + 1004026.21371718,6222810.84939244 + + + + + 1003555.31281829,6222483.13439712 + + + + + 1003647.3751082,6222401.82100567 + + + + + 1004309.66836652,6223110.81957785 + + + + + 1003745.10253898,6222507.54062578 + + + + + 1003696.4437017,6222455.04866221 + + + + + 1003757.91175857,6222706.23385019 + + + + + 1004238.24340688,6222841.62187878 + + + + + 1000878.43619407,6220274.3466856 + + + + + 1001107.24684923,6220391.87436156 + + + + + 1003946.78684547,6221880.1876508 + + + + + 1003775.57324976,6221922.76175725 + + + + + 1003839.54015074,6221908.19492644 + + + + + 1003899.60754345,6222127.01927093 + + + + + 1004068.76574521,6221926.1865048 + + + + + 1004027.57619058,6223045.89797913 + + + + + 1004221.1764584,6222860.18860723 + + + + + 1004183.22985918,6223218.06859791 + + + + + 1004095.65145913,6222747.01371625 + + + + + 1004004.3393274,6221865.17156268 + + + + + 1004262.6510124,6222874.49012428 + + + + + 1004607.78605797,6222785.56155322 + + + + + 1004514.71642941,6222887.03268779 + + + + + 1004483.74106128,6222915.39938982 + + + + + 1004303.04278025,6222920.76116234 + + + + + 1000449.94000524,6221904.71299594 + + + + + 1000536.94525949,6221839.34996813 + + + + + 1004434.39438966,6222767.42295813 + + + + + 1004407.02479507,6222765.5560396 + + + + + 1001569.5898177,6219744.44405902 + + + + + 1004422.27096645,6222832.11774671 + + + + + 1000652.71818791,6221724.76658426 + + + + + 1001759.17374285,6221773.37174766 + + + + + 1004432.28759553,6222778.67414255 + + + + + 1004605.87055219,6222776.97593719 + + + + + 1004536.28512556,6222699.78745955 + + + + + 1004521.75215942,6222657.84841466 + + + + + 1001432.03116544,6219385.3239352 + + + + + 1001269.49594123,6219583.71888825 + + + + + 1001446.00944971,6219890.54669478 + + + + + 1004829.43363135,6221623.00505714 + + + + + 1001275.12302677,6220409.28905948 + + + + + 1001186.34740161,6220459.66433954 + + + + + 1002622.66996036,6221162.46807726 + + + + + 1001634.27652788,6222113.58823657 + + + + + 1001928.96666296,6221701.18298049 + + + + + 1001805.23131167,6222239.15236114 + + + + + 1001806.08518826,6221307.13224234 + + + + + 1001636.8470959,6221432.84194866 + + + + + 1002161.08326842,6222058.23120113 + + + + + 1001730.88604383,6221182.3451556 + + + + + 1001889.36730125,6221047.16999001 + + + + + 1001891.40736133,6221430.94581986 + + + + + 1001757.033926,6221599.13099375 + + + + + 1002509.88988421,6222183.56835463 + + + + + 1002076.31366647,6221866.90361533 + + + + + 1001768.66918412,6220985.87533486 + + + + + 1001830.07379777,6221096.98362917 + + + + + 1001821.61736105,6221332.90322892 + + + + + 1001993.49068512,6221197.19198907 + + + + + 1002448.62305961,6222244.85108956 + + + + + 1002561.47727287,6223332.12607736 + + + + + 1001930.78353526,6221467.36521594 + + + + + 1002211.65419834,6221232.83267062 + + + + + 1002143.60477597,6222604.9501648 + + + + + 1002302.00075381,6222733.86070695 + + + + + 1002233.59814873,6221951.11952203 + + + + + 1002129.95849754,6222135.73878474 + + + + + 1002103.66905047,6221324.68154126 + + + + + 1002275.1898604,6221455.19588041 + + + + + 1002416.57059498,6221277.56159465 + + + + + 1002137.81278244,6221630.62018051 + + + + + 1002226.82368085,6221517.62843522 + + + + + 1002302.22841804,6221576.64258306 + + + + + 1002299.19357268,6222416.40706398 + + + + + 1002392.19979847,6222497.20609339 + + + + + 1002532.83636772,6221785.38136521 + + + + + 1002310.58466849,6221563.42200322 + + + + + 1002526.28363451,6221554.70249994 + + + + + 1002334.20638747,6221779.49098284 + + + + + 1002380.76911747,6222089.85859496 + + + + + 1002518.06990805,6221915.34875741 + + + + + 1002657.33259138,6222018.20620536 + + + + + 1002462.62346654,6221875.38780442 + + + + + 1002557.08337327,6223317.2011125 + + + + + 1002621.6858386,6222058.82241101 + + + + + 1002485.75145034,6221954.55074419 + + + + + 1002991.11072264,6222281.72914386 + + + + + 1002527.19655281,6222727.93691723 + + + + + 1002761.33635685,6222354.19324527 + + + + + 1002865.83898131,6222432.39284309 + + + + + 1002529.45107897,6222163.92536965 + + + + + 1002897.87933631,6221326.06027793 + + + + + 1002643.23398503,6221648.43442531 + + + + + 1002755.78126323,6222555.17746296 + + + + + 1002634.10286657,6222452.63050891 + + + + + 1002624.53430232,6222242.61769963 + + + + + 1002684.54187821,6222169.9061412 + + + + + 1003285.47179071,6222319.99149044 + + + + + 1002623.85396603,6221672.14481097 + + + + + 1003028.1814962,6221611.96830289 + + + + + 1003474.59453034,6222127.67457486 + + + + + 1002724.17727046,6222326.95840711 + + + + + 1002852.18578258,6222162.74032983 + + + + + 1002673.19045469,6221156.70050092 + + + + + 1002667.16458207,6221195.87188063 + + + + + 1002849.71919563,6222453.61290053 + + + + + 1002800.86644403,6222632.43477635 + + + + + 1002916.58033846,6222216.16749784 + + + + + 1002788.09666598,6222371.6460413 + + + + + 1002829.37711292,6222541.77590985 + + + + + 1002950.16219022,6222560.53103646 + + + + + 1002852.81680714,6222794.09896218 + + + + + 1002852.54413666,6222449.88692926 + + + + + 1002826.28134969,6221250.49654194 + + + + + 1002940.07923321,6221296.24215208 + + + + + 1002897.32222975,6222395.42838888 + + + + + 1003006.76410522,6222480.99306342 + + + + + 1002943.55552255,6222884.39323789 + + + + + 1003031.23572156,6222655.69469469 + + + + + 1003040.80096358,6222322.18412711 + + + + + 1002933.41223807,6222423.64415742 + + + + + 1003105.74257399,6222376.7841218 + + + + + 1003076.97655481,6222712.84504498 + + + + + 1003037.55521283,6222118.73863535 + + + + + 1002945.17950103,6222241.31856099 + + + + + 1002988.8334088,6222500.42759959 + + + + + 1003167.69350563,6222645.15329211 + + + + + 1003061.43114207,6222909.55139377 + + + + + 1003301.11150351,6222971.91730526 + + + + + 1003081.58397817,6222808.97867277 + + + + + 1003127.98884889,6222810.39105837 + + + + + 1003091.12635878,6221546.30265638 + + + + + 1003153.88971381,6222419.41498029 + + + + + 1003245.57883139,6222564.71225246 + + + + + 1003279.03907841,6222743.52344535 + + + + + 1003745.40906699,6222317.55884368 + + + + + 1003261.7338751,6222520.86764589 + + + + + 1004013.82617712,6221863.07174067 + + + + + 1003172.94058079,6222436.28679202 + + + + + 1003307.4740849,6222730.08836253 + + + diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.xsd b/python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.xsd new file mode 100644 index 000000000000..c99c2cd21b96 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/grass7/v_net_nodes.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 f3d178b2de71..c201b67217e1 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: From b9f559ee0430e09d8e1a3b70e060155635080262 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 31 Jan 2019 15:52:43 +0200 Subject: [PATCH 4/5] [processing] fix broken stdout handling in GRASS algs (fix #21142) --- .../plugins/processing/algs/grass7/Grass7Algorithm.py | 10 ++++------ .../algs/grass7/description/v.net.salesman.txt | 2 +- .../testdata/expected/grass7/v_net_salesman_seq.csv | 4 ++++ .../tests/testdata/grass7_algorithms_vector_tests.yaml | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_salesman_seq.csv diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py index 1e619eb4dd2b..5b064b238e4b 100644 --- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py +++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py @@ -631,15 +631,13 @@ def processCommand(self, parameters, context, feedback, delOutputs=False): 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.salesman.txt b/python/plugins/processing/algs/grass7/description/v.net.salesman.txt index cb423c7b40bc..cf044a606e9b 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/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 000000000000..814f790d6bfe --- /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 c201b67217e1..2899ba65339d 100644 --- a/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml +++ b/python/plugins/processing/tests/testdata/grass7_algorithms_vector_tests.yaml @@ -280,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 From 85e3b2db6e29fccec2eee264f84e0357a5f24d47 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Thu, 31 Jan 2019 16:31:35 +0200 Subject: [PATCH 5/5] [processing] fix v.net.report and v.net.nreport --- .../algs/grass7/description/v.net.nreport.txt | 2 +- .../algs/grass7/description/v.net.report.txt | 2 +- .../expected/grass7/v_net_nreport.html | 0 .../expected/grass7/v_net_report.html | 27 +++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_nreport.html create mode 100644 python/plugins/processing/tests/testdata/expected/grass7/v_net_report.html 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 11aa8eed5f2c..d45a4923ec1a 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 56ef1a72f211..de790ff7d0ad 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/tests/testdata/expected/grass7/v_net_nreport.html b/python/plugins/processing/tests/testdata/expected/grass7/v_net_nreport.html new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/python/plugins/processing/tests/testdata/expected/grass7/v_net_report.html b/python/plugins/processing/tests/testdata/expected/grass7/v_net_report.html new file mode 100644 index 000000000000..fb34f1dfd39a --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/grass7/v_net_report.html @@ -0,0 +1,27 @@ +

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