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