Skip to content

Commit

Permalink
[refFunctions] json helps and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang committed Sep 8, 2020
1 parent e3150d0 commit 900cef3
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 8 deletions.
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_contains
Expand Up @@ -20,6 +20,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_crosses
Expand Up @@ -21,6 +21,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_disjoint
Expand Up @@ -21,6 +21,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_equals
Expand Up @@ -20,6 +20,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_intersects
Expand Up @@ -21,6 +21,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_nearest
Expand Up @@ -26,6 +26,12 @@
"arg": "max_distance",
"description": "an optional maximum distance to limit the number of matching features (if not set, only the nearest feature will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_touches
Expand Up @@ -21,6 +21,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
6 changes: 6 additions & 0 deletions resources/function_help/json/geometry_overlay_within
Expand Up @@ -21,6 +21,12 @@
"arg": "limit",
"description": "an optional integer to limit the number of matching features (if not set, all features will be returned)",
"optional": true
},
{
"arg": "cache",
"description": "set this to true to build a local spatial index (most of the time, this is unwanted, unless you are working with a particularly slow data provider)",
"optional": true,
"default": false
}
],
"examples": [
Expand Down
15 changes: 7 additions & 8 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -5795,7 +5795,7 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
}
else
{
cachedTarget = context->cachedValue( cacheLayer ).value<QgsVectorLayer*>();
cachedTarget = context->cachedValue( cacheLayer ).value<QgsVectorLayer *>();
}

if ( !context->hasCachedValue( cacheIndex ) )
Expand All @@ -5820,7 +5820,7 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
fidsList = spatialIndex.intersects( intDomain );
}

QListIterator<QgsFeatureId> i(fidsList);
QListIterator<QgsFeatureId> i( fidsList );
while ( i.hasNext() )
{
// TODO : ignore feature if same as this (and remove logic below)
Expand All @@ -5832,8 +5832,8 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
{
// If the cache (local spatial index) is not enabled, we directly
// get the features from the target layer
request.setFilterRect(intDomain);
QgsFeatureIterator fit = targetLayer->getFeatures(request);
request.setFilterRect( intDomain );
QgsFeatureIterator fit = targetLayer->getFeatures( request );
QgsFeature feat;
while ( fit.nextFeature( feat ) )
{
Expand All @@ -5855,7 +5855,7 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress
bool found = false;
QVariantList results;

QListIterator<QgsFeature> i(features);
QListIterator<QgsFeature> i( features );
while ( i.hasNext() )
{
QgsFeature feat = i.next();
Expand Down Expand Up @@ -5920,8 +5920,6 @@ static QVariant executeGeomOverlay( const QVariantList &values, const QgsExpress

// Intersect functions:

typedef bool ( QgsGeometry::*t_relationFunction )( const QgsGeometry &geometry ) const;

static QVariant fcnGeomOverlayIntersects( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction * )
{
return executeGeomOverlay( values, context, parent, &QgsGeometry::intersects );
Expand Down Expand Up @@ -6329,7 +6327,8 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
yFunc->setIsStatic( false );
functions << yFunc;

QMap< QString, QgsExpressionFunction::FcnEval > geometry_overlay_definitions {
QMap< QString, QgsExpressionFunction::FcnEval > geometry_overlay_definitions
{
{ QStringLiteral( "geometry_overlay_intersects" ), fcnGeomOverlayIntersects },
{ QStringLiteral( "geometry_overlay_contains" ), fcnGeomOverlayContains },
{ QStringLiteral( "geometry_overlay_crosses" ), fcnGeomOverlayCrosses },
Expand Down

0 comments on commit 900cef3

Please sign in to comment.