mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Apply suggestions from code review
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
This commit is contained in:
parent
106e079258
commit
49f2ec9007
@ -10,13 +10,15 @@
|
||||
"arg": "point_b",
|
||||
"description": "point geometry"
|
||||
}, {
|
||||
"arg": "source_auth_id",
|
||||
"arg": "source_crs",
|
||||
"optional": true,
|
||||
"description": "an optional string representing the source auth CRS ID of the points. By default the current layer's auth CRS ID is used."
|
||||
"description": "an optional string representing the source CRS of the points. By default the current layer's CRS is used."
|
||||
|
||||
}, {
|
||||
"arg": "ellipsoid",
|
||||
"optional": true,
|
||||
"description": "an optional string representing the acronym or the auth ID of the ellipsoid on which the bearing should be measured. By default the current project's ellipsoid setting is used."
|
||||
"description": "an optional string representing the acronym or the authority:ID (eg 'EPSG:7030') of the ellipsoid on which the bearing should be measured. By default the current project's ellipsoid setting is used."
|
||||
|
||||
}],
|
||||
"examples": [{
|
||||
"expression": "degrees( bearing( make_point(16198544, -4534850), make_point(18736872, -1877769), 'EPSG:3857', 'EPSG:7030') )",
|
||||
|
||||
@ -5391,7 +5391,7 @@ static QVariant fcnBearing( const QVariantList &values, const QgsExpressionConte
|
||||
{
|
||||
const QgsGeometry geom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
|
||||
const QgsGeometry geom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
|
||||
QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
|
||||
QString sourceCrs = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
|
||||
QString ellipsoid = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
|
||||
|
||||
if ( geom1.isNull() || geom2.isNull() || geom1.type() != Qgis::GeometryType::Point || geom2.type() != Qgis::GeometryType::Point )
|
||||
@ -5413,9 +5413,9 @@ static QVariant fcnBearing( const QVariantList &values, const QgsExpressionConte
|
||||
{
|
||||
tContext = context->variable( QStringLiteral( "_project_transform_context" ) ).value<QgsCoordinateTransformContext>();
|
||||
|
||||
if ( sAuthId.isEmpty() )
|
||||
if ( sourceCrs.isEmpty() )
|
||||
{
|
||||
sAuthId = context->variable( QStringLiteral( "layer_crs" ) ).toString();
|
||||
sourceCrs = context->variable( QStringLiteral( "layer_crs" ) ).toString();
|
||||
}
|
||||
|
||||
if ( ellipsoid.isEmpty() )
|
||||
@ -5424,10 +5424,10 @@ static QVariant fcnBearing( const QVariantList &values, const QgsExpressionConte
|
||||
}
|
||||
}
|
||||
|
||||
const QgsCoordinateReferenceSystem sCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( sAuthId );
|
||||
const QgsCoordinateReferenceSystem sCrs = QgsCoordinateReferenceSystem( sourceCrs );
|
||||
if ( !sCrs.isValid() )
|
||||
{
|
||||
parent->setEvalErrorString( QObject::tr( "Function `bearing` requires a valid source auth CRS ID." ) );
|
||||
parent->setEvalErrorString( QObject::tr( "Function `bearing` requires a valid source CRS." ) );
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -5435,7 +5435,7 @@ static QVariant fcnBearing( const QVariantList &values, const QgsExpressionConte
|
||||
da.setSourceCrs( sCrs, tContext );
|
||||
if ( !da.setEllipsoid( ellipsoid ) )
|
||||
{
|
||||
parent->setEvalErrorString( QObject::tr( "Function `bearing` requires a valid ellipsoid acronym or ellipsoid auth ID." ) );
|
||||
parent->setEvalErrorString( QObject::tr( "Function `bearing` requires a valid ellipsoid acronym or ellipsoid authority ID." ) );
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@ -8097,7 +8097,7 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "radians" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "degrees" ) ), fcnRadians, QStringLiteral( "Math" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "degrees" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "radians" ) ), fcnDegrees, QStringLiteral( "Math" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "azimuth" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "point_b" ) ), fcnAzimuth, QStringLiteral( "GeometryGroup" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "bearing" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "point_b" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "source_auth_id" ), true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral( "ellipsoid" ), true, QVariant() ), fcnBearing, QStringLiteral( "GeometryGroup" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "bearing" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "point_b" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "source_crs" ), true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral( "ellipsoid" ), true, QVariant() ), fcnBearing, QStringLiteral( "GeometryGroup" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "inclination" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "point_b" ) ), fcnInclination, QStringLiteral( "GeometryGroup" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "project" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "point" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "azimuth" ) ) << QgsExpressionFunction::Parameter( QStringLiteral( "elevation" ), true, M_PI_2 ), fcnProject, QStringLiteral( "GeometryGroup" ) )
|
||||
<< new QgsStaticExpressionFunction( QStringLiteral( "abs" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "value" ) ), fcnAbs, QStringLiteral( "Math" ) )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user