@@ -220,6 +220,30 @@ bool QgsExpressionFunction::allParamsStatic( const QgsExpressionNodeFunction *no
220
220
return true ;
221
221
}
222
222
223
+ static QVariant fcnGenerateSeries ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
224
+ {
225
+ double start = QgsExpressionUtils::getDoubleValue ( values.at ( 0 ), parent );
226
+ double stop = QgsExpressionUtils::getDoubleValue ( values.at ( 1 ), parent );
227
+ double step = QgsExpressionUtils::getDoubleValue ( values.at ( 2 ), parent );
228
+
229
+ if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
230
+ return QVariant ();
231
+
232
+ QVariantList array;
233
+ int length = 1 ;
234
+
235
+ array << start;
236
+ double current = start + step;
237
+ while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
238
+ {
239
+ array << current;
240
+ current += step;
241
+ length++;
242
+ }
243
+
244
+ return array;
245
+ }
246
+
223
247
static QVariant fcnGetVariable ( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction * )
224
248
{
225
249
if ( !context )
@@ -4724,6 +4748,7 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
4724
4748
<< new QgsStaticExpressionFunction ( QStringLiteral ( " array_distinct" ), 1 , fcnArrayDistinct, QStringLiteral ( " Arrays" ) )
4725
4749
<< new QgsStaticExpressionFunction ( QStringLiteral ( " array_to_string" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " array" ) ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " delimiter" ), true , " ," ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " emptyvalue" ), true , " " ), fcnArrayToString, QStringLiteral ( " Arrays" ) )
4726
4750
<< new QgsStaticExpressionFunction ( QStringLiteral ( " string_to_array" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " string" ) ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " delimiter" ), true , " ," ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " emptyvalue" ), true , " " ), fcnStringToArray, QStringLiteral ( " Arrays" ) )
4751
+ << new QgsStaticExpressionFunction ( QStringLiteral ( " generate_series" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " start" ) ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " stop" ) ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " step" ), true , 1.0 ), fcnGenerateSeries, QStringLiteral ( " Arrays" ) )
4727
4752
4728
4753
// functions for maps
4729
4754
<< new QgsStaticExpressionFunction ( QStringLiteral ( " map" ), -1 , fcnMap, QStringLiteral ( " Maps" ) )
0 commit comments