@@ -24,8 +24,14 @@ void QgsTransformAlgorithm::initParameters( const QVariantMap & )
24
24
{
25
25
addParameter ( new QgsProcessingParameterCrs ( QStringLiteral ( " TARGET_CRS" ), QObject::tr ( " Target CRS" ), QStringLiteral ( " EPSG:4326" ) ) );
26
26
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 );
27
+ // Convert curves to straight segments
28
+ auto convertCurvesParam = std::make_unique<QgsProcessingParameterBoolean>( QStringLiteral ( " CONVERT_CURVED_GEOMETRIES" ), QObject::tr ( " Convert curved geometries to straight segments" ), false );
29
+ convertCurvesParam->setHelp ( QObject::tr ( " If checked, curved geometries will be converted to straight segments. Otherwise, they will be kept as curves. This can fix distortion issues." ) );
30
+ addParameter ( convertCurvesParam.release () );
31
+
32
+ // Optional coordinate operation
33
+ auto crsOpParam = std::make_unique< QgsProcessingParameterCoordinateOperation >( QStringLiteral ( " OPERATION" ), QObject::tr ( " Coordinate operation" ),
34
+ QVariant (), QStringLiteral ( " INPUT" ), QStringLiteral ( " TARGET_CRS" ), QVariant (), QVariant (), true );
29
35
crsOpParam->setFlags ( crsOpParam->flags () | QgsProcessingParameterDefinition::FlagAdvanced );
30
36
addParameter ( crsOpParam.release () );
31
37
}
@@ -87,6 +93,7 @@ bool QgsTransformAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, Qgs
87
93
prepareSource ( parameters, context );
88
94
mDestCrs = parameterAsCrs ( parameters, QStringLiteral ( " TARGET_CRS" ), context );
89
95
mTransformContext = context.transformContext ();
96
+ mConvertCurveToSegments = parameterAsBoolean ( parameters, QStringLiteral ( " CONVERT_CURVED_GEOMETRIES" ), context );
90
97
mCoordOp = parameterAsString ( parameters, QStringLiteral ( " OPERATION" ), context );
91
98
return true ;
92
99
}
@@ -107,8 +114,12 @@ QgsFeatureList QgsTransformAlgorithm::processFeature( const QgsFeature &f, QgsPr
107
114
if ( feature.hasGeometry () )
108
115
{
109
116
QgsGeometry g = feature.geometry ();
110
- // convert to straight segments to avoid issues with distorted curves
111
- g.convertToStraightSegment ();
117
+
118
+ if ( !mTransform .isShortCircuited () && mConvertCurveToSegments )
119
+ {
120
+ // convert to straight segments to avoid issues with distorted curves
121
+ g.convertToStraightSegment ();
122
+ }
112
123
try
113
124
{
114
125
if ( g.transform ( mTransform ) == Qgis::GeometryOperationResult::Success )
0 commit comments