Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Workaround to fix WFS provider empty() method
  • Loading branch information
m-kuhn committed Jun 4, 2018
1 parent 280e10e commit 0b96e3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -1199,6 +1199,27 @@ QString QgsWFSProvider::translateMetadataValue( const QString &mdKey, const QVar
{
return value.toString();
}
}

bool QgsWFSProvider::empty() const
{
QgsFeature f;
QgsFeatureRequest request;
request.setSubsetOfAttributes( QgsAttributeList() );
request.setFlags( QgsFeatureRequest::NoGeometry );

// Whoops, the WFS provider returns an empty iterator when we are using
// a setLimit call in combination with a subsetString.
// Remove this method (and default to the QgsVectorDataProvider one)
// once this is fixed
#if 0
request.setLimit( 1 );
#endif
if ( getFeatures( request ).nextFeature( f ) )
return false;
else
return true;

};

bool QgsWFSProvider::describeFeatureType( QString &geometryAttribute, QgsFields &fields, QgsWkbTypes::Type &geomType )
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wfs/qgswfsprovider.h
Expand Up @@ -111,6 +111,8 @@ class QgsWFSProvider : public QgsVectorDataProvider
QString translateMetadataKey( const QString &mdKey ) const override;
QString translateMetadataValue( const QString &mdKey, const QVariant &value ) const override;

bool empty() const override;

public slots:

void reloadData() override;
Expand Down

0 comments on commit 0b96e3a

Please sign in to comment.