QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsalgorithmassignprojection.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmassignprojection.cpp
3  --------------------------------
4  begin : April 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
19 
21 
22 QString QgsAssignProjectionAlgorithm::name() const
23 {
24  return QStringLiteral( "assignprojection" );
25 }
26 
27 QString QgsAssignProjectionAlgorithm::displayName() const
28 {
29  return QObject::tr( "Assign projection" );
30 }
31 
32 QStringList QgsAssignProjectionAlgorithm::tags() const
33 {
34  return QObject::tr( "assign,set,transform,reproject,crs,srs,warp" ).split( ',' );
35 }
36 
37 QString QgsAssignProjectionAlgorithm::group() const
38 {
39  return QObject::tr( "Vector general" );
40 }
41 
42 QString QgsAssignProjectionAlgorithm::groupId() const
43 {
44  return QStringLiteral( "vectorgeneral" );
45 }
46 
47 QString QgsAssignProjectionAlgorithm::outputName() const
48 {
49  return QObject::tr( "Assigned CRS" );
50 }
51 
52 QString QgsAssignProjectionAlgorithm::shortHelpString() const
53 {
54  return QObject::tr( "This algorithm assigns a new projection to a vector layer. It creates a new layer with the exact same features "
55  "and geometries as the input one, but assigned to a new CRS. E.g. the geometries are not reprojected, they are just assigned "
56  "to a different CRS. This algorithm can be used to repair layers which have been assigned an incorrect projection.\n\n"
57  "Attributes are not modified by this algorithm." );
58 }
59 
60 QgsAssignProjectionAlgorithm *QgsAssignProjectionAlgorithm::createInstance() const
61 {
62  return new QgsAssignProjectionAlgorithm();
63 }
64 
65 void QgsAssignProjectionAlgorithm::initParameters( const QVariantMap & )
66 {
67  addParameter( new QgsProcessingParameterCrs( QStringLiteral( "CRS" ), QObject::tr( "Assigned CRS" ), QStringLiteral( "EPSG:4326" ) ) );
68 }
69 
70 QgsProcessingFeatureSource::Flag QgsAssignProjectionAlgorithm::sourceFlags() const
71 {
73 }
74 
75 bool QgsAssignProjectionAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
76 {
77  mDestCrs = parameterAsCrs( parameters, QStringLiteral( "CRS" ), context );
78  return true;
79 }
80 
81 QgsFeatureList QgsAssignProjectionAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
82 {
83  return QgsFeatureList() << feature;
84 }
85 
87 
Base class for providing feedback from a processing algorithm.
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:549
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
A coordinate reference system parameter for processing algorithms.
Flag
Flags controlling how QgsProcessingFeatureSource fetches features.
Contains information about the context in which a processing algorithm is executed.