Skip to content

Commit

Permalink
restore old parameter names in transform() expression function and
Browse files Browse the repository at this point in the history
better handling of null variants and empty strings in getCrsValue()
  • Loading branch information
alexbruy authored and nyalldawson committed Feb 13, 2025
1 parent 8cbe41c commit 1f1eec7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/expression/qgsexpressionfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9197,8 +9197,8 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
fcnGeomToWKB, QStringLiteral( "GeometryGroup" ), QString(), false, QSet<QString>(), false )
<< new QgsStaticExpressionFunction( QStringLiteral( "geometry" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "feature" ) ), fcnGetGeometry, QStringLiteral( "GeometryGroup" ), QString(), true )
<< new QgsStaticExpressionFunction( QStringLiteral( "transform" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "geometry" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "source_crs" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "dest_crs" ) ),
<< QgsExpressionFunction::Parameter( QStringLiteral( "source_auth_id" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "dest_auth_id" ) ),
fcnTransformGeometry, QStringLiteral( "GeometryGroup" ) )
<< new QgsStaticExpressionFunction( QStringLiteral( "extrude" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "geometry" ) )
<< QgsExpressionFunction::Parameter( QStringLiteral( "x" ) )
Expand Down
10 changes: 10 additions & 0 deletions src/core/expression/qgsexpressionutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,18 @@ QgsMapLayer *QgsExpressionUtils::getMapLayerPrivate( const QVariant &value, cons

QgsCoordinateReferenceSystem QgsExpressionUtils::getCrsValue( const QVariant &value, QgsExpression *parent )
{
if ( QgsVariantUtils::isNull( value ) )
{
return QgsCoordinateReferenceSystem();
}

const bool isCrs = value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>();

if ( !isCrs && value.toString().isEmpty() )
{
return QgsCoordinateReferenceSystem();
}

QgsCoordinateReferenceSystem crs = isCrs ? value.value<QgsCoordinateReferenceSystem>() : QgsCoordinateReferenceSystem( value.toString() );
if ( !crs.isValid() )
{
Expand Down

0 comments on commit 1f1eec7

Please sign in to comment.