From 761314197cbab7999c28100670a998e23b0d311b Mon Sep 17 00:00:00 2001 From: Piotr Pociask Date: Wed, 6 Nov 2013 17:52:43 +0100 Subject: [PATCH] [processing] Add crs selection panel to scripts --- python/plugins/processing/gui/CrsSelectionPanel.py | 4 ++-- python/plugins/processing/script/ScriptAlgorithm.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/python/plugins/processing/gui/CrsSelectionPanel.py b/python/plugins/processing/gui/CrsSelectionPanel.py index 86db96e2041d..13b27badbf92 100644 --- a/python/plugins/processing/gui/CrsSelectionPanel.py +++ b/python/plugins/processing/gui/CrsSelectionPanel.py @@ -27,13 +27,13 @@ from PyQt4 import QtGui, QtCore from processing.gui.CrsSelectionDialog import CrsSelectionDialog - +from qgis.core import QgsCoordinateReferenceSystem class CrsSelectionPanel(QtGui.QWidget): def __init__(self, default): super(CrsSelectionPanel, self).__init__(None) - self.authid = default + self.authid = QgsCoordinateReferenceSystem(default).authid() self.horizontalLayout = QtGui.QHBoxLayout(self) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setMargin(0) diff --git a/python/plugins/processing/script/ScriptAlgorithm.py b/python/plugins/processing/script/ScriptAlgorithm.py index f6237afb8b3a..6676b4d0667f 100644 --- a/python/plugins/processing/script/ScriptAlgorithm.py +++ b/python/plugins/processing/script/ScriptAlgorithm.py @@ -35,6 +35,7 @@ from processing.parameters.ParameterVector import ParameterVector from processing.parameters.ParameterMultipleInput import ParameterMultipleInput from processing.parameters.ParameterString import ParameterString +from processing.parameters.ParameterCrs import ParameterCrs from processing.parameters.ParameterNumber import ParameterNumber from processing.parameters.ParameterBoolean import ParameterBoolean from processing.parameters.ParameterSelection import ParameterSelection @@ -128,7 +129,7 @@ def processParameterLine(self, line): if '|' in line: self.processDescriptionParameterLine(line) return - tokens = line.split('=') + tokens = line.split('=', 1) desc = self.createDescriptiveName(tokens[0]) if tokens[1].lower().strip() == 'group': self.group = tokens[0] @@ -178,6 +179,11 @@ def processParameterLine(self, line): elif tokens[1].lower().strip().startswith('string'): default = tokens[1].strip()[len('string') + 1:] param = ParameterString(tokens[0], desc, default) + elif tokens[1].lower().strip().startswith('crs'): + default = tokens[1].strip()[len('crs') + 1:] + if not default: + default = 'EPSG:4326' + param = ParameterCrs(tokens[0], desc, default) elif tokens[1].lower().strip().startswith('output raster'): out = OutputRaster() elif tokens[1].lower().strip().startswith('output vector'):