@@ -69,9 +69,13 @@ QList<int> QgsDensifyGeometriesByIntervalAlgorithm::inputLayerTypes() const
69
69
void QgsDensifyGeometriesByIntervalAlgorithm::initParameters ( const QVariantMap &configuration )
70
70
{
71
71
Q_UNUSED ( configuration )
72
- addParameter ( new QgsProcessingParameterDistance ( QStringLiteral ( " INTERVAL" ),
73
- QObject::tr ( " Interval between vertices to add" ),
74
- 1 , QStringLiteral ( " INPUT" ), false , 0 , 10000000 ) );
72
+ std::unique_ptr<QgsProcessingParameterDistance> interval = qgis::make_unique<QgsProcessingParameterDistance>( QStringLiteral ( " INTERVAL" ),
73
+ QObject::tr ( " Interval between vertices to add" ),
74
+ 1 , QStringLiteral ( " INPUT" ), false , 0 , 10000000 );
75
+ interval->setIsDynamic ( true );
76
+ interval->setDynamicPropertyDefinition ( QgsPropertyDefinition ( QStringLiteral ( " Interval" ), QObject::tr ( " Interval" ), QgsPropertyDefinition::DoublePositive ) );
77
+ interval->setDynamicLayerParameterName ( QStringLiteral ( " INPUT" ) );
78
+ addParameter ( interval.release () );
75
79
}
76
80
77
81
QString QgsDensifyGeometriesByIntervalAlgorithm::outputName () const
@@ -84,6 +88,11 @@ QgsFeatureList QgsDensifyGeometriesByIntervalAlgorithm::processFeature( const Qg
84
88
Q_UNUSED ( context );
85
89
Q_UNUSED ( feedback );
86
90
QgsFeature modifiedFeature = feature;
91
+
92
+ double interval = mInterval ;
93
+ if ( mDynamicInterval )
94
+ interval = mIntervalProperty .valueAsDouble ( context.expressionContext (), interval );
95
+
87
96
if ( feature.hasGeometry () )
88
97
modifiedFeature.setGeometry ( feature.geometry ().densifyByDistance ( mInterval ) );
89
98
@@ -94,5 +103,10 @@ bool QgsDensifyGeometriesByIntervalAlgorithm::prepareAlgorithm( const QVariantMa
94
103
{
95
104
Q_UNUSED ( feedback );
96
105
mInterval = parameterAsDouble ( parameters, QStringLiteral ( " INTERVAL" ), context );
106
+
107
+ mDynamicInterval = QgsProcessingParameters::isDynamic ( parameters, QStringLiteral ( " INTERVAL" ) );
108
+ if ( mDynamicInterval )
109
+ mIntervalProperty = parameters.value ( QStringLiteral ( " INTERVAL" ) ).value < QgsProperty >();
110
+
97
111
return true ;
98
112
}
0 commit comments