Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix slow filter rect requests with server python plugins (refs #13919)
  • Loading branch information
nyalldawson committed Feb 21, 2016
1 parent fab8dc2 commit 0446f50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/server/qgsaccesscontrol.cpp
Expand Up @@ -38,7 +38,7 @@ void QgsAccessControl::filterFeatures( const QgsVectorLayer* layer, QgsFeatureRe
}
if ( !expressions.isEmpty() )
{
featureRequest.setFilterExpression( expressions.join( " AND " ) );
featureRequest.setFilterExpression( QString( "((" ).append( expressions.join( ") AND (" ) ).append( "))" ) );
}
}

Expand All @@ -61,7 +61,7 @@ QString QgsAccessControl::extraSubsetString( const QgsVectorLayer* layer ) const
sqls.append( sql );
}
}
return sqls.isEmpty() ? QString::null : sqls.join( " AND " );
return sqls.isEmpty() ? QString() : QString( "((" ).append( sqls.join( ") AND (" ) ).append( "))" );
}

/** Return the layer read right */
Expand Down
20 changes: 4 additions & 16 deletions src/server/qgswmsserver.cpp
Expand Up @@ -2171,21 +2171,14 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
bool hasGeometry = addWktGeometry || featureBBox;
fReq.setFlags((( hasGeometry ) ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) | QgsFeatureRequest::ExactIntersect );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
mAccessControl->filterFeatures( layer, fReq );
if ( ! searchRect.isEmpty() )
{
if ( fReq.filterExpression() )
{
fReq.setFilterExpression( QString( "intersects( $geometry , geomFromWKT( '%1' ) ) AND ( %2 )" ).
arg( searchRect.asWktPolygon(), fReq.filterExpression()->expression() ) );
}
else
{
fReq.setFilterRect( searchRect );
}
fReq.setFilterRect( searchRect );
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
mAccessControl->filterFeatures( layer, fReq );

QStringList attributes;
QgsField field;
Q_FOREACH ( field, layer->pendingFields().toList() )
Expand All @@ -2194,11 +2187,6 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
}
attributes = mAccessControl->layerAttributes( layer, attributes );
fReq.setSubsetOfAttributes( attributes, layer->pendingFields() );
#else
if ( ! searchRect.isEmpty() )
{
fReq.setFilterRect( searchRect );
}
#endif

QgsFeatureIterator fit = layer->getFeatures( fReq );
Expand Down

0 comments on commit 0446f50

Please sign in to comment.