Skip to content

Commit 960f3a9

Browse files
author
Médéric RIBREUX
committed
Fix r.drain algorithm (fixes Redmine #13003)
1 parent 36da688 commit 960f3a9

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

python/plugins/processing/algs/grass7/description/r.drain.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ r.drain
22
Traces a flow through an elevation model on a raster map.
33
Raster (r.*)
44
ParameterRaster|input|Elevation|False
5-
ParameterString|start_coordinates|Map coordinates of starting point(s) (E,N)|(0,0)
6-
ParameterMultipleInput|start_points|Vector layer(s) containing starting point(s)|0|True
5+
ParameterRaster|direction|Name of input movement direction map associated with the cost surface|True
6+
ParameterString|start_coordinates|Map coordinates of starting point(s) (E,N)|0.0,0.0|False|True
7+
ParameterVector|start_points|Vector layer containing starting point(s)|0|True
78
ParameterBoolean|-c|Copy input cell values on output|False
89
ParameterBoolean|-a|Accumulate input values along the path|False
910
ParameterBoolean|-n|Count cell numbers along the path|False
11+
ParameterBoolean|-d|The input raster map is a cost surface (direction surface must also be specified)|False
1012
OutputRaster|output|Least cost path
13+
OutputVector|drain|Drain
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
r_drain.py
6+
----------
7+
Date : February 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'February 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import os
29+
30+
31+
def checkParameterValuesBeforeExecuting(alg):
32+
""" Verify if we have the right parameters """
33+
if alg.getParameterValue('start_coordinates') and alg.getParameterValue('start_points'):
34+
return alg.tr("You need to set either start coordinates OR a start points vector layer !")
35+
36+
parameters = [alg.getParameterValue(f) for f in ['-c', '-a', '-n']]
37+
paramscore = [f for f in parameters if f]
38+
if len(paramscore) > 1:
39+
return alg.tr("-c, -a, -n parameters are mutually exclusive !")
40+
return None

0 commit comments

Comments
 (0)