@@ -2543,6 +2543,27 @@ static QVariant fcnShortestLine( const QVariantList& values, const QgsExpression
2543
2543
return result;
2544
2544
}
2545
2545
2546
+ static QVariant fcnLineInterpolatePoint ( const QVariantList& values, const QgsExpressionContext*, QgsExpression* parent )
2547
+ {
2548
+ QgsGeometry lineGeom = getGeometry ( values.at ( 0 ), parent );
2549
+ double distance = getDoubleValue ( values.at ( 1 ), parent );
2550
+
2551
+ QgsGeometry geom = lineGeom.interpolate ( distance );
2552
+
2553
+ QVariant result = !geom.isEmpty () ? QVariant::fromValue ( geom ) : QVariant ();
2554
+ return result;
2555
+ }
2556
+
2557
+ static QVariant fcnLineLocatePoint ( const QVariantList& values, const QgsExpressionContext*, QgsExpression* parent )
2558
+ {
2559
+ QgsGeometry lineGeom = getGeometry ( values.at ( 0 ), parent );
2560
+ QgsGeometry pointGeom = getGeometry ( values.at ( 1 ), parent );
2561
+
2562
+ double distance = lineGeom.lineLocatePoint ( pointGeom );
2563
+
2564
+ return distance >= 0 ? distance : QVariant ();
2565
+ }
2566
+
2546
2567
static QVariant fcnRound ( const QVariantList& values, const QgsExpressionContext *, QgsExpression* parent )
2547
2568
{
2548
2569
if ( values.length () == 2 && values.at ( 1 ).toInt () != 0 )
@@ -3121,6 +3142,7 @@ const QStringList& QgsExpression::BuiltinFunctions()
3121
3142
<< " bounds_width" << " bounds_height" << " is_closed" << " convex_hull" << " difference"
3122
3143
<< " distance" << " intersection" << " sym_difference" << " combine"
3123
3144
<< " extrude" << " azimuth" << " project" << " closest_point" << " shortest_line"
3145
+ << " line_locate_point" << " line_interpolate_point"
3124
3146
<< " union" << " geom_to_wkt" << " geomToWKT" << " geometry"
3125
3147
<< " transform" << " get_feature" << " getFeature"
3126
3148
<< " levenshtein" << " longest_common_substring" << " hamming_distance"
@@ -3345,6 +3367,10 @@ const QList<QgsExpression::Function*>& QgsExpression::Functions()
3345
3367
<< new StaticFunction ( " order_parts" , 3 , fcnOrderParts, " GeometryGroup" , QString () )
3346
3368
<< new StaticFunction ( " closest_point" , 2 , fcnClosestPoint, " GeometryGroup" )
3347
3369
<< new StaticFunction ( " shortest_line" , 2 , fcnShortestLine, " GeometryGroup" )
3370
+ << new StaticFunction ( " line_interpolate_point" , ParameterList () << Parameter ( " geometry" )
3371
+ << Parameter ( " distance" ), fcnLineInterpolatePoint, " GeometryGroup" )
3372
+ << new StaticFunction ( " line_locate_point" , ParameterList () << Parameter ( " geometry" )
3373
+ << Parameter ( " point" ), fcnLineLocatePoint, " GeometryGroup" )
3348
3374
<< new StaticFunction ( " $id" , 0 , fcnFeatureId, " Record" )
3349
3375
<< new StaticFunction ( " $currentfeature" , 0 , fcnFeature, " Record" )
3350
3376
<< new StaticFunction ( " uuid" , 0 , fcnUuid, " Record" , QString (), false , QStringList (), false , QStringList () << " $uuid" )
0 commit comments