mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Code name consistency fix and unit tests for functions
This commit is contained in:
parent
151c9033a0
commit
0372e4b61b
@ -13,3 +13,8 @@ Returns a string representing a color from a color ramp.
|
||||
<p><h4>Example</h4>
|
||||
<!-- Show example of function.-->
|
||||
ramp_color('Spectral',0.3) → '#fdbe73'</p>
|
||||
|
||||
<p><h4>Note:</h4>
|
||||
The color ramps available vary between QGIS installations. This function
|
||||
may not give the expected results if you move your Quantum project.
|
||||
</p>
|
||||
|
@ -979,7 +979,7 @@ static QVariant fcnFormatDate( const QVariantList& values, QgsFeature*, QgsExpre
|
||||
return dt.toString( format );
|
||||
}
|
||||
|
||||
static QVariant fncColorRgb( const QVariantList &values, QgsFeature *, QgsExpression *parent )
|
||||
static QVariant fcnColorRgb( const QVariantList &values, QgsFeature *, QgsExpression *parent )
|
||||
{
|
||||
int red = getIntValue( values.at( 0 ), parent );
|
||||
int green = getIntValue( values.at( 1 ), parent );
|
||||
@ -1009,7 +1009,7 @@ static QVariant fncColorRgba( const QVariantList &values, QgsFeature *, QgsExpre
|
||||
return QgsSymbolLayerV2Utils::encodeColor( color );
|
||||
}
|
||||
|
||||
QVariant fncRampColor( const QVariantList &values, QgsFeature *, QgsExpression *parent )
|
||||
QVariant fcnRampColor( const QVariantList &values, QgsFeature *, QgsExpression *parent )
|
||||
{
|
||||
QString rampName = getStringValue( values.at( 0 ), parent );
|
||||
const QgsVectorColorRampV2 *mRamp = QgsStyleV2::defaultStyle()->colorRampRef( rampName );
|
||||
@ -1077,7 +1077,7 @@ const QStringList &QgsExpression::BuiltinFunctions()
|
||||
<< "substr" << "concat" << "strpos" << "left"
|
||||
<< "right" << "rpad" << "lpad"
|
||||
<< "format_number" << "format_date"
|
||||
<< "color_rgb" << "color_rgba" << "ramp_colour"
|
||||
<< "color_rgb" << "color_rgba" << "ramp_color"
|
||||
<< "xat" << "yat" << "$area"
|
||||
<< "$length" << "$perimeter" << "$x" << "$y"
|
||||
<< "$rownum" << "$id" << "$scale" << "_specialcol_";
|
||||
@ -1139,9 +1139,9 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
|
||||
<< new StaticFunction( "format", -1, fcnFormatString, QObject::tr( "String" ) )
|
||||
<< new StaticFunction( "format_number", 2, fcnFormatNumber, QObject::tr( "String" ) )
|
||||
<< new StaticFunction( "format_date", 2, fcnFormatDate, QObject::tr( "String" ) )
|
||||
<< new StaticFunction( "color_rgb", 3, fncColorRgb, QObject::tr( "Color" ) )
|
||||
<< new StaticFunction( "color_rgb", 3, fcnColorRgb, QObject::tr( "Color" ) )
|
||||
<< new StaticFunction( "color_rgba", 4, fncColorRgba, QObject::tr( "Color" ) )
|
||||
<< new StaticFunction( "ramp_color", 2, fncRampColor, QObject::tr( "Color" ) )
|
||||
<< new StaticFunction( "ramp_color", 2, fcnRampColor, QObject::tr( "Color" ) )
|
||||
<< new StaticFunction( "xat", 1, fcnXat, QObject::tr( "Geometry" ), "", true )
|
||||
<< new StaticFunction( "yat", 1, fcnYat, QObject::tr( "Geometry" ), "", true )
|
||||
<< new StaticFunction( "$area", 0, fcnGeomArea, QObject::tr( "Geometry" ), "", true )
|
||||
|
@ -314,6 +314,11 @@ class TestQgsExpression: public QObject
|
||||
QTest::newRow( "year with interval" ) << "year(tointerval('2 years'))" << false << QVariant( 2.0 );
|
||||
QTest::newRow( "age" ) << "age('2012-06-30','2012-06-28')" << false << QVariant::fromValue( QgsExpression::Interval( 172800 ) );
|
||||
QTest::newRow( "negative age" ) << "age('2012-06-28','2012-06-30')" << false << QVariant::fromValue( QgsExpression::Interval( -172800 ) );
|
||||
|
||||
// Color functions
|
||||
QTest::newRow( "ramp color" ) << "ramp_color('Spectral',0.3)" << false << QVariant( "#fdbe73" );
|
||||
QTest::newRow( "color rgb" ) << "color_rgb(255,127,0)" << false << QVariant( "#ff7f00" );
|
||||
QTest::newRow( "color rgba" ) << "color_rgba(255,127,0,200)" << false << QVariant( "255,127,0,200" );
|
||||
}
|
||||
|
||||
void evaluation()
|
||||
|
Loading…
x
Reference in New Issue
Block a user