Skip to content

Commit

Permalink
[processing][needs-docs] Make Find Projection algorithm simpler to use
Browse files Browse the repository at this point in the history
We no longer require the seperate CRS parameter, because the extent
parameter contains the CRS information itself. This means the algorithm
is simplified to just picking the layer and drawing the desired area
on the canvas.

(cherry picked from commit c6f3d5f)
  • Loading branch information
nyalldawson committed Feb 7, 2019
1 parent d590055 commit 985abf1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions python/plugins/processing/algs/qgis/FindProjection.py
Expand Up @@ -40,7 +40,8 @@
QgsProcessingParameterFeatureSource,
QgsProcessingParameterExtent,
QgsProcessingParameterCrs,
QgsProcessingParameterFeatureSink)
QgsProcessingParameterFeatureSink,
QgsProcessingParameterDefinition)
from qgis.PyQt.QtCore import QVariant

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
Expand Down Expand Up @@ -72,9 +73,12 @@ def initAlgorithm(self, config=None):
self.tr('Input layer')))
extent_parameter = QgsProcessingParameterExtent(self.TARGET_AREA,
self.tr('Target area for layer'))
#extent_parameter.skip_crs_check = True
self.addParameter(extent_parameter)
self.addParameter(QgsProcessingParameterCrs(self.TARGET_AREA_CRS, 'Target area CRS'))

# deprecated
crs_param = QgsProcessingParameterCrs(self.TARGET_AREA_CRS, 'Target area CRS', optional=True)
crs_param.setFlags(crs_param.flags() | QgsProcessingParameterDefinition.FlagHidden)
self.addParameter(crs_param)

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT,
self.tr('CRS candidates')))
Expand All @@ -91,7 +95,11 @@ def processAlgorithm(self, parameters, context, feedback):
raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT))

extent = self.parameterAsExtent(parameters, self.TARGET_AREA, context)
target_crs = self.parameterAsCrs(parameters, self.TARGET_AREA_CRS, context)
target_crs = self.parameterAsExtentCrs(parameters, self.TARGET_AREA, context)
if self.TARGET_AREA_CRS in parameters:
c = self.parameterAsCrs(parameters, self.TARGET_AREA_CRS, context)
if c.isValid():
target_crs = c

target_geom = QgsGeometry.fromRect(extent)

Expand Down

0 comments on commit 985abf1

Please sign in to comment.