@@ -2535,6 +2535,29 @@ static QVariant fcnConvexHull( const QVariantList &values, const QgsExpressionCo
2535
2535
QVariant result = !geom.isNull () ? QVariant::fromValue ( geom ) : QVariant ();
2536
2536
return result;
2537
2537
}
2538
+
2539
+ static QVariant fcnMinimalCircle ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
2540
+ {
2541
+ QgsGeometry fGeom = QgsExpressionUtils::getGeometry ( values.at ( 0 ), parent );
2542
+ QgsPointXY center;
2543
+ double radius;
2544
+ unsigned int segments = 36 ;
2545
+ if ( values.length () == 2 )
2546
+ segments = QgsExpressionUtils::getDoubleValue ( values.at ( 1 ), parent );
2547
+ QgsGeometry geom = fGeom .minimalEnclosingCircle ( center, radius, segments );
2548
+ QVariant result = !geom.isNull () ? QVariant::fromValue ( geom ) : QVariant ();
2549
+ return result;
2550
+ }
2551
+
2552
+ static QVariant fcnOrientedBBox ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
2553
+ {
2554
+ QgsGeometry fGeom = QgsExpressionUtils::getGeometry ( values.at ( 0 ), parent );
2555
+ double area, angle, width, height;
2556
+ QgsGeometry geom = fGeom .orientedMinimumBoundingBox ( area, angle, width, height );
2557
+ QVariant result = !geom.isNull () ? QVariant::fromValue ( geom ) : QVariant ();
2558
+ return result;
2559
+ }
2560
+
2538
2561
static QVariant fcnDifference ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
2539
2562
{
2540
2563
QgsGeometry fGeom = QgsExpressionUtils::getGeometry ( values.at ( 0 ), parent );
@@ -4139,6 +4162,13 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
4139
4162
<< new QgsStaticExpressionFunction ( QStringLiteral ( " bounds_height" ), 1 , fcnBoundsHeight, QStringLiteral ( " GeometryGroup" ) )
4140
4163
<< new QgsStaticExpressionFunction ( QStringLiteral ( " is_closed" ), 1 , fcnIsClosed, QStringLiteral ( " GeometryGroup" ) )
4141
4164
<< new QgsStaticExpressionFunction ( QStringLiteral ( " convex_hull" ), 1 , fcnConvexHull, QStringLiteral ( " GeometryGroup" ), QString (), false , QSet<QString>(), false , QStringList () << QStringLiteral ( " convexHull" ) )
4165
+ << new QgsStaticExpressionFunction ( QStringLiteral ( " oriented_bbox" ), QgsExpressionFunction::ParameterList ()
4166
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " geometry" ) ),
4167
+ fcnOrientedBBox, QStringLiteral ( " GeometryGroup" ) )
4168
+ << new QgsStaticExpressionFunction ( QStringLiteral ( " minimal_circle" ), QgsExpressionFunction::ParameterList ()
4169
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " geometry" ) )
4170
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " segments" ), true , 36 ),
4171
+ fcnMinimalCircle, QStringLiteral ( " GeometryGroup" ) )
4142
4172
<< new QgsStaticExpressionFunction ( QStringLiteral ( " difference" ), 2 , fcnDifference, QStringLiteral ( " GeometryGroup" ) )
4143
4173
<< new QgsStaticExpressionFunction ( QStringLiteral ( " distance" ), 2 , fcnDistance, QStringLiteral ( " GeometryGroup" ) )
4144
4174
<< new QgsStaticExpressionFunction ( QStringLiteral ( " hausdorff_distance" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " geometry1" ) ) << QgsExpressionFunction::Parameter ( QStringLiteral ( " geometry2" ) )
0 commit comments