QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
22QString QgsAssignProjectionAlgorithm::name() const
23{
24 return QStringLiteral( "assignprojection" );
25}
26
27QString QgsAssignProjectionAlgorithm::displayName() const
28{
29 return QObject::tr( "Assign projection" );
30}
31
32QStringList QgsAssignProjectionAlgorithm::tags() const
33{
34 return QObject::tr( "assign,set,transform,reproject,crs,srs,warp" ).split( ',' );
35}
36
37QString QgsAssignProjectionAlgorithm::group() const
38{
39 return QObject::tr( "Vector general" );
40}
41
42QString QgsAssignProjectionAlgorithm::groupId() const
43{
44 return QStringLiteral( "vectorgeneral" );
45}
46
47QString QgsAssignProjectionAlgorithm::outputName() const
48{
49 return QObject::tr( "Assigned CRS" );
50}
51
52QString 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
60QgsAssignProjectionAlgorithm *QgsAssignProjectionAlgorithm::createInstance() const
61{
62 return new QgsAssignProjectionAlgorithm();
63}
64
65bool QgsAssignProjectionAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
66{
67 Q_UNUSED( layer )
68 return false;
69}
70
71void QgsAssignProjectionAlgorithm::initParameters( const QVariantMap & )
72{
73 addParameter( new QgsProcessingParameterCrs( QStringLiteral( "CRS" ), QObject::tr( "Assigned CRS" ), QStringLiteral( "EPSG:4326" ) ) );
74}
75
76Qgis::ProcessingFeatureSourceFlags QgsAssignProjectionAlgorithm::sourceFlags() const
77{
79}
80
81bool QgsAssignProjectionAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
82{
83 mDestCrs = parameterAsCrs( parameters, QStringLiteral( "CRS" ), context );
84 return true;
85}
86
87QgsFeatureList QgsAssignProjectionAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
88{
89 return QgsFeatureList() << feature;
90}
91
93
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
Definition: qgis.h:3011
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Base class for all map layer types.
Definition: qgsmaplayer.h:75
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
A coordinate reference system parameter for processing algorithms.
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:917