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.

(cherry picked from commit c6f3d5f)
  • Loading branch information
nyalldawson committed Feb 7, 2019
1 parent d590055 commit 985abf14ab20fe90ef2bbfba5e5e2744fcfab833
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 985abf1

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