Skip to content
Browse files
Add CrsWidgetWrapper
  • Loading branch information
arnaud-morvan authored and volaya committed Oct 5, 2016
1 parent bb0938a commit 6158e9b3405090fa2e93e16a6248882ebf21778c
@@ -162,12 +162,16 @@ def getAsScriptCode(self):

class ParameterCrs(Parameter):

def __init__(self, name='', description='', default=None, optional=False):
default_metadata = {
'widget_wrapper': 'processing.gui.wrappers.CrsWidgetWrapper'

def __init__(self, name='', description='', default=None, optional=False, metadata={}):
'''The value is a string that uniquely identifies the
coordinate reference system. Typically it is the auth id of the CRS
(if the authority is EPSG) or proj4 string of the CRS (in case
of other authorities or user defined projections).'''
Parameter.__init__(self, name, description, default, optional)
Parameter.__init__(self, name, description, default, optional, metadata)

def setValue(self, value):
if value is None or value.strip() == '':
@@ -55,7 +55,6 @@
from processing.core.parameters import ParameterString
from processing.core.parameters import ParameterNumber
from processing.core.parameters import ParameterFile
from processing.core.parameters import ParameterCrs
from processing.core.parameters import ParameterPoint
from processing.core.parameters import ParameterGeometryPredicate

@@ -172,7 +171,7 @@ def setParamValue(self, param, wrapper, alg=None):
options = dataobjects.getVectorLayers([param.datatype], sorting=False)
return param.setValue([options[i] for i in widget.selectedoptions])
elif isinstance(param, (ParameterNumber, ParameterFile, ParameterCrs,
elif isinstance(param, (ParameterNumber, ParameterFile,
ParameterExtent, ParameterPoint)):
return param.setValue(widget.getValue())
elif isinstance(param, ParameterString):
@@ -39,14 +39,16 @@

class CrsSelectionPanel(BASE, WIDGET):

def __init__(self, default):
def __init__(self, default='EPSG:4326'):
super(CrsSelectionPanel, self).__init__(None)


self.btnSelect.clicked.connect(self.browseCRS) = QgsCoordinateReferenceSystem(default).authid()

# TODO: Default should be removed = default

def setAuthId(self, authid):
@@ -411,8 +411,6 @@ def getWidgetFromParameter(self, param):
item = ExtentSelectionPanel(self.parent, self.alg, param.default)
elif isinstance(param, ParameterPoint):
item = PointSelectionPanel(self.parent, param.default)
elif isinstance(param, ParameterCrs):
item = CrsSelectionPanel(param.default)
elif isinstance(param, ParameterString):
if param.multiline:
verticalLayout = QVBoxLayout()
@@ -28,11 +28,14 @@

from inspect import isclass

from qgis.core import QgsCoordinateReferenceSystem
from qgis.PyQt.QtWidgets import (

from processing.gui.CrsSelectionPanel import CrsSelectionPanel

DIALOG_STANDARD = 'standard'
DIALOG_BATCH = 'batch'
DIALOG_MODELER = 'modeler'
@@ -115,3 +118,19 @@ def value(self):

if self.dialog in (DIALOG_BATCH, DIALOG_MODELER):
return self.widget.itemData(self.widget.currentIndex())

class CrsWidgetWrapper(WidgetWrapper):

def createWidget(self, extra_values=[]):
return CrsSelectionPanel()

def setValue(self, value):
if isinstance(value, basestring): # authId = value
else: = QgsCoordinateReferenceSystem(value).authid()

def value(self):
return self.widget.getValue()

0 comments on commit 6158e9b

Please sign in to comment.