Skip to content

Commit

Permalink
[Processing] Allow user defined projections in Processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
radosuav committed Jan 22, 2015
1 parent 8fc6dd8 commit b835f40
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
1 change: 0 additions & 1 deletion python/plugins/processing/algs/gdal/warp.py
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/qgis/PointsLayerFromTable.py
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/qgis/ReprojectLayer.py
Expand Up @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/processing/core/parameters.py
Expand Up @@ -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
Expand Down
22 changes: 14 additions & 8 deletions python/plugins/processing/gui/CrsSelectionPanel.py
Expand Up @@ -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

0 comments on commit b835f40

Please sign in to comment.