2016-02-10 20:47:19 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
r_null.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-10 20:47:19 +01:00
|
|
|
""" Verify if we have the right parameters """
|
2017-10-22 10:25:09 +02:00
|
|
|
if (alg.parameterAsString(parameters, 'setnull', context)
|
|
|
|
or alg.parameterAsString(parameters, 'null', context)):
|
2018-05-28 14:51:36 +10:00
|
|
|
return True, None
|
2016-02-10 20:47:19 +01:00
|
|
|
|
2018-05-28 14:51:36 +10:00
|
|
|
return False, alg.tr("You need to set at least 'setnull' or 'null' parameters for this algorithm!")
|
2016-02-10 20:47:19 +01:00
|
|
|
|
|
|
|
|
2018-04-08 09:25:27 +10:00
|
|
|
def processInputs(alg, parameters, context, feedback):
|
2016-02-10 20:47:19 +01:00
|
|
|
"""Prepare the GRASS import commands"""
|
2017-10-22 10:25:09 +02:00
|
|
|
if 'map' in alg.exportedLayers:
|
2016-02-10 20:47:19 +01:00
|
|
|
return
|
|
|
|
|
2017-12-27 10:19:51 +01:00
|
|
|
# We need to import without r.external
|
2017-10-22 10:25:09 +02:00
|
|
|
alg.loadRasterLayerFromParameter('map', parameters, context, False)
|
2019-04-02 16:20:08 +10:00
|
|
|
alg.postInputs(context)
|
2016-02-10 20:47:19 +01:00
|
|
|
|
|
|
|
|
2018-04-08 09:25:27 +10:00
|
|
|
def processCommand(alg, parameters, context, feedback):
|
2016-02-10 20:47:19 +01:00
|
|
|
# We temporary remove the output 'sequence'
|
2018-04-08 09:25:27 +10:00
|
|
|
alg.processCommand(parameters, context, feedback, True)
|
2016-02-10 20:47:19 +01:00
|
|
|
|
|
|
|
|
2018-04-08 09:25:27 +10:00
|
|
|
def processOutputs(alg, parameters, context, feedback):
|
2017-10-22 10:25:09 +02:00
|
|
|
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
|
2017-12-27 10:19:51 +01:00
|
|
|
grassName = alg.exportedLayers['map']
|
2017-10-22 10:25:09 +02:00
|
|
|
alg.exportRasterLayer(grassName, fileName, False)
|