Skip to content
Permalink
Browse files
Merge pull request #1852 from radosuav/changes
[Processing] Small fixes and additions
  • Loading branch information
volaya committed Jan 26, 2015
2 parents 609db7d + b835f40 commit 098aa681f05cb42db4c1c483917f11236c7b55a0
@@ -79,7 +79,6 @@ def processAlgorithm(self, progress):
arguments.append(str(self.getParameterValue(self.SOURCE_SRS)))
arguments.append('-t_srs')
crsId = self.getParameterValue(self.DEST_SRS)
self.crs = QgsCoordinateReferenceSystem(crsId)
arguments.append(str(crsId))
arguments.append('-r')
arguments.append(
@@ -57,7 +57,8 @@ def processAlgorithm(self, progress):
self.getParameterValue(self.YFIELD))

crsId = self.getParameterValue(self.TARGET_CRS)
targetCrs = QgsCoordinateReferenceSystem(crsId)
targetCrs = QgsCoordinateReferenceSystem()
targetCrs.createFromUserInput(crsId)
self.crs = targetCrs

outFeat = QgsFeature()
@@ -55,7 +55,8 @@ def processAlgorithm(self, progress):
layer = dataobjects.getObjectFromUri(
self.getParameterValue(self.INPUT))
crsId = self.getParameterValue(self.TARGET_CRS)
targetCrs = QgsCoordinateReferenceSystem(crsId)
targetCrs = QgsCoordinateReferenceSystem()
targetCrs.createFromUserInput(crsId)

writer = self.getOutputFromName(
self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
@@ -117,7 +117,10 @@ def setValue(self, value):
class ParameterCrs(Parameter):

def __init__(self, name='', description='', default='EPSG:4326'):
'''The value is the auth id of the CRS'''
'''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)
self.value = None
self.default = default
@@ -142,8 +142,9 @@ def getWidgetFromParameter(self, param, row, col):
else:
item = QLineEdit()
try:
item.setText(param.default)
item.setText(str(param.default))
except:
item.setText("0")
pass

return item
@@ -41,23 +41,29 @@ def __init__(self, default):
self.leText.setEnabled(False)

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

def setAuthId(self, authid):
self.authId = authid
self.crs = authid
self.updateText()

def browseCRS(self):
selector = QgsGenericProjectionSelector()
selector.setSelectedAuthId(self.authId)
selector.setSelectedAuthId(self.crs)
if selector.exec_():
self.authId = selector.selectedAuthId()
authId = selector.selectedAuthId()
if authId.upper().startswith("EPSG:"):
self.crs = authId
else:
proj = QgsCoordinateReferenceSystem()
proj.createFromSrsId(selector.selectedCrsId())
self.crs = proj.toProj4()
self.updateText()

def updateText(self):
if self.authId is not None:
self.leText.setText(self.authId)

if self.crs is not None:
self.leText.setText(self.crs)
def getValue(self):
return self.authId
return self.crs
@@ -253,6 +253,7 @@ def processAlgorithm(self, progress):

ns = {}
ns['progress'] = progress
ns['scriptDescriptionFile'] = self.descriptionFile

for param in self.parameters:
ns[param.name] = param.value

0 comments on commit 098aa68

Please sign in to comment.