Skip to content

Commit 0b96e3a

Browse files
committedJun 4, 2018
Workaround to fix WFS provider empty() method
1 parent 280e10e commit 0b96e3a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

‎src/providers/wfs/qgswfsprovider.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,27 @@ QString QgsWFSProvider::translateMetadataValue( const QString &mdKey, const QVar
11991199
{
12001200
return value.toString();
12011201
}
1202+
}
1203+
1204+
bool QgsWFSProvider::empty() const
1205+
{
1206+
QgsFeature f;
1207+
QgsFeatureRequest request;
1208+
request.setSubsetOfAttributes( QgsAttributeList() );
1209+
request.setFlags( QgsFeatureRequest::NoGeometry );
1210+
1211+
// Whoops, the WFS provider returns an empty iterator when we are using
1212+
// a setLimit call in combination with a subsetString.
1213+
// Remove this method (and default to the QgsVectorDataProvider one)
1214+
// once this is fixed
1215+
#if 0
1216+
request.setLimit( 1 );
1217+
#endif
1218+
if ( getFeatures( request ).nextFeature( f ) )
1219+
return false;
1220+
else
1221+
return true;
1222+
12021223
};
12031224

12041225
bool QgsWFSProvider::describeFeatureType( QString &geometryAttribute, QgsFields &fields, QgsWkbTypes::Type &geomType )

‎src/providers/wfs/qgswfsprovider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class QgsWFSProvider : public QgsVectorDataProvider
111111
QString translateMetadataKey( const QString &mdKey ) const override;
112112
QString translateMetadataValue( const QString &mdKey, const QVariant &value ) const override;
113113

114+
bool empty() const override;
115+
114116
public slots:
115117

116118
void reloadData() override;

0 commit comments

Comments
 (0)