[needs-docs][processing] add help and clarity to the define current projection algorithm

This commit is contained in:
Mathieu Pellerin 2018-05-01 10:14:08 +07:00 committed by GitHub
parent 3228654e5b
commit 39c6e23c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -550,3 +550,9 @@ qgis:voronoipolygons: >
qgis:zonalstatistics: qgis:zonalstatistics:
qgis:definecurrentprojection: >
This algorithm sets an existing layer's projection to the provided CRS. Contrary to the "Assign projection" algorithm, it will not output a new layer.
For shapefile datasets, the .prj and .qpj files will be overwritten - or created if missing - to match the provided CRS.

View File

@ -56,7 +56,7 @@ class DefineProjection(QgisAlgorithm):
def initAlgorithm(self, config=None): def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT, self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Input Layer'), types=[QgsProcessing.TypeVectorAnyGeometry])) self.tr('Input Layer'), types=[QgsProcessing.TypeVectorAnyGeometry]))
self.addParameter(QgsProcessingParameterCrs(self.CRS, 'Output CRS')) self.addParameter(QgsProcessingParameterCrs(self.CRS, 'CRS'))
self.addOutput(QgsProcessingOutputVectorLayer(self.INPUT, self.addOutput(QgsProcessingOutputVectorLayer(self.INPUT,
self.tr('Layer with projection'))) self.tr('Layer with projection')))
@ -64,7 +64,7 @@ class DefineProjection(QgisAlgorithm):
return 'definecurrentprojection' return 'definecurrentprojection'
def displayName(self): def displayName(self):
return self.tr('Define current projection') return self.tr('Define layer projection')
def flags(self): def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagNoThreading return super().flags() | QgsProcessingAlgorithm.FlagNoThreading
@ -89,6 +89,8 @@ class DefineProjection(QgisAlgorithm):
if os.path.exists(qpjFile): if os.path.exists(qpjFile):
with open(qpjFile, 'w') as f: with open(qpjFile, 'w') as f:
f.write(wkt) f.write(wkt)
else:
feedback.pushConsoleInfo(tr("Data source isn't a shapefile, skipping .prj/.qpj creation"))
layer.setCrs(crs) layer.setCrs(crs)
layer.triggerRepaint() layer.triggerRepaint()