23 void QgsTransformAlgorithm::initParameters(
const QVariantMap & )
25 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"TARGET_CRS" ), QObject::tr(
"Target CRS" ), QStringLiteral(
"EPSG:4326" ) ) );
27 std::unique_ptr< QgsProcessingParameterCoordinateOperation > crsOpParam = std::make_unique< QgsProcessingParameterCoordinateOperation >( QStringLiteral(
"OPERATION" ), QObject::tr(
"Coordinate operation" ),
28 QVariant(), QStringLiteral(
"INPUT" ), QStringLiteral(
"TARGET_CRS" ), QVariant(), QVariant(),
true );
30 addParameter( crsOpParam.release() );
38 QString QgsTransformAlgorithm::outputName()
const
40 return QObject::tr(
"Reprojected" );
48 QString QgsTransformAlgorithm::name()
const
50 return QStringLiteral(
"reprojectlayer" );
53 QString QgsTransformAlgorithm::displayName()
const
55 return QObject::tr(
"Reproject layer" );
58 QStringList QgsTransformAlgorithm::tags()
const
60 return QObject::tr(
"transform,reprojection,crs,srs,warp" ).split(
',' );
63 QString QgsTransformAlgorithm::group()
const
65 return QObject::tr(
"Vector general" );
68 QString QgsTransformAlgorithm::groupId()
const
70 return QStringLiteral(
"vectorgeneral" );
73 QString QgsTransformAlgorithm::shortHelpString()
const
75 return QObject::tr(
"This algorithm reprojects a vector layer. It creates a new layer with the same features "
76 "as the input one, but with geometries reprojected to a new CRS.\n\n"
77 "Attributes are not modified by this algorithm." );
80 QgsTransformAlgorithm *QgsTransformAlgorithm::createInstance()
const
82 return new QgsTransformAlgorithm();
87 prepareSource( parameters, context );
88 mDestCrs = parameterAsCrs( parameters, QStringLiteral(
"TARGET_CRS" ), context );
90 mCoordOp = parameterAsString( parameters, QStringLiteral(
"OPERATION" ), context );
97 if ( !mCreatedTransform )
99 mCreatedTransform =
true;
100 if ( !mCoordOp.isEmpty() )
101 mTransformContext.addCoordinateOperation( sourceCrs(), mDestCrs, mCoordOp,
false );
104 mTransform.disableFallbackOperationHandler(
true );
121 if ( !mWarnedAboutFallbackTransform && mTransform.fallbackOperationOccurred() )
123 feedback->
reportError( QObject::tr(
"An alternative, ballpark-only transform was used when transforming coordinates for one or more features. "
124 "(Possibly an incorrect choice of operation was made for transformations between these reference systems - check "
125 "that the selected operation is valid for the full extent of the input layer.)" ) );
126 mWarnedAboutFallbackTransform =
true;
132 feedback->
reportError( QObject::tr(
"Encountered a transform error when reprojecting feature with id %1." ).arg( f.
id() ) );