QGIS API Documentation 3.99.0-Master (09f76ad7019)
Loading...
Searching...
No Matches
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
20#include <QString>
21
22using namespace Qt::StringLiterals;
23
25
26QString QgsAssignProjectionAlgorithm::name() const
27{
28 return u"assignprojection"_s;
29}
30
31QString QgsAssignProjectionAlgorithm::displayName() const
32{
33 return QObject::tr( "Assign projection" );
34}
35
36QStringList QgsAssignProjectionAlgorithm::tags() const
37{
38 return QObject::tr( "assign,set,transform,reproject,crs,srs,warp" ).split( ',' );
39}
40
41QString QgsAssignProjectionAlgorithm::group() const
42{
43 return QObject::tr( "Vector general" );
44}
45
46QString QgsAssignProjectionAlgorithm::groupId() const
47{
48 return u"vectorgeneral"_s;
49}
50
51QString QgsAssignProjectionAlgorithm::outputName() const
52{
53 return QObject::tr( "Assigned CRS" );
54}
55
56QString QgsAssignProjectionAlgorithm::shortHelpString() const
57{
58 return QObject::tr( "This algorithm assigns a new projection to a vector layer. It creates a new layer with the exact same features "
59 "and geometries as the input one, but assigned to a new CRS. E.g. the geometries are not reprojected, they are just assigned "
60 "to a different CRS. This algorithm can be used to repair layers which have been assigned an incorrect projection.\n\n"
61 "Attributes are not modified by this algorithm." );
62}
63
64QString QgsAssignProjectionAlgorithm::shortDescription() const
65{
66 return QObject::tr( "Assigns a new projection to a copy of a vector layer, with the exact same features and geometries." );
67}
68
69QgsAssignProjectionAlgorithm *QgsAssignProjectionAlgorithm::createInstance() const
70{
71 return new QgsAssignProjectionAlgorithm();
72}
73
74bool QgsAssignProjectionAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
75{
76 Q_UNUSED( layer )
77 return false;
78}
79
80void QgsAssignProjectionAlgorithm::initParameters( const QVariantMap & )
81{
82 addParameter( new QgsProcessingParameterCrs( u"CRS"_s, QObject::tr( "Assigned CRS" ), u"EPSG:4326"_s ) );
83}
84
85Qgis::ProcessingFeatureSourceFlags QgsAssignProjectionAlgorithm::sourceFlags() const
86{
88}
89
90bool QgsAssignProjectionAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
91{
92 mDestCrs = parameterAsCrs( parameters, u"CRS"_s, context );
93 return true;
94}
95
96QgsFeatureList QgsAssignProjectionAlgorithm::processFeature( const QgsFeature &feature, QgsProcessingContext &, QgsProcessingFeedback * )
97{
98 return QgsFeatureList() << feature;
99}
100
@ SkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
Definition qgis.h:3782
QFlags< ProcessingFeatureSourceFlag > ProcessingFeatureSourceFlags
Flags which control how QgsProcessingFeatureSource fetches features.
Definition qgis.h:3793
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Base class for all map layer types.
Definition qgsmaplayer.h:83
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