55 lines
2.0 KiB
Python
Raw Normal View History

2016-03-12 18:08:09 +01:00
# -*- coding: utf-8 -*-
"""
***************************************************************************
v_rectify.py
------------
Date : March 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__ = 'March 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
2017-12-28 18:28:18 +01:00
import os
from processing.algs.grass7.Grass7Utils import Grass7Utils
2016-03-12 18:08:09 +01:00
2017-10-22 10:25:09 +02:00
def checkParameterValuesBeforeExecuting(alg, parameters, context):
2016-03-12 18:08:09 +01:00
""" Verify if we have the right parameters """
2017-10-22 10:25:09 +02:00
if (alg.parameterAsString(parameters, 'inline_points', context)
and alg.parameterAsString(parameters, 'points', context)):
2016-03-12 18:08:09 +01:00
return alg.tr("You need to set either an input control point file or inline control points!")
return None
2017-10-22 10:25:09 +02:00
def processCommand(alg, parameters, context):
2017-12-28 18:28:18 +01:00
# handle inline points
inlinePoints = alg.parameterAsString(parameters, 'inline_points', context)
if inlinePoints:
2016-03-12 18:08:09 +01:00
# Creates a temporary txt file
2017-12-28 18:28:18 +01:00
pointsName = getTempFilename()
2016-03-12 18:08:09 +01:00
# Inject rules into temporary txt file
2017-12-28 18:28:18 +01:00
with open(pointsName, "w") as tempPoints:
tempPoints.write(inlinePoints)
alg.removeParameter('inline_points')
parameters['points'] = tempPoints
2016-03-12 18:08:09 +01:00
2017-12-28 18:28:18 +01:00
alg.processCommand(parameters, context, True)