@@ -792,6 +792,13 @@ static QVariant fcnScale( const QVariantList&, QgsFeature*, QgsExpression* paren
792
792
return QVariant ( parent->scale () );
793
793
}
794
794
795
+ static QVariant fcnFormatNumber ( const QVariantList& values, QgsFeature*, QgsExpression* parent )
796
+ {
797
+ double value = getDoubleValue ( values.at (0 ), parent );
798
+ int places = getIntValue ( values.at (1 ), parent );
799
+ return QString ( " %L1" ).arg ( value, 0 , ' f' , places );
800
+ }
801
+
795
802
QList<QgsExpression::FunctionDef> QgsExpression::gmBuiltinFunctions;
796
803
797
804
const QList<QgsExpression::FunctionDef> &QgsExpression::BuiltinFunctions ()
@@ -847,6 +854,7 @@ const QList<QgsExpression::FunctionDef> &QgsExpression::BuiltinFunctions()
847
854
<< FunctionDef ( " right" , 2 , fcnRight, QObject::tr ( " String" ) )
848
855
<< FunctionDef ( " rpad" , 3 , fcnRPad, QObject::tr ( " String" ) )
849
856
<< FunctionDef ( " lpad" , 3 , fcnLPad, QObject::tr ( " String" ) )
857
+ << FunctionDef ( " format_number" , 2 , fcnFormatNumber, QObject::tr ( " String" ) )
850
858
851
859
// geometry accessors
852
860
<< FunctionDef ( " xat" , 1 , fcnXat, QObject::tr ( " Geometry" ), " " , true )
0 commit comments