2016-02-27 15:19:55 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
r_drain.py
|
|
|
|
----------
|
|
|
|
Date : February 2016
|
|
|
|
Copyright : (C) 2016 by Médéric Ribreux
|
|
|
|
Email : medspx at medspx dot fr
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Médéric Ribreux'
|
|
|
|
__date__ = 'February 2016'
|
|
|
|
__copyright__ = '(C) 2016, Médéric Ribreux'
|
|
|
|
|
|
|
|
|
2017-10-22 10:25:09 +02:00
|
|
|
def checkParameterValuesBeforeExecuting(alg, parameters, context):
|
2016-02-27 15:19:55 +01:00
|
|
|
""" Verify if we have the right parameters """
|
2017-12-27 10:19:51 +01:00
|
|
|
# start_coordinates and start_points are mutually exclusives
|
2017-10-22 10:25:09 +02:00
|
|
|
if (alg.parameterAsString(parameters, 'start_coordinates', context)
|
|
|
|
and alg.parameterAsVectorLayer(parameters, 'start_points', context)):
|
2018-05-28 14:51:36 +10:00
|
|
|
return False, alg.tr("You need to set either start coordinates OR a start points vector layer!")
|
2017-12-30 17:16:16 +01:00
|
|
|
|
2017-12-27 10:19:51 +01:00
|
|
|
# You need to set at least one parameter
|
|
|
|
if (not alg.parameterAsString(parameters, 'start_coordinates', context)
|
2017-12-30 17:16:16 +01:00
|
|
|
and not alg.parameterAsVectorLayer(parameters, 'start_points', context)):
|
2018-05-28 14:51:36 +10:00
|
|
|
return False, alg.tr("You need to set either start coordinates OR a start points vector layer!")
|
2016-02-27 15:19:55 +01:00
|
|
|
|
2017-10-22 10:25:09 +02:00
|
|
|
paramscore = [f for f in ['-c', '-a', '-n']
|
2019-04-16 08:30:00 +02:00
|
|
|
if alg.parameterAsBoolean(parameters, f, context)]
|
2016-02-27 15:19:55 +01:00
|
|
|
if len(paramscore) > 1:
|
2018-05-28 14:51:36 +10:00
|
|
|
return False, alg.tr("-c, -a, -n parameters are mutually exclusive!")
|
|
|
|
return True, None
|