Skip to content
Permalink
Browse files

Fix slow filter rect requests with server python plugins (refs #13919)

  • Loading branch information
nyalldawson committed Feb 21, 2016
1 parent fab8dc2 commit 0446f50729d7894f5b20d0fbeeca4b3a3aba35ae
Showing with 6 additions and 18 deletions.
  1. +2 −2 src/server/qgsaccesscontrol.cpp
  2. +4 −16 src/server/qgswmsserver.cpp
@@ -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( "))" ) );
}
}

@@ -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 */
@@ -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() )
@@ -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 );

0 comments on commit 0446f50

Please sign in to comment.
You can’t perform that action at this time.