Skip to content

Commit 7613141

Browse files
author
Piotr Pociask
committed
[processing] Add crs selection panel to scripts
1 parent 7985c4e commit 7613141

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

python/plugins/processing/gui/CrsSelectionPanel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
from PyQt4 import QtGui, QtCore
2929
from processing.gui.CrsSelectionDialog import CrsSelectionDialog
30-
30+
from qgis.core import QgsCoordinateReferenceSystem
3131

3232
class CrsSelectionPanel(QtGui.QWidget):
3333

3434
def __init__(self, default):
3535
super(CrsSelectionPanel, self).__init__(None)
36-
self.authid = default
36+
self.authid = QgsCoordinateReferenceSystem(default).authid()
3737
self.horizontalLayout = QtGui.QHBoxLayout(self)
3838
self.horizontalLayout.setSpacing(2)
3939
self.horizontalLayout.setMargin(0)

python/plugins/processing/script/ScriptAlgorithm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from processing.parameters.ParameterVector import ParameterVector
3636
from processing.parameters.ParameterMultipleInput import ParameterMultipleInput
3737
from processing.parameters.ParameterString import ParameterString
38+
from processing.parameters.ParameterCrs import ParameterCrs
3839
from processing.parameters.ParameterNumber import ParameterNumber
3940
from processing.parameters.ParameterBoolean import ParameterBoolean
4041
from processing.parameters.ParameterSelection import ParameterSelection
@@ -128,7 +129,7 @@ def processParameterLine(self, line):
128129
if '|' in line:
129130
self.processDescriptionParameterLine(line)
130131
return
131-
tokens = line.split('=')
132+
tokens = line.split('=', 1)
132133
desc = self.createDescriptiveName(tokens[0])
133134
if tokens[1].lower().strip() == 'group':
134135
self.group = tokens[0]
@@ -178,6 +179,11 @@ def processParameterLine(self, line):
178179
elif tokens[1].lower().strip().startswith('string'):
179180
default = tokens[1].strip()[len('string') + 1:]
180181
param = ParameterString(tokens[0], desc, default)
182+
elif tokens[1].lower().strip().startswith('crs'):
183+
default = tokens[1].strip()[len('crs') + 1:]
184+
if not default:
185+
default = 'EPSG:4326'
186+
param = ParameterCrs(tokens[0], desc, default)
181187
elif tokens[1].lower().strip().startswith('output raster'):
182188
out = OutputRaster()
183189
elif tokens[1].lower().strip().startswith('output vector'):

0 commit comments

Comments
 (0)