|
28 | 28 | #include "qgsdistancearea.h"
|
29 | 29 | #include "qgsfeature.h"
|
30 | 30 | #include "qgsgeometry.h"
|
| 31 | +#include "qgsgeometryengine.h" |
31 | 32 | #include "qgslogger.h"
|
32 | 33 | #include "qgsmaplayerregistry.h"
|
33 | 34 | #include "qgsogcutils.h"
|
@@ -1474,6 +1475,21 @@ static QVariant fcnYMax( const QVariantList& values, const QgsExpressionContext*
|
1474 | 1475 | return QVariant::fromValue( geom.boundingBox().yMaximum() );
|
1475 | 1476 | }
|
1476 | 1477 |
|
| 1478 | +static QVariant fcnRelate( const QVariantList& values, const QgsExpressionContext*, QgsExpression* parent ) |
| 1479 | +{ |
| 1480 | + QgsGeometry fGeom = getGeometry( values.at( 0 ), parent ); |
| 1481 | + QgsGeometry sGeom = getGeometry( values.at( 1 ), parent ); |
| 1482 | + |
| 1483 | + if ( fGeom.isEmpty() || sGeom.isEmpty() ) |
| 1484 | + return QVariant(); |
| 1485 | + |
| 1486 | + QgsGeometryEngine* engine = QgsGeometry::createGeometryEngine( fGeom.geometry() ); |
| 1487 | + QString result = engine->relate( *sGeom.geometry() ); |
| 1488 | + delete engine; |
| 1489 | + |
| 1490 | + return QVariant::fromValue( result ); |
| 1491 | +} |
| 1492 | + |
1477 | 1493 | static QVariant fcnBbox( const QVariantList& values, const QgsExpressionContext*, QgsExpression* parent )
|
1478 | 1494 | {
|
1479 | 1495 | QgsGeometry fGeom = getGeometry( values.at( 0 ), parent );
|
@@ -2171,6 +2187,7 @@ const QStringList& QgsExpression::BuiltinFunctions()
|
2171 | 2187 | << "y_min" << "ymin" << "y_max" << "ymax" << "geom_from_wkt" << "geomFromWKT"
|
2172 | 2188 | << "geom_from_gml" << "geomFromGML" << "intersects_bbox" << "bbox"
|
2173 | 2189 | << "disjoint" << "intersects" << "touches" << "crosses" << "contains"
|
| 2190 | + << "relate" |
2174 | 2191 | << "overlaps" << "within" << "buffer" << "centroid" << "bounds"
|
2175 | 2192 | << "bounds_width" << "bounds_height" << "convex_hull" << "difference"
|
2176 | 2193 | << "distance" << "intersection" << "sym_difference" << "combine"
|
@@ -2292,6 +2309,7 @@ const QList<QgsExpression::Function*>& QgsExpression::Functions()
|
2292 | 2309 | << new StaticFunction( "y_max", 1, fcnYMax, "GeometryGroup", QString(), false, QStringList(), false, QStringList() << "ymax" )
|
2293 | 2310 | << new StaticFunction( "geom_from_wkt", 1, fcnGeomFromWKT, "GeometryGroup", QString(), false, QStringList(), false, QStringList() << "geomFromWKT" )
|
2294 | 2311 | << new StaticFunction( "geom_from_gml", 1, fcnGeomFromGML, "GeometryGroup", QString(), false, QStringList(), false, QStringList() << "geomFromGML" )
|
| 2312 | + << new StaticFunction( "relate", 2, fcnRelate, "GeometryGroup" ) |
2295 | 2313 | << new StaticFunction( "intersects_bbox", 2, fcnBbox, "GeometryGroup", QString(), false, QStringList(), false, QStringList() << "bbox" )
|
2296 | 2314 | << new StaticFunction( "disjoint", 2, fcnDisjoint, "GeometryGroup" )
|
2297 | 2315 | << new StaticFunction( "intersects", 2, fcnIntersects, "GeometryGroup" )
|
|
0 commit comments