Skip to content
Permalink
Browse files

[processing][needs-docs] Make Find Projection algorithm simpler to use

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.
  • Loading branch information
nyalldawson committed Feb 5, 2019
1 parent c93775f commit c6f3d5ff483554e7a338c07b2cb22f38b5bf4d36
Showing with 12 additions and 4 deletions.
  1. +12 −4 python/plugins/processing/algs/qgis/FindProjection.py
@@ -40,7 +40,8 @@
QgsProcessingParameterFeatureSource,
QgsProcessingParameterExtent,
QgsProcessingParameterCrs,
QgsProcessingParameterFeatureSink)
QgsProcessingParameterFeatureSink,
QgsProcessingParameterDefinition)
from qgis.PyQt.QtCore import QVariant

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
@@ -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')))
@@ -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)

0 comments on commit c6f3d5f

Please sign in to comment.
You can’t perform that action at this time.